bdfd1m1g | Database Administration |
Figure 69 shows the same 78 blocks of a fixed file divided into three interleaves. The ordinal numbers in each interleave start at zero.
Figure 69. Interleaving: &SW00xxx: ILV, BOR, EOR, and EO#
With interleaved files, it is easy to increase the size of each interleave (that is, the number of blocks in each file).
In the previous example (relating to customers in three cities) interleaving would be appropriate if the number of cities is unlikely to change, but the number of customers in each city is likely to change substantially. This would require a change in the number of prime blocks (ordinals) in each interleave.
It is difficult to add a new file to an interleaved fixed file. This requires reorganization of the files.
Interleaving is appropriate when the number of files is likely to stay the same but the number of subfiles in each file might change.
The following statements are needed in the DSECT of any program that accesses data in any of the three interleaves:
&SW00ILV SETC '3' Number of interleaves &SW00EOR SETC '77' Ending ordinal &SW00RBV SETC '#TPFDB01' Addressing algorithm &SW00EO# SETC '77'
&SW00ILV defines a set of three interleaved files. Code the remaining &SW00xxx fields, including &SW00RBV as if the file were non-interleaved.
The application program can specify the interleave by coding the INTERLV parameter in a DBOPN macro. For example:
DBOPN REF=zzzzzz,...,INTERLV=label
In this example, store the interleave number in location label before coding the DBOPN macro statement.
Alternatively, the program can specify the interleave by using the INTERLV parameter when it calls other macros (for example, DBRED or DBADD). This is less controlled, and is not recommended.
For C applications, a program accesses an interleave using the dfopt function with the DFOPT_INTERLEAVE option.
With interleaved files, it is easy to increase the number of blocks in each interleave. For example, to add one subfile to each interleave in the previous diagram, add 3 blocks to the fixed file. Set the DBDEF EO# parameter to the new number of blocks:
EO#=80 Set end ordinal number in the fixed file
Change the DSECT statements for the interleaved file, as follows:
&SW00EOR SETC '80' &SW00EO# SETC '80'