The library of Analytics Functions that operate on database fields of type sequence use the mco_seq_iterator_t
structure defined in header file mcoseq.h
as follows:
typedef struct mco_seq_iterator_t_ { mco_seq_iterator_next_t next; /* method for obtaning next portion of values */ mco_seq_iterator_reset_t reset; /* start iteration from beginning */ mco_seq_iterator_prepare_t prepare; /* prepare iterator (used to start parallel processing) */ mco_seq_iterator_merge_t merge; /* merge two iterators (used to merge results of parallel processing) */ uint2 elem_size; /* size of element */ uint2 tile_size; /* number of tile items */ uint2 tile_offs; /* offset to first not handled tile item */ uint1 rle_offs; /* index within same RLE value */ uint1 prepared; /* flag set by prepare function */ mco_seq_no_t first_seq_no; /* first sequence number (inclusive) */ mco_seq_no_t next_seq_no; /* sequence number of element returned by sudsequent invocation of next() function */ mco_seq_no_t last_seq_no; /* last sequence number (inclusive) */ struct mco_seq_iterator_t_* opd[3]; /*operands of sequence operator */ void* buf; /* memory buffer used by operators requiring temporary memory (reverse, order_by) */ mco_size_t buf_size; /* size of buffer */ uint1 elem_type; /* result element type MCO_DD_... */ uint1 bounded; /* iterator is used in expression */ uint1 createdBySql; /* iterator was created by SQL */ uint8 context[MCO_SEQ_ITERATOR_CTX_SIZE/8]; /* operator specific context */ mco_seq_tile_t tile; /* tile of values */ } mco_seq_iterator_t, *mco_seq_iterator_h;
Functions such as the generated functions classname_fieldname_search()
use the mco_seq_boundary_kind_t
structure to specify the boundary type:
typedef enum mco_seq_boundary_kind_t_ { MCO_SEQ_BOUNDARY_OPEN, MCO_SEQ_BOUNDARY_INCLUSIVE, MCO_SEQ_BOUNDARY_EXCLUSIVE } mco_seq_boundary_kind_t;
To optimize access of sequences in memory, sequence functions operate on tiles, which are arrays of sequence values in contiguous memory blocks. The last element tile
of the mco_seq_iterator_t
structure, which is used for this internal optimization, is defined as follows:
typedef union mco_seq_tile_t_ { mco_seq_bool arr_mco_seq_bool[MCO_SEQ_TILE_SIZE_BYTES/sizeof(mco_seq_bool)]; char arr_char[MCO_SEQ_TILE_SIZE_BYTES]; int1 arr_int1[MCO_SEQ_TILE_SIZE_BYTES]; int2 arr_int2[MCO_SEQ_TILE_SIZE_BYTES/sizeof(int2)]; int4 arr_int4[MCO_SEQ_TILE_SIZE_BYTES/sizeof(int4)]; mco_int8 arr_int8[MCO_SEQ_TILE_SIZE_BYTES/sizeof(mco_int8)]; uint1 arr_uint1[MCO_SEQ_TILE_SIZE_BYTES/sizeof(uint1)]; uint2 arr_uint2[MCO_SEQ_TILE_SIZE_BYTES/sizeof(uint2)]; uint4 arr_uint4[MCO_SEQ_TILE_SIZE_BYTES/sizeof(uint4)]; uint8 arr_uint8[MCO_SEQ_TILE_SIZE_BYTES/sizeof(uint8)]; mco_time arr_mco_time[MCO_SEQ_TILE_SIZE_BYTES/sizeof(mco_time)]; mco_date arr_mco_date[MCO_SEQ_TILE_SIZE_BYTES/sizeof(mco_date)]; mco_datetime arr_datetime[MCO_SEQ_TILE_SIZE_BYTES/sizeof(mco_datetime)]; float arr_float[MCO_SEQ_TILE_SIZE_BYTES/sizeof(float)]; double arr_double[MCO_SEQ_TILE_SIZE_BYTES/sizeof(double)]; } mco_seq_tile_t MCO_ALIGN_16;