The BTREE file structure is a true variable-level recursive structure. The host automatically balances the BTREE structure as keys are added and deleted; therefore no periodic key rebuilds are necessary. In addition, the BTREE algorithms allow you to set the average number of keys per node to optimize key file performance for your particular file and system characteristics.
The BTREE data structure allows any data-level file to have keys defined for it. Dictionary, MD, or SYSTEM level files may not have keys defined. When a file has keys set up, a total of four elements are necessary in order for the BTREE system to operate:
The data file itself is flagged by the BTREE system as a DB type file. The change of the file from a D to a DB type file is automatic and requires no action by you.
The keys themselves are stored in an additional data portion under the same dictionary. This additional data portion has the same name as the main data portion with a $ appended to the end. For example, a key file for a file named CUSTOMER would be named CUSTOMER,CUSTOMER$. This naming convention allows multiple data portion files to each have individual key files. Note that with this naming convention, some file names are not valid:
The file name should not end in a $.
The file’s data portion name may be no larger than 99 characters long.
The file’s key file must not clash with a dictionary item.
The key definitions are stored in an intermediate format in an item in the file’s dictionary called SMART-TREE-DEF.
A control item is created for each data portion in the file’s dictionary. This item has the same name as the data file name with the addition of a CHAR(164) appended to the end. This item will appear to have the same item-ID as the D-pointer for the key file (a CHAR(164) is a $ character with the high order bit set).
See Also
Using the BTREE File Structure System
Using Lookup and Browse Routines
Source Code to Lookup Routines
Maintaining Key File Performance
Stack Code Calculator Function