Index File - Index Node Record

For each key defined, a complete and independent index is constructed which consists of a tree of index node records. Each index node record contains actual key values associated with data records written to the indexed file. Every key value in a node will point either to a subordinate index node record or, if it is a leaf node, to the data record associated with the key.

The top level node record is called the root.

The default node size is 1024 bytes, but can change depending on the largest key size defined for the file. If the largest key is greater than 238 bytes, the node size will be 4096 bytes.

Note: It is possible to change the default node size by setting the XFHNODE environment variable to one of 512, 1024 (the default) or 4096 bytes. However, if you set XFHNODE to 512 and the largest key value is greater than 120 bytes, the value of XFHNODE will be overwritten by 1024. Also, if you set XFHNODE to 512 or 1024 and the largest key value is greater than 248, the value of XFHNODE will be overwritten by 4096. The setting of XFHNODE is only effective at the time that the file is created - you cannot alter the node size of an existing file.

The index node record contains:

Size Description of the field
2
Bit 15
Security flag. Value should match value of trailing security flag.
Bits 14-0
Pointer to the end of the last key value block in this record, relative to the start of this record.
n Key value block
...  
n Key value block
1 Index number.

The value is the same for all nodes belonging to the same index tree. Contains zero if this is the primary key.

1
Bit 7
Security flag. Value should match value of leading security flag.
Bits 6-0
Level of this node. Leaf nodes are level 0.

The key value block contains:

Size Description of the field
1 Present only when compression of leading characters is enabled. Contains a count of leading characters identical to those in the previous key. It will always be 0 for the first key in a node.
1 Present only when compression of trailing spaces is enabled. Contains a count of trailing spaces for this key value.
n Key value.
duplicate-occurrence Optional. Duplicate occurrence number. See the topic Types of Indexed File for details. This field is present only if duplicates are allowed for this key. It contains the duplicate occurrence count. The first key stored that is a duplicate has this field set to 1. Second duplicate has this field set to 2, and so on.
file-pointer-size
Most significant bit
Reserved if duplicate key compression is enabled. Set if the next Key-Value Block is a duplicate of this one.
Remainder
Address of the data record in the data file if this is a leaf node; otherwise, the address of the subordinate index node record in the index file.