sort_stream_i Class Reference
[Sorting]

Inherits smlevel_top, and xct_dependent_t.

Collaboration diagram for sort_stream_i:

Collaboration graph
[legend]
List of all members.

Detailed Description

Sorting tool.

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

Examples:

sort_stream.cpp.

Definition at line 429 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.


Constructor & Destructor Documentation

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().

Parameters:
[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.


Member Function Documentation

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.

Parameters:
[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.

Parameters:
[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.

rc_t sort_stream_i::put ( const cvec_t key,
const cvec_t elem 
)

Insert a key,elem pair into the stream.

Parameters:
[in] key Key of key,elem pair.
[in] elem Element of key,elem pair.
Note:
Must be invoked in a transaction, although this is not enforced gracefully.

rc_t sort_stream_i::get_next ( vec_t key,
vec_t elem,
bool &  eof 
)

Fetch the next key,elem pair from the stream (in sorted order).

Parameters:
[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.
Note:
Must be invoked in a transaction, although this is not enforced gracefully.


The documentation for this class was generated from the following file:
Generated on Wed Jul 7 17:22:43 2010 for Shore Storage Manager by  doxygen 1.4.7