Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

RECBYT Segment Mode

The RECBYT segment mode specifies an index segment containing the character ‘D’ in the first byte. The rest of the segment is padded with NULL bytes, however, there is no reason to use a segment length greater than one.

To take complete advantage of the variable-length (VLEN) space management capabilities, create an index using only a RECBYT segment with a segment length of one that allows duplicates. Since a duplicate key adds the record position as part of the actual key value, this results in a 5-byte (9-byte for huge files) duplicate key with a single byte (‘D’ for active data records) for the segment. This is referred to as a “RECBYT Index”.

Use NbrOfKeyEntries() on a RECBYT index for an exact count of variable-length records in the data file.

Note: The RECBYT index enables backward physical traversal of variable-length records. By default, the c-treeDB API creates this index on every table. Because it is an extra index, it slows inserts, updates, and deletes. Unless you need to walk variable-length records backwards, disable the creation of the index by adding NORECBYT to the table create mode.

Improved Deleted Space Management

For non-transaction controlled variable-length files or multi-user standalone variable-length files, FairCom DB will always consider coalescing space when trailing space is marked deleted. For example, deleting records in reverse physical order will obtain maximum space coalescing. An available RECBYT index in these cases allows coalescing in both directions for optimal space usage.

For transaction-controlled variable-length files, this variable-length space management does not take place and deleted variable record space is not coalesced. For records that don't change much in size, space is still efficiently reused based on the space management index present in the file. Only when a RECBYT index exists for this case will FairCom DB check and possibly merge the adjacent deleted record space for transaction controlled files.

The following example adds a RECBYT index to the ISEG/IIDX structures in ctixmg.c:

ISEG segments[] = {

{0,15,5}, {4,5,2}, /* First index key segments */

{0,4,1}, /* Second index key segments */

{4,9,2}, {0,9,5}, /* Third index key segments */

{0,1,RECBYT} /* RECBYT key segment with a

segment length of one. Segment offset is ignored */

};


IIDX ndxs[] = {

{24, 4,1,1,32,2, segments},

{ 4, 0,0,0, 0,1,&segments[2]},

{22,12,1,1,32,2,&segments[3],NULL,"vcusti.2"},

{ 5, /* 1 byte segment length plus 4 byte offset */

0, 1, /* Allow Duplicates */

0,0,1,&segments[5]}

};

TOCIndex