Documentation

FairCom ISAM for C

Previous Topic

Next Topic

c-tree Keys

Key values permit data records to be located quickly, avoiding lengthy sequential searches. c-tree maintains keys in an index file that can be rapidly searched. Each key in a c-tree index file has a data record pointer associated with it.

Target key values are passed to the c-tree routines by a pointer to the first byte of the key value. Keys in c-tree should not be handled as normal character strings. No restrictions are placed on the individual byte values comprising the key. In particular, a null or zero byte DOES NOT signify the end of a key value. Therefore, you should use a function like cpybuf() to manipulate keys.

When you define a key value to c-tree, you establish the length of the key. c‑tree does not pad the target key values to their full length for you. It assumes that you have completely filled in the target key value to the defined length specified at the time the index file is created. If you are not careful to pad your keys to their full length, you may find that your index searches will not work the way you expect.

Note: Target key buffers must be the full length of the key to avoid memory corruption errors. TransformKey() reads and writes the full key length, even when using automatic transformation. See TransformKey for more information.

In the following example, we set up an input buffer of 128 bytes, greater than any key lengths in the application, and initialize the full length to 0x20, the space character, before taking a target value.

#define INPBUFSIZ 128

TEXT inpbuf[INPBUFSIZ];

. . .

ctsfill(inpbuf,32,INPBUFSIZ);

gets(inpbuf);

In This Section

ISAM Keys

Duplicate Keys

Sequence Numbers

Alternative Key Types

Deferred Indexing

TOCIndex