Collaboration diagram for sort_stream_i:
Used for bulk-loading indexes but may be used independently. After creating an instance of sort_stream_i, you can keep putting <key,element> pairs into the stream, which will save the records in a temporary persistent store, sort them, and then return them in sorted order like an iterator over the temporary store. The temporary store is destroyed upon completion (destruction).
Before you can begin inserting pairs into the stream, you must initialize the stream with information about the key on which to sort (where it is to be found, what its length and type are, etc.).
See example sort_stream::cpp
Definition at line 434 of file sort.h.
Public Member Functions | |
NORET | sort_stream_i () |
Constructor. If you use this constructor you must use init(). | |
NORET | sort_stream_i (const key_info_t &k, const sort_parm_t &s, uint est_rec_sz=0) |
Constructor that calls init(). | |
void | init (const key_info_t &k, const sort_parm_t &s, uint est_rec_sz=0) |
Initialize the stream with necessary metadata. | |
void | finish () |
Release resources, render unusable. (Called by destructor if apropos.). | |
rc_t | put (const cvec_t &key, const cvec_t &elem) |
Insert a key,elem pair into the stream. | |
rc_t | get_next (vec_t &key, vec_t &elem, bool &eof) |
Fetch the next key,elem pair from the stream (in sorted order). | |
bool | is_empty () const |
Returns true until the first put() call. | |
bool | is_sorted () const |
Sort happens at first get_next call, returns false until then. | |
Static Public Member Functions | |
static PFC | get_cmp_func (key_info_t::key_type_t type, bool up) |
Return a key-comparison function for the given pre-defined key type. |
NORET sort_stream_i::sort_stream_i | ( | const key_info_t & | k, | |
const sort_parm_t & | s, | |||
uint | est_rec_sz = 0 | |||
) |
Constructor that calls init().
[in] | k | See key_info_t, which describes the keys used to sort the data to be inserted. |
[in] | s | See ssm_sort::sort_parm_t, which describes behavior of the sort. |
[in] | est_rec_sz | Estimated record size; allows the sort to estimate how many items will fit in a page. |
static PFC sort_stream_i::get_cmp_func | ( | key_info_t::key_type_t | type, | |
bool | up | |||
) | [static] |
Return a key-comparison function for the given pre-defined key type.
[in] | type | See key_info_t. |
[in] | up | If true, the function returns will sort in ascending order, if false, in descending order. |
void sort_stream_i::init | ( | const key_info_t & | k, | |
const sort_parm_t & | s, | |||
uint | est_rec_sz = 0 | |||
) |
Initialize the stream with necessary metadata.
[in] | k | See key_info_t, which describes the keys used to sort the data to be inserted. |
[in] | s | See ssm_sort::sort_parm_t, which describes behavior of the sort. |
[in] | est_rec_sz | Estimated record size; allows the sort to estimate how many items will fit in a page. |
Insert a key,elem pair into the stream.
[in] | key | Key of key,elem pair. |
[in] | elem | Element of key,elem pair. |
Fetch the next key,elem pair from the stream (in sorted order).
[out] | key | Key of key,elem pair. |
[out] | elem | Element of key,elem pair. |
[out] | eof | Set to true if no more pairs in the stream. |