LoadKey Add key value to index file in presorted order. Short Name LOADKEY() Type Low-level index file function Declaration COUNT LoadKey(COUNT keyno, pVOID target, LONG recbyt, COUNT typadd) Description LoadKey() inserts the key value pointed to by target and the associated data record position recbyt into index file number keyno. Repeated calls to LoadKey() provide an exceptionally fast method to add key values which have already been sorted. The sorted keys must be added to an empty index or all of the sorted keys must be greater than the existing entries. Calls to LoadKey() should not be intermixed for different indices. typadd signals the beginning, middle and end of the calls to LoadKey() as shown below:
LoadKey() is used by the RebuildIFile() to quickly build the indices associated with a data file. Return
See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values. Example TEXT target[11]; LONG recbyt,trials; COUNT name_key,mode; FILE *fp;
mode = FRSADD; while (fscanf(fp,"%s %ld",target,&recbyt) == 2) {
if (LoadKey(name_key,target,recbyt,mode)) break; if (trials++) mode = NXTADD; }
printf("\nerror during LoadKey (%d) on trial #%ld", uerr_cod,trials);
Limitations LoadKey() does not pad key values. Therefore, if you pass a key value which is not completely specified to its full length, LoadKey() will effectively pad the value with whatever “garbage” follows the key value in memory. Key values added to an index which supports duplicate keys (keydup = 1 in CreateIndexFile() or CreateIndexMember()) have their last 4 bytes overwritten by the associated data record position. In this way, identical key values become distinguishable. The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSetHgh() and ctGetHgh() functions to set or get the high order 4 bytes of the file offset. See also AddKey(), CreateIndexFile(), CreateIndexMember(), ctSetHgh(), ctGetHgh() |
||||||||||||||||||||||||||||||