Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Selected Deferred Index features extended to non-deferred indexes

In V11 and later, the following Deferred Index features have been extended to regular (non-deferred) indexes. c-tree Server now supports the following abilities:

  • A regular (non-deferred) index can be created with the data file open in shared mode.
  • The background loading of a regular or deferred index can be queued to the index load thread.

Creation of regular index with data file open in shared mode:

PRMIIDX() can be used to create a regular (non-deferred) index with the data file open in shared mode by setting the dxtdsiz field of the IFIL parameter passed to PRMIIDX() to either ctNO_IDX_BUILD or QUEUE_IDX_BUILD.

If using ctNO_IDX_BUILD, the index can be loaded later by either:

  • Calling RBLIIDX() with the data file open in exclusive mode (which was already supported).

    or

  • Calling ctDeferredIndexControl() with opcode of DFKCTLqueueload to queue the index load to the background index load thread.

When using ctQUEUE_IDX_BUILD, the index load is immediately queued to the background index load thread after the index is created.

Note that when a regular index is created with the data file open in shared mode, all connections that already have the associated data file open will internally open the new index and their ISAM record add/delete/update operations will affect this new index. This means that if an error occurs when updating the new index (for example if the add or update attempts to add a key that already exists in that index), the operation fails with that error. By contrast, updates to a deferred index that is created with the data file open in shared mode are queued to a background thread.

Queueing index load:

This example shows how to use ctDeferredIndexControl() to queue the index load to the background index load thread. The data file must be open by the calling connection. Set the datno field of the DFKQIL structure to the data file number. The idxlst field of the DFKQIL structure holds the file numbers of the indexes for which you want to queue an index load operation.

DFKQIL dfkqil;

LONG keynos[1];

memset(&dfkctl,0,sizeof(dfkctl));

memset(&dfkqil,0,sizeof(dfkqil));

dfkctl.verson = DFKCTL_VERS_V01;

dfkctl.opcode = DFKCTLqueueload;

dfkctl.verson = DFKCTL_VERS_V01;

dfkctl.opcode = DFKCTLqueueload;

dfkctl.bufsiz = sizeof(dfkqil);

dfkctl.bufptr = (pTEXT) &dfkqil;

dfkqil.verson = DFKQIL_VERS_V01;

dfkqil.datno = datno;

dfkqil.numidx = 1;

keynos[0] = datno + 1;

dfkqil.idxlst = &keynos;

if ((rc = ctDeferredIndexControl(&dfkctl)) != NO_ERROR) {

printf("Error: Failed to schedule index load: %d\n",

rc);

goto err_ret;

}

printf("Successfully scheduled index load.\n");

TOCIndex