Using KSAM/XL and KSAM 64 (32650-90886)

16 Chapter1
Introduction
KSAM XL File Format
The index portion of the file is organized in a tree structure. Figure 1-3. provides a diagram
of a simple structure. The entry point of the structure, the root, either points to the
location of an entry or directs the search to branches of the structure for higher or lower
entries. The branches narrow the search, again, either to an entry location or to an
ever-decreasing number of higher or lower entries. The lowest level, or leaves, provides
pointers to the locations of the remaining records. Root, branch, and leaf pages for each
key are contained in the index portion of the KSAM file.
Figure 1-3. Simple Index Tree Structure
Data Area
The data area of the file follows the index area and contains all the data records. A 4-byte
record header precedes each record. The first byte of this record header specifies whether
the record has been deleted. When records are written to a KSAM file, the data record is
written to the data area first. Keys are then inserted in the appropriate indexes using the
data area location for creating pointers.
By default, records are stored in chronological order. When new records are appended, they
are written at the end of the file, maintaining the chronological order. As records are
deleted, the record space is not recovered and reused.
If the REUSE option is specified when the file is built, new records appended to the file are
written in available space throughout the file, thus interrupting the chronological