#include <ExternalSortInfo.h>
Public Member Functions | |
ExternalSortInfo (ExecStream &) | |
int | compareKeys (TupleData const &key1, TupleData const &key2) |
Compares two keys, taking ASC/DESC into account. | |
Public Attributes | |
ExecStream & | stream |
Main stream, for abort checking. | |
SegmentAccessor | externalSegmentAccessor |
Accessor for segment used to store runs externally. | |
SegmentAccessor | memSegmentAccessor |
Accessor for scratch segment used for building runs in-memory. | |
TupleDescriptor | tupleDesc |
Descriptor for tuples to be sorted. | |
TupleProjection | keyProj |
Projection of sort keys from tupleDesc. | |
std::vector< bool > | descendingKeyColumns |
| |
TupleDescriptor | keyDesc |
Descriptor for projected sort key tuples. | |
uint | nSortMemPages |
Maximum number of memory pages available for sorting. | |
uint | nSortMemPagesPerRun |
Maximum number of memory pages which can be filled per run. | |
uint | cbPage |
Number of bytes per memory page. |
Definition at line 37 of file ExternalSortInfo.h.
ExternalSortInfo::ExternalSortInfo | ( | ExecStream & | ) | [explicit] |
Definition at line 38 of file ExternalSortExecStreamImpl.cpp.
References cbPage, nSortMemPages, and nSortMemPagesPerRun.
00039 : stream(streamInit) 00040 { 00041 nSortMemPages = 0; 00042 nSortMemPagesPerRun = 0; 00043 cbPage = 0; 00044 }
Compares two keys, taking ASC/DESC into account.
key1 | first key to compare | |
key2 | second key to compare |
Definition at line 46 of file ExternalSortExecStreamImpl.cpp.
References TupleDescriptor::compareTuples(), descendingKeyColumns, and keyDesc.
Referenced by ExternalSortMerger::heapify(), ExternalSortRunLoader::quickSortFindPivot(), and ExternalSortRunLoader::quickSortPartition().
00047 { 00048 int c = keyDesc.compareTuples(key1, key2); 00049 if (!c) { 00050 return 0; 00051 } 00052 // abs(c) is 1-based column ordinal 00053 int i = (c > 0) ? c : -c; 00054 // shift to 0-based 00055 --i; 00056 if (descendingKeyColumns[i]) { 00057 // flip comparison result for DESC 00058 return -c; 00059 } else { 00060 return c; 00061 } 00062 }
Main stream, for abort checking.
Note that we intentionally don't give subcomponents access to ExternalSortExecStreamImpl details.
Definition at line 44 of file ExternalSortInfo.h.
Referenced by ExternalSortRunAccessor::fetch(), and ExternalSortMerger::fetch().
Accessor for segment used to store runs externally.
Definition at line 49 of file ExternalSortInfo.h.
Referenced by ExternalSortExecStreamImpl::prepare(), and ExternalSortRunAccessor::storeRun().
Accessor for scratch segment used for building runs in-memory.
Definition at line 54 of file ExternalSortInfo.h.
Referenced by ExternalSortRunLoader::ExternalSortRunLoader(), ExternalSortExecStreamImpl::getResourceRequirements(), ExternalSortExecStreamImpl::prepare(), and ExternalSortRunLoader::releaseResources().
Descriptor for tuples to be sorted.
Definition at line 59 of file ExternalSortInfo.h.
Referenced by ExternalSortMerger::ExternalSortMerger(), ExternalSortOutput::ExternalSortOutput(), ExternalSortRunAccessor::ExternalSortRunAccessor(), ExternalSortRunLoader::ExternalSortRunLoader(), ExternalSortRunAccessor::initRead(), and ExternalSortExecStreamImpl::prepare().
Projection of sort keys from tupleDesc.
Definition at line 64 of file ExternalSortInfo.h.
Referenced by ExternalSortMerger::ExternalSortMerger(), ExternalSortRunLoader::ExternalSortRunLoader(), and ExternalSortExecStreamImpl::prepare().
std::vector<bool> ExternalSortInfo::descendingKeyColumns |
Definition at line 69 of file ExternalSortInfo.h.
Referenced by compareKeys(), and ExternalSortExecStreamImpl::prepare().
Descriptor for projected sort key tuples.
Definition at line 74 of file ExternalSortInfo.h.
Referenced by compareKeys(), ExternalSortMerger::ExternalSortMerger(), ExternalSortRunLoader::ExternalSortRunLoader(), and ExternalSortExecStreamImpl::prepare().
Maximum number of memory pages available for sorting.
Definition at line 79 of file ExternalSortInfo.h.
Referenced by ExternalSortInfo(), ExternalSortMerger::ExternalSortMerger(), ExternalSortExecStreamImpl::mergeFirstResult(), ExternalSortExecStreamImpl::open(), ExternalSortExecStreamImpl::prepare(), and ExternalSortExecStreamImpl::setResourceAllocation().
Maximum number of memory pages which can be filled per run.
Definition at line 84 of file ExternalSortInfo.h.
Referenced by ExternalSortInfo(), ExternalSortExecStreamImpl::open(), and ExternalSortRunLoader::startRun().
Number of bytes per memory page.
Must be a power of 2.
Definition at line 89 of file ExternalSortInfo.h.
Referenced by ExternalSortRunLoader::allocateDataBuffer(), ExternalSortRunLoader::allocateIndexBuffer(), ExternalSortInfo(), ExternalSortRunLoader::ExternalSortRunLoader(), and ExternalSortExecStreamImpl::prepare().