The C sequence libraries provide three functions for detecting and traversing Run-Length Encoding (RLE). The functions are available with both the plain and RLE implementations so that representation-neutral code can call them unconditionally.
mco_seq_rle_count()Returns the logical repeat count for physical item
posin the iterator's current tile. Call this function only after the iterator's rawnextcallback returnsMCO_S_OKand with0 <= pos < iterator->tile_size. The RLE implementation returns the run count; the plain implementation returns 1.mco_seq_rle_count_t mco_seq_rle_count( mco_seq_iterator_h iterator, int pos);mco_seq_is_rle()Returns
MCO_YESwhen the active sequence implementation is RLE andMCO_NOfor the plain implementation.mco_bool mco_seq_is_rle(void);mco_seq_rle_decode()Initializes
dstas a lazy, expanded view ofsrc. RLE runs are expanded to logical items and element NULL bits are preserved. The function does not rewrite stored database data. With the plain implementation it provides compatible pass-through behavior.MCO_RET mco_seq_rle_decode( mco_seq_iterator_h dst, mco_seq_iterator_h src);Decode and Traverse an Iterator
The source iterator, its database transaction, and its object handle must remain valid until the decoded iterator has been consumed.
mco_seq_iterator_t source = { 0 }; mco_seq_iterator_t decoded = { 0 }; float value; MCO_RET rc; rc = Quote_high_iterator("e, &source); if (rc == MCO_S_OK) rc = mco_seq_rle_decode(&decoded, &source); while (rc == MCO_S_OK) { rc = mco_seq_next_float(&decoded, &value); if (rc == MCO_S_OK) use_value(value); else if (rc == MCO_E_SEQ_NULL_VALUE) rc = MCO_S_OK; /* The decoded iterator advanced past a NULL. */ } if (rc == MCO_S_CURSOR_END) rc = MCO_S_OK;If NULL values must be preserved for later processing rather than handled one at a time, consume the decoded iterator with
mco_seq_get_nullable_TYPE().Direct Physical Traversal
Applications normally do not need to decode an iterator before passing it to another sequence function: the operators in the RLE libraries understand runs directly. Decode or inspect repeat counts only when application code needs a dense logical stream or accesses
iterator.tileitself.See RLE Compression for a complete direct-tile loop and the restrictions on processing independently compressed fields.