|
Automatic Index Header
The first 140 bytes of the index are as follows:
| Offset |
Length |
Contents |
| 0 |
2 |
"0xC139" - filePro
4.5 index magic number |
| 2 |
2 |
Depth of index tree |
| 4 |
2 |
"1" if root node
is in block zero, else "0" |
| 6 |
2 |
Maximum number of keys per node |
| 8 |
4 |
Size of each node, in bytes |
| 12 |
4 |
Block number of root node |
| 16 |
4 |
Number of records in index |
| 20 |
2 |
Length of sort key, in bytes |
| 22 |
2 |
Length of record number portion
of key in bytes |
| 24 |
64 |
Sort information
-- see below |
| 88 |
4 |
Block number of freechain head |
| 92 |
48 |
Index comment (NUL-terminated ASCII) |
|
Notes:
The length of the sort key is the combined length of each sort item.
The length of the record number portion is 4, plus 1 byte for each
associated field within the sort key.
When fPTransfer sends an index, it is truncated to the first block
only, and the magic number is set of "0xC138".
The root node may be combined with the index header within block
zero. In that case, the root node block number is stored as a
negative number, the absolute value of which is its offset within
block zero. Currently, that is always "-140". |

Sort Information
The sort information is the following 8 bytes
repeated 8 times - once for each possible sort key.
| Offset |
Length |
Contents |
| 0 |
2 |
The field number |
| 2 |
1 |
Associated field instance |
| 3 |
1 |
"0" - Used for output formats only |
| 4 |
2 |
Field length |
| 6 |
1 |
"0" for ascending, "1" for descending |
| 7 |
1 |
Field type |
|

Non-leaf node
Each non-leaf node has the following format:
| Offset |
Length |
Meaning |
| 0 |
2 |
The number of node pointers within
this node |
| 2 |
4 |
Left node pointer |
| 6 |
n*m |
n entries consisting of: Lowest key
of node (n bytes), Node pointer (4 bytes). The node count
does not include the left node pointer. |
|

Leaf node
Each leaf node has the following format:
| Offset |
Length |
Meaning |
| 0 |
4 |
Backward node pointer link |
| 4 |
4 |
Forward node pointer link |
| 8 |
2 |
Extended block flag:
" 0" - A normal block
" 1" - This block contains a list of duplicate keys, and continues into the next
block
" 2" - This block is the end of a chain of duplicate-key blocks. |
| 10 |
2 |
Number of key values in this node |
| 12 |
2*n |
Offset within block of start of each
key value |
|
Each key value is stored as:
| Offset |
Length |
Meaning |
| 0 |
n |
The key value |
| n |
m*o |
A list of the records for this key |
|
| Each entry consists of 1 byte for each associated field
instance, followed by a 4-byte record number. The length
of each of these portions is stored in the header. If there
are multiple copies of an index key, its value is stored
only once. This is followed by a list of the associated field
instances and record numbers. If the number of duplicates
prevents all record numbers from fitting into one block,
the key is spread across multiple blocks, and the "extended
block flag" is set appropriately. The leaf nodes are stored
in a doubly-linked list. |

Freechain
Each node on the freechain is stored in a singly-linked list
as:
| Offset |
Length |
Meaning |
| 0 |
4 |
Forward link pointer |
|
|