Cursors are used to navigate sets of records returned by index searches with functions
mco_cursor_first(),mco_cursor_last(),mco_cursor_prev()andmco_cursor_next(). A cursor structure is also used for calls to generatedindex_cursorfunctions andmco_uda_cursor(). Following is the definition of themco_cursor_tstructure as defined inmco.h:#define mco_cursor_size (100*sizeof(mco_offs_t)) /* cursor structure size */ typedef struct mco_cursor_t_ { MCO_PUB_STRUCT_BASE c[mco_cursor_size_w]; } mco_cursor_t, /* cursor (structure) */ *mco_cursor_h; /* cursor handle (pointer) */The array c contains 100 offset values. These are set to the addresses of database records satisfying a search.
Cursor Types
Cursors are of different types depending on the type of index they operate on. The following cursor types are defined in
mco.h:typedef enum MCO_CURSOR_TYPE_E_ { MCO_LIST_CURSOR = 0, MCO_TREE_CURSOR = 1, MCO_HASH_CURSOR = 2, MCO_KDTREE_CURSOR = 3, MCO_PTREE_CURSOR = 4, MCO_RTREE_CURSOR = 5 } MCO_CURSOR_TYPE;MCO_LIST_CURSORList (hash) index cursor.MCO_TREE_CURSORtreeindex cursor.MCO_HASH_CURSORhashindex cursor.MCO_KDTREE_CURSORkdtreeindex cursor.MCO_PTREE_CURSORpatriciatrie index cursor.MCO_RTREE_CURSORrtreeindex cursor.Cursor Operation Codes
When calling an index search function to return a cursor, one of the following cursor operation codes (
opcodes) must be specified:typedef enum MCO_OPCODE_E_ { MCO_NOP = 0, /* No operation */ MCO_LT = 1, /* Values less-than sample */ MCO_LE = 2, /* Values less-or-equal to the sample */ MCO_EQ = 3, /* Values equal to the sample */ MCO_GE = 4, /* Values greater-or-equal to the sample */ MCO_GT = 5, /* Values greater-than the sample */ MCO_OVERLAP = 6, /* rtree, overlapping regions */ MCO_CONTAIN = 7, /* rtree, containing regions */ MCO_EX = 8, /* patricia, exact match */ MCO_BEST = 9, /* patricia, the best, longest match */ MCO_PREF = 10, /* patricia, prefix match */ MCO_NEXT_MATCH = 11, /* patricia, continue search instead of new search */ MCO_NEIGHBOURHOOD = 12, /* rtree, list object distances from the sample */ MCO_NEIGHBORHOOD = MCO_NEIGHBOURHOOD, /* American synonym */ MCO_BELONG = MCO_LE /* patricia, sample belongs to value */ } MCO_OPCODE;MCO_NOPNo operation.MCO_LTValues less than the sample.MCO_LEValues less than or equal to the sample.MCO_EQValues equal to the sample.MCO_GEValues greater than or equal to the sample.MCO_GTValues greater than the sample.MCO_OVERLAPrtree, overlapping regions.MCO_CONTAINrtree, containing regions.MCO_EXpatricia, exact match.MCO_BESTpatricia, the best, longest match.MCO_PREFpatricia, prefix match.MCO_NEXT_MATCHpatricia, continue the search instead of starting a new search.MCO_NEIGHBORHOOD (= MCO_NEIGHBOURHOOD)rtree, list object distances from the sample.MCO_BELONG (= MCO_LE)patricia, sample belongs to value.