ExternalSortInfo Struct Reference

Global information shared with sorter sub-components. More...

#include <ExternalSortInfo.h>

List of all members.

Public Member Functions

 ExternalSortInfo (ExecStream &)
int compareKeys (TupleData const &key1, TupleData const &key2)
 Compares two keys, taking ASC/DESC into account.

Public Attributes

ExecStreamstream
 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
 
See also:
ExternalSortExecStreamParams

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.


Detailed Description

Global information shared with sorter sub-components.

Definition at line 37 of file ExternalSortInfo.h.


Constructor & Destructor Documentation

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 }


Member Function Documentation

int ExternalSortInfo::compareKeys ( TupleData const &  key1,
TupleData const &  key2 
)

Compares two keys, taking ASC/DESC into account.

Parameters:
key1 first key to compare
key2 second key to compare
Returns:
negative for key1 < key2; zero for key1 == key2; positive for key1 > key2

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 }


Member Data Documentation

ExecStream& ExternalSortInfo::stream

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

SegmentAccessor ExternalSortInfo::externalSegmentAccessor

Accessor for segment used to store runs externally.

Definition at line 49 of file ExternalSortInfo.h.

Referenced by ExternalSortExecStreamImpl::prepare(), and ExternalSortRunAccessor::storeRun().

SegmentAccessor ExternalSortInfo::memSegmentAccessor

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

TupleDescriptor ExternalSortInfo::tupleDesc

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

TupleProjection ExternalSortInfo::keyProj

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

See also:
ExternalSortExecStreamParams

Definition at line 69 of file ExternalSortInfo.h.

Referenced by compareKeys(), and ExternalSortExecStreamImpl::prepare().

TupleDescriptor ExternalSortInfo::keyDesc

Descriptor for projected sort key tuples.

Definition at line 74 of file ExternalSortInfo.h.

Referenced by compareKeys(), ExternalSortMerger::ExternalSortMerger(), ExternalSortRunLoader::ExternalSortRunLoader(), and ExternalSortExecStreamImpl::prepare().

uint ExternalSortInfo::nSortMemPages

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

uint ExternalSortInfo::nSortMemPagesPerRun

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

uint ExternalSortInfo::cbPage

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


The documentation for this struct was generated from the following files:
Generated on Mon Jun 22 04:00:32 2009 for Fennel by  doxygen 1.5.1