Before creating a file, you need to estimate the amount of space needed for the file. The modulo specifies the number of groups allocated for a file.
In choosing a modulo, estimate the average size of an item and the number of items in a file. If the average item size is less than 2000 bytes, you can use the following chart to estimate the modulo of a file. The estimate for a sample file is given in the right-hand column. Round off calculations to the next largest integer.
A. |
Average Size of Item |
______: |
100 |
B. |
Number of Items |
______: |
50 |
C. |
Multiply A and B |
______: |
5000 |
D. |
Group Size (2000) |
______: |
2000 |
E. |
Divide C By D |
______: |
3 |
F |
Choose prime number (Modulo) |
______: |
3 |
The modulo of a file should be a prime number for an even distribution of items. It should never be a multiple of 2 or 5. The CREATE-FILE processor ensures that a modulo is entered that is not a multiple of two, adding one if necessary to get an odd-numbered modulo. For instance, if a modulo of 2 is entered, CREATE-FILE specifies a modulo of 3.
Some databases are static by design; that is, they contain a fixed amount of information that does not change often or increase significantly. Others are dynamic in that they increase in size over time. When estimating the size of a file, the user should know whether to allow for the dynamic growth of the database.
You can calculate the amount of space available in each group for expansion. Use the following chart to run this test.
G. |
Divide B by F (Group Size) |
______: |
16 |
H. |
Multiply A by G (Characters Used) |
______: |
1600 |
I. |
Subtract H from D (Available Group Space) |
______: |
400 |
J. |
Divide I by A (Number of New Items) |
______: |
4 |
Using the sample figures, this test tells us that with a modulo of 3, the average number of items per group is 16 and that there is sufficient space for 4 more items per group. This is an indication that the file can expand by 12 items or approximately 20 per cent over the estimate before requiring additional storage space. This is, however, only an estimate of actual usage; the hashing scheme does not guarantee even distribution across all groups.
Additional information on creating and deleting files and on monitoring the size and efficiency of files, is presented in Managing Files.
See Also