Compact Data Sets

The following figure illustrates the layout of a compact data set.

Figure 24. Compact Data Sets

Compact Data Sets


Records in compact data sets vary in size because they contain items which vary in size, vary in number of occurrences, or are stored conditionally. Records are not maintained in logical order. Within embedded compact data sets, blocks can contain records belonging to different masters.

The following text explains in more detail the data block format, the data control word (DCW) layout, the record directory layout, the address block layout, the key entry layout, the block 0 (zero) format, and the available block format.

Data Block Format

The following figure illustrate the format of a data block in a compact data set.

Example 5. Compact Data Set Data Block Format

             WORD
              0      Data control word (DCW)
              1      Table serial number (TSN)
              2      Block type
                       1 = Data block.
              3      ---
                      .
                      .   Record directory words.
                      .
                      ---
                      ---
                      .
                      .   Available space.
                      .
                      ---
                      ---
                      .
                      .
                      .   Data records.
                      .
                      .
                      ---


Data Control Word (DCW) Layout

The following figure illustrates the data control word (DCW) layout of a compact data set.

Example 6. Compact Data Set Data Control Word (DCW) Layout

            * * A A A B   B B C C C C
            * * A A A B   B B C C C C
            * * A A A B   B B C C C C
            * * A A A B   B B C C C C

            *    47: 08     Unused

            A    39: 12     SLOTSAVAIL

                      Number of directory entry slots available.

            B    27: 12     SLOTSALLOC

                      Number of directory entry slots allocated.

            C    15: 16     WORDSAVAIL

                      Number of words of available data space.


Record Directory Layout

The following figure illustrates the record directory layout of a compact data set.

            A A A A B B   B B B B B *
            A A A A B B   B B B B B C
            A A A A B B   B B B B B D
            A A A A B B   B B B B B E
            
            A    47: 16     RECSIZE

                      Record size in words.

                 31: 28     RECSTART

                      Record location (word offset).

            *    03: 01     Unused

            C    02: 01     PARENTBLOCK

                           1 = This is original block for record.

            D    01: 01     RECPRESENT

                           1 = Record present in this block.

            E    00: 01     SLOTINUSE

                           1 = Directory entry (slot) is in use.
            C  D  E
            =  =  =

            -  -  0    Slot available; C and D are ignored.

            1  1  1    Record present in this block at word B
                       for A words.
                       This is parent (original) block.

            0  1  1    Record is present in this block at word B
                       for A words.
                       Parent block is some other block.

            -  0  1    Record has been moved to another block.
                       Record is now record A of block B.

Example 7. Compact Data Set Data Record Directory Layout


Every data block contains a record directory which is used to locate data records. Each directory entry indicates the size and location of one record. Compact data set records are addressed using AA words in which the WAF field is really a record number, not a word offset. This record number locates the directory entry, which in turn locates the actual record.

Although the size and location of a data record can vary, the directory entry never moves. If a record size changes, the system attempts to retain the record in its original block. If the record outgrows its present block, it can be moved to any other data block. In this case, the record has two directory entries, one in the original block and another in the new block. The directory entry in the original block refers to the directory entry in the new block, which in turn refers to the record. Whenever the record is modified, the system attempts to return it to the original block. Regardless of how many times the record changes blocks, it can always be located in at most two accesses since the original directory entry is adjusted with each change.

When a record is deleted, both its directory entry and record space become available for reallocation. The directory entry of the record is marked as deleted and the available directory count in the data control word (DCW) is incremented. In addition, the record area is compacted to produce a single available space in the middle of the block.

A table is used to keep track of available space. A 2-word entry exists in the table for each partially filled data block. The first word serves as the key; it contains the available area size and block number. The second word is an AA word which addresses the block.

Address Block Layout

The following figure illustrates the address block layout of a compact data set.

Example 8. Compact Data Set Address Block Layout

             WORD
               0           Table control word (TCW)
               1           Table serial number (TSN)
               2           Block type
                             2 = Address Block
               3           ---
                            .
                            . Unused available space entries.
                            .
                           ---
                           ---
                            .
                            . In-use available space entries in
                            . ascending order.
                           ---
                           ---
                            . Unused available space entries.
                            .
                           ---


Key Entry Layout

The following figure illustrates the key entry layout of a compact data set.

Example 9. Compact Data Set Address Block Layout

                A A A A B B   B B B B B *
                A A A A B B   B B B B B *
                A A A A B B   B B B B B *
                A A A A B B   B B B B B *
                A    47: 16     Available space size
                B    31: 28     Block number
                      *    03: 04     Unused


The available table is organized like a disjoint index sequential set. Entries are contained in table blocks arranged hierarchically with the root in block 1. Since entries are maintained in order by size, a binary search can be performed to find the closest fit; that is, the smallest block sufficient to contain the record. Whenever the amount of available space in a block changes, the available space table (DKTABLE) is updated. When an entry is to be added to a full table, the table is split just as an index sequential set is split with a LOADFACTOR value of 50.

When either data or table blocks become empty, they are linked in a one-way list of empty blocks, the head of which resides in block 0 (zero). (Refer to “Common Features” earlier in this appendix for more information.)

Block 0 (Zero) Format

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

Example 10. Compact Data Set Block 0 (Zero) Format

  WORD
    0      NEXTBLOCKADDRESS
                Block address of next available block.
    1      LASTBLOCKADDRESS
                Block address of first never-used block.
    2      Last Record Serial Number (RSN) allocated.
    3      Reserved
    4      ---
            .
            .   Unused.
            .
           ---

Available Block Format

The following figure illustrates the available block format of a compact data set.

Example 11. Compact Data Set Available Block Format

             WORD
             0      Link to next available block.
             1      Unused.
             2      BLOCKTYPE
                     3 = Available block.
             3      ---
                      .
                      .   Unused.
                      .
                      --- 


Compact Data Set Restrictions

The restrictions for compact data sets are as follows:

  • The FIND NEXT and FIND PRIOR operations are not permitted for embedded compact data sets.

  • Variable-format records are not allowed.

  • Filler items are not allowed.

  • Compact data sets cannot be partition masters.

  • The BLOCKSIZE must be compatible with the compact data set's minimum record size.

The reasons for the restrictions on compact data sets are as follows:

  • Compact data sets are designed to save disk space. To accomplish this saving, extra processor time is required to compact records at store time and expand them at find time. Additional processor time is also required to maintain contiguous available areas within blocks.

  • Each invocation of a database which contains a compact data set causes an extra buffer to be allocated. This buffer, which is large enough to contain the largest compact record, is used for record compaction and expansion, and is shared by all compact data sets in that invocation.

  • Record modification is extremely efficient provided the size of the record remains the same. When records are created or deleted, or the record size is changed, record relocation is normally required.

  • Disjoint compact data sets can be accessed in physical order using FIND NEXT and FIND PRIOR operations. Valid records can be selected quickly by examining the record directory. Increasing the block size normally improves the performance of the operation.

  • Embedded compact data sets can be accessed only by sets and subsets since records are not physically grouped by master. Accessing all records under one master does not in general benefit from a large block size.

  • The data control word (DCW) limits the number of directory entry slots to 4095. Therefore, the BLOCKSIZE must be no larger than what would accommodate 4095 records with the minimum record size.