HPlogo Using KSAM XL and KSAM 64 > Chapter 1 Introduction

KSAM XL File Format

MPE documents

Complete PDF
Table of Contents
Index

E0300 Edition 4 ♥
E0394 Edition 3

A KSAM file is a single file consisting of an index portion and a data portion. Figure 1-1 "General Representation of the KSAM Format" provides a general representation of the contents of a KSAM file.

Figure 1-1 General Representation of the KSAM Format

[General Representation of the KSAM Format]

Index Area


The index area contains a control block, bit mappings for the pages of the index and data areas, and the key indexes. The control block contains the file specifications and key specifications established when the file was built. It also contains pointers to the index and data page maps to manage the file's space.

A key index contains a key value and pointer for each record. This index data is arranged in ascending order based on the key value. If alternate keys are identified for the file, alternate indexes are created for each key.

When the file is opened for sequential processing, records can be accessed by physical location in the file or by key sequence. The selected key index supplies a pointer to the data record. Figure 1-2 "A Simplified View of the KSAM File Structure" shows how key index entries relate to the appropriate records in the file.

Figure 1-2 A Simplified View of the KSAM File Structure

[A Simplified View of the KSAM File Structure]

The index portion of the file is organized in a tree structure. Figure 1-3 "Simple Index Tree Structure" 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

[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 sequence. In this case, physical location of a record does not represent the chronological order of written records.

Any alterations to the data area of the file, such as additions, modifications, or deletions, are immediately available to subsequent accesses by any process. The file system guarantees the order of concurrent data access.




Terminology


Automatic Recovery