Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbNumberOfKeyEntries

Declaration

LONG ctdbDECL ctdbNumberOfKeyEntries(CTHANDLE Handle, NINT index);

Description

ctdbNumberOfKeyEntries() retrieves the number key entries in an index file identified by its index number.

  • Handle is a table handle or a handle that can be evaluated into a table handle.
  • index identifies the index to obtain the number of entries. The first index number is zero.

Return Values

ctdbNumberOfKeyEntries() returns the number of key entries in the index. ctdbNumberOfKeyEntries() returns -1 and users should call the ctdbGetError() function to retrieve the error code.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

Example


LONG Estimate(CTHANDLE Handle, NINT index)

{

LONG Retval = 0;

TEXT key1[16], key2[16];

VRLEN klen;

/* set the default index */

ctdbSetDefaultIndex(Handle, index);

/* load the first record */

ctdbFirstRecord(Handle);

/* build the target key for the first record */

klen = sizeof(key1);

ctdbBuildTargetKey(Handle, CTFIND_EQ, key1, &klen);

/* load the last record */

ctdbLastRecord(Handle);

/* build the target key for the last record */

klen = sizeof(key2);

ctdbBuildTargetKey(Handle, CTFIND_EQ, key2, &klen);

/* get the estimated span */

Retval = ctdbEstimateSpan(Handle, key1, key2);

if (Retval > 0)

Retval--;

return Retval;

}

See Also

ctdbGetError(), ctdbEstimateKeySpan()

TOCIndex