Cursors are used to navigate sets of records returned by index searches with functions
mco_cursor_first(), mco_cursor_last(), mco_cursor_prev()and. A cursor structure is also used for calls to generated index_cursor functions andmco_cursor_next()mco_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 offsets 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_CURSOR List ( hash) index cursor.MCO_TREE_CURSOR treeindex cursorMCO_HASH_CURSOR hashindex cursorMCO_KDTREE_CURSOR kdtreeindex cursorMCO_PTREE_CURSOR patriciaTrie index cursorMCO_RTREE_CURSOR rtreeindex cursor
Cursor Operation Codes
When calling an index search function to return a cursor, one of the following cursor operator 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_NOP No Operation MCO_LT Values less-than sample MCO_LE Values less-or-equal to the sample MCO_EQ Values equal to the sample MCO_GE Values greater-than-or-equal-to the sample MCO_GT Values greater-than the sample MCO_OVERLAP
rtree, overlapping regionsMCO_CONTAIN
rtree, containing regionsMCO_EX
patricia, exact matchMCO_BEST
patricia, the best, longest matchMCO_PREF
patricia, prefix matchMCO_NEXT_MATCH
patricia, continue search instead of new searchMCO_NEIGHBORHOOD (= MCO_NEIGHBOURHOOD)
rtree, list object distances from the sampleMCO_BELONG (= MCO_LE) patricia, sample belongs to value