Standard Data Set (Variable Format)

The following figure illustrates a standard data set with a variable format.

Figure 36. Standard Data Set (Variable Format)

Standard Data Set (Variable Format)


Variable-format standard data sets contain four types of blocks:

  • Block 0 (the control block)

  • Address blocks (DKTABLE overflow blocks)

  • Empty blocks

  • Data blocks

All blocks are the same size with the possible exception of block 0 (zero), which can use some of the words that would otherwise be wasted in its last segment on disk. Word 0 (zero) of every block is a control word.

Control Word Layout

The following figure illustrates the control word layout of a standard data set with a variable format.

Example 25. Standard Data Set (Variable Format) Control Word Layout

            * B B B B C   C C C C C C
            * B B B B C   C C C C C C
            * B B B B C   C C C C C C
            A B B B B C   C C C C C C
            *    47: 03     Unused
                      Zeros
            A    44: 01     DATABLOCKFLAG
                      0 = Address block
                      1 = Data block
            B    43: 16 LEFTOFFIELD/COUNTFIELD
                      If a data block, the field (LEFTOFFIELD)
                      contains the AA word of the next available
                      word for data in block.
                      If not a data block, the field (COUNTFIELD)
                      contains the number of AA words of available
                      records in this block minus 1.
                      If block 0, the field contains the number
                      of AA words in this piece.
            C    27: 28     LINKFIELD
                      Block address of next block in the
                      chain.  (In data blocks this field is
                      unused and can have any value.) 


Block 0 (Zero) Format

The following figure illustrates the block 0 (zero) format of a standard data set with a variable format.

Example 26. Standard Data Set (Variable Format) Block 0 (Zero) Format

            WORD
              0       CONTROL WORD
              1       ---
                       .
                       .   DKTABLE
                       .   AA words for available records
                       .   of type 0.
                       .
                      ---
                      CONTROL WORD
                      ---
                       .
                       .   DKTABLE
                       .   AA words for available records
                       .   of type 1.
                       .
                      ---
                      CONTROL WORD
              n       ---
                       .
                       .   DKTABLE
                       .   AA words for available records
                       .   of type 2.
                       .
                      ---
              n+1     EOF BLOCK
                           First never-used block.
              n+2     CURRENT BLOCK
                           Block from which records are currently 
                           being allocated.
              n+3     EMPTY BLOCK
                           Head of empty block chain.
              n+4
                       Last
                            Record Serial Number (RSN) allocated.
              n+5     Reserved
              ---.    Unused.
               


Note: Size of each DKTABLE in words = (BS-3) DIV (NUM REC TYPES)~ where BS = BLOCKSIZE rounded up to segment boundary.

Block 0 (zero) contains one DKTABLE for each variable-format record type. Each DKTABLE is the same length and begins with a control word. If the DKTABLE in block 0 (zero) is too small to hold all the AA words for the record type, then the link field in the control word points to the first address block containing additional AA words. Block 0 (zero) also locates the first empty block, the current block, and the first unused block. Block 0 (zero) never contains an addresscheck or checksum word.

Address Block Format

The following figure illustrates the address block format of a standard data set with a variable format.

Example 27. Standard Data Set (Variable Format) Address Block Format

            WORD
              0       CONTROL WORD
                           DATABLOCKFLAG = 0.
              1       ---
                       .
                       .   DKTABLE
                       .   AA words for available records
                       .   of a particular record type.
                       .
                      ---
                      ---
                       .
                       .   Unused.
                       .
                      ---


Address blocks contain AA words which locate available record spaces. All AA words in a single address block refer to records of the same type. The first address block for each variable-format type is located using the control words in block 0 (zero). Subsequent address blocks are linked using the control word at the beginning of each block.

Empty Block Format

The following figure illustrates the empty block format of a standard data set with a variable format.

Example 28. Standard Data Set (Variable Format) Empty Block Format

            WORD
              0      CONTROL WORD
                          DATABLOCKFLAG = 0.
              1      ---
                      .
                      .   Unused.
                      .
                     ---


Empty blocks are address blocks which have been emptied. When a new block is required, it is taken from the empty block chain if possible; otherwise, the new block is taken from the end of the file. The empty block chain begins in block 0 (zero) and continues through word 0 (zero) of each empty block.

Data Block Format

The following figure illustrates the data block format of a standard data set with a variable format.

Example 29. Standard Data Set (Variable Format) Data Block Format

            WORD
              0      CONTROL WORD
                         DATABLOCKFLAG = 1.
              1      ---
                      .
                      .   Data record of type X.
                      .   In-use or deleted.
                      .
                     ---
                     ---
                      .
                      .   Data record of type Y.
                      .   In-use or deleted.
                      .
                     ---
                     ---  <= Next available word for data record.
                      .
                      .   Unused.
                      .
                     ---


Data blocks contain data set records. Records are not maintained in logical order. Blocks in embedded data sets can contain records belonging to different masters. Each record contains a fixed part and optionally a variable part; both parts are stored contiguously in the block. Each block can contain a variety of record types. Once a block becomes a data block, it always remains a data block; when space is allocated for a particular record type, it only contains records of that type.

Standard Data Set (Variable Format) Restrictions

The following restrictions apply to standard data sets with a variable format:

  • Bit vectors are not allowed when the data set contains variable format records.

  • Standard data sets can be disjoint or embedded.

  • Sets must be declared for all embedded standard data sets.

  • FIND NEXT and FIND PRIOR operations are not allowed for embedded standard data sets.

The restrictions on standard data sets with a variable format are for the following reasons:

  • Variable-format standard data sets use disk space reasonably efficiently provided deleted record spaces can be reused. Since record spaces when allocated can be reused only by records of the same type, it is inefficient to create, delete, and not reuse records. When a large number of records of a particular type are deleted and are never to be reused, a reorganization can be performed to compact the data set and return the available space to the system.

  • Creation, deletion, and modification of records is efficient. When a record is created, the DKTABLE for its record type is examined. If an available space is present, this space is allocated to the record. If the DKTABLE is empty, an attempt is made to insert the record in the current block. If the record is too large to fit in the current block, an empty block is found, the record is inserted in it, and that block becomes the new current block. Empty blocks are obtained from the empty block chain if possible, otherwise from the end of file.

  • When a record is deleted, the AA word for the record is inserted in the appropriate DKTABLE. At compilation time, DASDL calculates the number of extra areas needed for the DKTABLE. Since the records are a variable format, and DASDL might calculate the number of extra areas based on an average record size, there might not be enough extra areas to accommodate the actual number of deleted records. A portion of the DKTABLE resides in memory when the database is open, making this a fast operation.

  • FIND NEXT and FIND PRIOR operations can be used to access variable-format standard data sets in physical order. The INVALIDTEXT error produced by the DASDL compiler is used to set certain items to null when a record is deleted. In-use records are selected by performing a valid record test upon these items. Records that do not satisfy the VALIDRECORDTEXT condition are assumed to be deleted. This test, where possible, is made on a single required item. If no such item exists, all data items must be examined to determine the validity of the record. Since in-use and deleted records can be intermingled, several deleted records can be examined before a valid record is located. Increasing the block size setting generally improves the performance of the operation.