The namespace within TPIE for the Access Method Interface elements. More...
Classes | |
class | heap_element |
This is a heap element. More... | |
class | heap_ptr |
This is a record pointer element. More... | |
class | Internal_Sorter_Base |
The base class for internal sorters. More... | |
class | Internal_Sorter_Obj |
Comparision object based Internal_Sorter_base subclass implementation; uses quick_sort_obj(). More... | |
class | merge_base |
Superclass for merge management objects. More... | |
class | merge_heap_obj |
class | merge_heap_op |
A merge heap object base class - also serves as the full implementation for objects with a < comparison operator. More... | |
class | merge_heap_ptr_obj |
A record pointer heap that uses a comparison object. More... | |
class | merge_heap_ptr_op |
A record pointer heap base class - also serves as the full implementation for objects with a < comparison operator. More... | |
class | qsort_item |
A simple class that facilitates doing key sorting followed by in-memory permuting to sort items in-memory. More... | |
class | stack |
An implementation of an external-memory stack compatible with the old AMI interface. More... | |
class | stream |
A Stream<T> object stores an ordered collection of objects of type T on external memory. More... | |
Typedefs | |
typedef TPIE_OS_SIZE_T | arity_t |
Intended to signal the number of input streams in a merge. More... | |
Enumerations | |
enum | err { NO_ERROR = 0, IO_ERROR, END_OF_STREAM, READ_ONLY, OS_ERROR, BASE_METHOD, BTE_ERROR, MM_ERROR, OBJECT_INITIALIZATION, OBJECT_INVALID, PERMISSION_DENIED, INSUFFICIENT_MAIN_MEMORY, INSUFFICIENT_AVAILABLE_STREAMS, ENV_UNDEFINED, NO_MAIN_MEMORY_OPERATION, BIT_MATRIX_BOUNDS, NOT_POWER_OF_2, NULL_POINTER, GENERIC_ERROR = 0xfff, SCAN_DONE = 0x1000, SCAN_CONTINUE, MERGE_DONE = 0x2000, MERGE_CONTINUE, MERGE_OUTPUT, MERGE_READ_MULTIPLE, MATRIX_BOUNDS = 0x3000, SORT_ALREADY_SORTED = 0x4000 } |
Legacy TPIE error codes. More... | |
enum | merge_output_type { MERGE_OUTPUT_OVERWRITE = 1, MERGE_OUTPUT_APPEND } |
enum | stream_type { READ_STREAM = 1, WRITE_STREAM, APPEND_STREAM, READ_WRITE_STREAM } |
AMI stream types passed to constructors. More... | |
enum | stream_status { STREAM_STATUS_VALID = 0, STREAM_STATUS_INVALID } |
AMI stream status. More... | |
Functions | |
template<class T , class M > | |
err | merge (stream< T > **instreams, arity_t arity, stream< T > *outstream, M *m_obj) |
Merges arity streams using a merge management object and writes result into outstream. More... | |
template<class T , class M > | |
err | partition_and_merge (stream< T > *instream, stream< T > *outstream, M *m_obj) |
Partitions a stream into substreams small enough to fit. More... | |
template<class T , class M > | |
err | single_merge (stream< T > **instreams, arity_t arity, stream< T > *outstream, M *m_obj) |
Merges arity streams in memory using a merge management object and write result into outstream. More... | |
template<class T , class M > | |
err | main_mem_merge (stream< T > *instream, stream< T > *outstream, M *m_obj) |
Reads instream in memory and merges it using m_obj->main_mem_operate(); if instream does not fit in main memory returns INSUFFICIENT_MAIN_MEMORY;. More... | |
template<class T , class M > | |
void | merge_sorted_runs (typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator start, typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator end, file_stream< T > *outStream, M *MergeHeap, TPIE_OS_OFFSET cutoff=-1, progress_indicator_base *indicator=NULL) |
This is a common merge routine for all of the AMI_merge_sorted, AMI_ptr_merge_sorted and AMI_key_merge_sorted entry points. More... | |
template<class T , class CMPR > | |
void | merge_sorted (typename tpie::array< std::auto_ptr< file_stream< T > > >::iterator start, typename tpie::array< std::auto_ptr< file_stream< T > > >::iterator end, file_stream< T > *outStream, CMPR *cmp) |
Merging with a heap that contains the records to be merged. More... | |
template<class T , class CMPR > | |
void | ptr_merge_sorted (typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator start, typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator end, file_stream< T > *outStream, CMPR *cmp) |
Merging with a heap that keeps a pointer to the records rather than the records themselves: CMPR is the class of the comparison object, and must contain the method compare() which is called from within the merge. More... | |
TPIE_DEPRECATED_CLASS_A (template< typename T > class TPIE_DEPRECATED_CLASS_B queue:public tpie::queue< T >{public:queue(){}queue(const std::string &basename):tpie::queue< T >(basename){}}) | |
err | exception_kind (const exception &e) |
template<class T > | |
err | sort (stream< T > *instream_ami, stream< T > *outstream_ami, tpie::progress_indicator_base *indicator=NULL) |
template<class T , class CMPR > | |
err | sort (stream< T > *instream_ami, stream< T > *outstream_ami, CMPR *cmp, progress_indicator_base *indicator=NULL) |
template<class T > | |
err | ptr_sort (stream< T > *instream_ami, stream< T > *outstream_ami, progress_indicator_base *indicator=NULL) |
template<class T , class CMPR > | |
err | ptr_sort (stream< T > *instream_ami, stream< T > *outstream_ami, CMPR *cmp, progress_indicator_base *indicator=NULL) |
template<class T , class KEY , class CMPR > | |
err | key_sort (stream< T > *instream_ami, stream< T > *outstream_ami, KEY, CMPR *cmp, progress_indicator_base *indicator=NULL) |
template<class T > | |
err | sort (stream< T > *instream_ami, progress_indicator_base *indicator=0) |
template<class T , class CMPR > | |
err | sort (stream< T > *instream_ami, CMPR *cmp, progress_indicator_base *indicator=NULL) |
template<class T > | |
err | ptr_sort (stream< T > *instream_ami, progress_indicator_base *indicator=NULL) |
template<class T , class CMPR > | |
err | ptr_sort (stream< T > *instream_ami, CMPR *cmp, progress_indicator_base *indicator=NULL) |
template<class T , class KEY , class CMPR > | |
err | key_sort (stream< T > *instream_ami, KEY, CMPR *cmp, progress_indicator_base *indicator=NULL) |
The namespace within TPIE for the Access Method Interface elements.
In-place sorting variant of key_sort(stream<T> instream_ami, stream<T> *outstream_ami, KEY dummykey, CMPR *cmp, progress_indicator_base indicator=NULL), see also In-place Variants for Sorting in TPIE.
In-place sorting variant of ptr_sort(stream<T> instream_ami, stream<T> *outstream_ami, CMPR *cmp, progress_indicator_base indicator=NULL), see also In-place Variants for Sorting in TPIE.
In-place sorting variant of ptr_sort(stream<T> instream_ami, stream<T> *outstream_ami, progress_indicator_base indicator=NULL), see also In-place Variants for Sorting in TPIE.
In-place sorting variant of sort(stream<T> instream_ami, stream<T> *outstream_ami, CMPR *cmp, progress_indicator_base indicator=NULL), see also In-place Variants for Sorting in TPIE.
In-place sorting variant of sort(stream<T> instream_ami, stream<T> *outstream_ami, tpie::progress_indicator_base indicator=NULL), see also In-place Variants for Sorting in TPIE.
A version of sort that takes an input stream of elements of type T, an output stream, and a user-specified comparison object.
A version of sort that takes an input stream of elements of type T, and an output stream, and and uses the < operator to sort, see also Sorting in TPIE.
inline int compare (const KEY & k1, const KEY & k2);
The user-written compare() function computes the order of the two user-defined keys k1
and k2
, and returns -1, 0, or +1 to indicate that k1<k2
, k1==k2
, or k1>k2
respectively.
The comparison object "cmp", of (user-defined) class represented by CMPR, must have a member function called "compare" which is used for sorting the input stream; see also Comparing within Sorting.
typedef TPIE_OS_SIZE_T tpie::ami::arity_t |
Intended to signal the number of input streams in a merge.
Definition at line 44 of file merge_sorted_runs.h.
enum tpie::ami::err |
Legacy TPIE error codes.
Functions in the AMI interface of TPIE typically return error codes of the enumerated type err.
Enumerator | |
---|---|
NO_ERROR |
No error occurred. The call the the entry point returned normally. |
IO_ERROR |
A low level I/O error occurred. |
END_OF_STREAM |
An attempt was made to read past the end of a stream or write past the end of a substream. |
READ_ONLY |
An attempt was made to write to a read-only stream. |
OS_ERROR |
An unexpected operating system error occurred. Details should appear in the log file if logging is enabled.
|
BASE_METHOD |
An attempt was made to call a member function of the virtual base class of tpie::ami::stream. This indicates a bug in the implementation of TPIE streams. |
BTE_ERROR |
An error occurred at the BTE level. |
MM_ERROR |
An error occurred within the memory manager. |
OBJECT_INITIALIZATION |
An TPIE entry point was not able to properly initialize the operation management object that was passed to it. This generally indicates a bug in the operation management object's initialization code. |
OBJECT_INVALID |
A passed object is invalid. |
PERMISSION_DENIED |
A passed object is inaccessible due to insufficient permissions. |
INSUFFICIENT_MAIN_MEMORY |
The memory manager could not make adequate main memory available to complete the requested operation. Many operations adapt themselves to use whatever main memory is available, but in some cases, when memory is extremely tight, they may not be able to function. |
INSUFFICIENT_AVAILABLE_STREAMS |
TPIE could not allocate enough intermediate streams to perform the requested operation. Certain operating system restrictions limit the number of streams that can be created on certain platforms. Only in unusual circumstances, such as when the application itself has a very large number of open streams, will this error occur. |
ENV_UNDEFINED |
An environment variable necessary to initialize the TPIE accessing environment was not defined. |
BIT_MATRIX_BOUNDS |
A bit matrix larger than the number of bits in an offset into a stream was passed. |
NOT_POWER_OF_2 |
The length of a stream on which a bit permutation was to be performed is not a power of two. |
NULL_POINTER |
An attempt was made to perform a matrix operation on matrices whose bounds did not match appropriately. |
SCAN_DONE |
Value returned by a scan_object: Indicates that the function should be called again with any "taken" inputs replaced by the next objects from their respective streams. |
SCAN_CONTINUE |
Value returned by a scan_object: Indicates that the scan is complete and no more input needs to be processed. |
MERGE_DONE |
Value returned by a merge_management_object, signaling that the merge() completed. |
MERGE_CONTINUE |
Value returned by a merge_management_object, telling merge() to continue to call the operate() member function of the management object with more data. |
MERGE_OUTPUT |
Value returned by a merge_management_object, signaling that the last merge() call generated output for the output stream. |
MERGE_READ_MULTIPLE |
Value returned by a merge_management_object, telling merge() that more than one input ob ject was consumed and thus the input flags should be consulted. |
MATRIX_BOUNDS |
Matrix related error. |
SORT_ALREADY_SORTED |
Values returned by sort routines if input does not require sorting. |
Definition at line 45 of file err.h.
AMI stream types passed to constructors.
err tpie::ami::main_mem_merge | ( | stream< T > * | instream, |
stream< T > * | outstream, | ||
M * | m_obj | ||
) |
Reads instream in memory and merges it using m_obj->main_mem_operate(); if instream does not fit in main memory returns INSUFFICIENT_MAIN_MEMORY;.
Definition at line 442 of file merge.h.
References tpie::consecutive_memory_available(), INSUFFICIENT_MAIN_MEMORY, NO_ERROR, tpie::ami::stream< T >::read_array(), tpie::ami::stream< T >::seek(), tpie::ami::stream< T >::stream_len(), tp_assert, tpie::tpie_delete_array(), and tpie::ami::stream< T >::write_array().
Referenced by partition_and_merge().
err tpie::ami::merge | ( | stream< T > ** | instreams, |
arity_t | arity, | ||
stream< T > * | outstream, | ||
M * | m_obj | ||
) |
Merges arity streams using a merge management object and writes result into outstream.
It is assumed that the available memory can fit the arity streams, the output stream and also the space required by the merge management object; merge() checks this and then calls single_merge();
Definition at line 253 of file merge.h.
References tpie::consecutive_memory_available(), INSUFFICIENT_MAIN_MEMORY, tpie::ami::stream< T >::main_memory_usage(), single_merge(), tpie::STREAM_USAGE_CURRENT, and tpie::STREAM_USAGE_MAXIMUM.
void tpie::ami::merge_sorted | ( | typename tpie::array< std::auto_ptr< file_stream< T > > >::iterator | start, |
typename tpie::array< std::auto_ptr< file_stream< T > > >::iterator | end, | ||
file_stream< T > * | outStream, | ||
CMPR * | cmp | ||
) |
Merging with a heap that contains the records to be merged.
CMPR is the class of the comparison object, and must contain the method compare() which is called from within the merge.
This is one of the merge entry points for merging without the merge_management_object used by TPIE's merge. These routines perform the special case of merging when the the required output is the original records interleaved according to a comparison operator or function.
Definition at line 149 of file merge_sorted_runs.h.
References tpie::ami::merge_heap_op< REC, Compare >::allocate(), and merge_sorted_runs().
void tpie::ami::merge_sorted_runs | ( | typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator | start, |
typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator | end, | ||
file_stream< T > * | outStream, | ||
M * | MergeHeap, | ||
TPIE_OS_OFFSET | cutoff = -1 , |
||
progress_indicator_base * | indicator = NULL |
||
) |
This is a common merge routine for all of the AMI_merge_sorted, AMI_ptr_merge_sorted and AMI_key_merge_sorted entry points.
It is also used by the sort entry points AMI_sort, AMI_ptr_sort and AMI_key_sort and by the routine AMI_partition_and_merge. Differences are encapsulated within the merge heap object MergeHeap. It is assumed that MergeHeap::allocate() was called before entering ami_merge_sorted_runs. ami_merge_sorted_runs takes both the max number of elements to read from any stream and also a boolean flag for showing a progress indicator.
Definition at line 71 of file merge_sorted_runs.h.
References tpie::stream_crtp< child_t >::can_read(), tpie::file_stream< T >::read(), and tpie::file_stream< T >::write().
Referenced by merge_sorted(), and ptr_merge_sorted().
err tpie::ami::partition_and_merge | ( | stream< T > * | instream, |
stream< T > * | outstream, | ||
M * | m_obj | ||
) |
Partitions a stream into substreams small enough to fit.
in main memory, operates on each in main memory, and then merges them together, possibly in several passes if low memory conditions dictate. This function takes three arguments: instream
points to the input stream, outstream
points to the output stream, and mo
points to a merge management object that controls the merge. This function takes care of all the details of determining how much main memory is available, how big the initial substreams can be, how many streams can be merged at a time, and how many levels of merging must take place.
In order to complete the merge successfully, the function needs sufficient memory for a binary merge. If not enough memory is available, the function fails and it returns INSUFFICIENT_MAIN_MEMORY. Otherwise, it returns NO_ERROR.
err main_mem_operate(T* mm_stream, size_t len);
where mm_stream
is a pointer to an array of objects that have been read into main memory, len
is the number of objects in the array. This function is called by AMI_partition_and_merge() when a substream of the data is small enough to fit into main memory, and the (application-specific) processing of this subset of the data can therefore be completed in internal memory. size_t space_usage_per_stream(void);
This function should return the amount of main memory that the merge management object will need per per input stream. Merge management objects are allowed to maintain data structures whose size is linear in the number of input streams being processed. Definition at line 508 of file merge.h.
References tpie::ami::stream< T >::available_streams(), tpie::ami::stream< T >::chunk_size(), tpie::consecutive_memory_available(), INSUFFICIENT_AVAILABLE_STREAMS, INSUFFICIENT_MAIN_MEMORY, main_mem_merge(), tpie::ami::stream< T >::main_memory_usage(), NO_ERROR, tpie::ami::stream< T >::persist(), tpie::ami::stream< T >::read_array(), tpie::ami::stream< T >::seek(), single_merge(), tpie::ami::stream< T >::stream_len(), tpie::STREAM_USAGE_MAXIMUM, tp_assert, tpie::tpie_delete(), tpie::tpie_delete_array(), and tpie::ami::stream< T >::write_array().
void tpie::ami::ptr_merge_sorted | ( | typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator | start, |
typename tpie::array< tpie::auto_ptr< file_stream< T > > >::iterator | end, | ||
file_stream< T > * | outStream, | ||
CMPR * | cmp | ||
) |
Merging with a heap that keeps a pointer to the records rather than the records themselves: CMPR
is the class of the comparison object, and must contain the method compare() which is called from within the merge.
This is one of the merge entry points for merging without the merge_management_object used by TPIE's merge. These routines perform the special case of merging when the the required output is the original records interleaved according to a comparison operator or function.
Definition at line 181 of file merge_sorted_runs.h.
References tpie::ami::merge_heap_ptr_op< REC, CMPR >::allocate(), and merge_sorted_runs().
err tpie::ami::single_merge | ( | stream< T > ** | instreams, |
arity_t | arity, | ||
stream< T > * | outstream, | ||
M * | m_obj | ||
) |
Merges arity streams in memory using a merge management object and write result into outstream.
Definition at line 298 of file merge.h.
References END_OF_STREAM, MERGE_CONTINUE, MERGE_DONE, MERGE_OUTPUT, MERGE_READ_MULTIPLE, NO_ERROR, OBJECT_INITIALIZATION, tpie::ami::stream< T >::read_item(), tp_assert, tpie::tpie_delete_array(), and tpie::ami::stream< T >::write_item().
Referenced by merge(), and partition_and_merge().