Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Duplicate Keys

When you create a new index you can set the index up for keys that are always unique, or you can allow duplicate keys. If the index file is set up for duplicate keys, then the 4-byte data record position is automatically appended on the right end of the key to create a unique key value. The programmer must increase the key length by 4 bytes to allow for this addition.

This suffix DOES NOT appear in your data record. DO NOT create extra fields in the record structures to accommodate the suffix.

For example: a key length of 12 will have space for 8 bytes of an actual key value and 4 bytes for the automatic record position suffix.

When a key value is returned from one of the low level index file search routines (e.g., NextKey()), the last 4 bytes of the returned value will contain the associated data record position. Recall that the key value found in the index by a search routine is returned by placing a copy of the entry into the area pointed to by idxval. When using a value found in an index that supports duplicate keys, be sure to strip off the last 4 bytes before displaying the key, or using it for a computation if it is a numerical key, since the suffix is not a proper part of the key value.

Note: For indexes associated with Standard data files, a duplicate key length includes 4 bytes for the associated record position, which is used to break ties. If an index is created for a HUGE data file, then the key length must include 8 bytes for the associated record position.

TOCIndex