| java.lang.Object org.apache.derby.impl.store.access.sort.MergeSort
MergeSort | final public class MergeSort implements Sort(Code) | | A sort implementation which does the sort in-memory if it can,
but which can do an external merge sort so that it can sort an
arbitrary number of rows.
|
Method Summary | |
protected boolean | checkColumnOrdering(DataValueDescriptor[] template, ColumnOrdering columnOrdering) Check the column ordering against the template, making
sure that each column is present in the template,
implements Orderable, and is not mentioned more than
once. | void | checkColumnTypes(DataValueDescriptor[] row) Check that the columns in the row agree with the columns
in the template, both in number and in type. | int | compare(DataValueDescriptor[] r1, DataValueDescriptor[] r2) | long | createMergeRun(TransactionManager tran, SortBuffer sortBuffer) Remove all the rows from the sort buffer and store them
in a temporary conglomerate. | void | doneInserting(MergeInserter inserter, SortBuffer sortBuffer, Vector mergeRuns) An inserter is closing. | void | doneScanning(Scan scan, SortBuffer sortBuffer) | void | doneScanning(Scan scan, SortBuffer sortBuffer, Vector mergeRuns) | public void | drop(TransactionController tran) Drop the sort. | void | dropMergeRuns(TransactionManager tran) Get rid of the merge runs, if there are any. | public void | initialize(DataValueDescriptor[] template, ColumnOrdering columnOrdering, SortObserver sortObserver, boolean alreadyInOrder, long estimatedRows, int sortBufferMax) Go from the CLOSED to the INITIALIZED state. | public SortController | open(TransactionManager tran) Open a sort controller. | public ScanControllerRowSource | openSortRowSource(TransactionManager tran) Open a row source to get rows out of the sorter. | public ScanController | openSortScan(TransactionManager tran, boolean hold) Open a scan controller. |
STATE_CLOSED | final static int STATE_CLOSED(Code) | | |
STATE_DONE_INSERTING | final static int STATE_DONE_INSERTING(Code) | | |
STATE_DONE_SCANNING | final static int STATE_DONE_SCANNING(Code) | | |
STATE_INITIALIZED | final static int STATE_INITIALIZED(Code) | | |
STATE_INSERTING | final static int STATE_INSERTING(Code) | | |
STATE_SCANNING | final static int STATE_SCANNING(Code) | | |
alreadyInOrder | protected boolean alreadyInOrder(Code) | | Whether the rows are expected to be in order on insert,
as passed in on create.
|
columnOrdering | protected ColumnOrdering columnOrdering(Code) | | The column ordering as passed in on create. Valid when
the state is INITIALIZED through SCANNING, null otherwise.
May be null if there is no column ordering - this means
that all rows are considered to be duplicates, and the
sort will only emit a single row.
|
columnOrderingAscendingMap | protected boolean columnOrderingAscendingMap(Code) | | A lookup table to speed up lookup of Ascending state of a column,
|
columnOrderingMap | protected int columnOrderingMap(Code) | | A lookup table to speed up lookup of a column associated with the i'th
column to compare. To find the column id to compare as the i'th column
look in columnOrderingMap[i].
|
inserter | protected MergeInserter inserter(Code) | | The inserter that's being used to insert rows into the sort.
This field is only valid when the state is INSERTING.
|
mergeRuns | protected Vector mergeRuns(Code) | | A vector of merge runs, produced by the MergeInserter.
Might be null if no merge runs were produced.
It is a vector of container ids.
|
scan | protected Scan scan(Code) | | The scan that's being used to return rows from the sort.
This field is only valid when the state is SCANNING.
|
sortBuffer | protected SortBuffer sortBuffer(Code) | | An ordered set of the leftover rows that didn't go
in the last merge run (might be all the rows if there
are no merge runs).
|
sortBufferMax | protected int sortBufferMax(Code) | | The maximum number of entries a sort buffer can hold.
|
sortBufferMin | protected int sortBufferMin(Code) | | The minimum number of entries a sort buffer can hold.
|
sortObserver | protected SortObserver sortObserver(Code) | | The sort observer. May be null. Used as a callback.
|
state | protected int state(Code) | | Maintains the current state of the sort as defined in
the preceding values. Sorts start off and end up closed.
|
template | protected DataValueDescriptor[] template(Code) | | The template as passed in on create. Valid when the state
is INITIALIZED through SCANNING, null otherwise.
|
checkColumnOrdering | protected boolean checkColumnOrdering(DataValueDescriptor[] template, ColumnOrdering columnOrdering)(Code) | | Check the column ordering against the template, making
sure that each column is present in the template,
implements Orderable, and is not mentioned more than
once. Intended to be called as part of a sanity check.
|
checkColumnTypes | void checkColumnTypes(DataValueDescriptor[] row) throws StandardException(Code) | | Check that the columns in the row agree with the columns
in the template, both in number and in type.
XXX (nat) Currently checks that the classes implementing
each column are the same -- is this right?
|
createMergeRun | long createMergeRun(TransactionManager tran, SortBuffer sortBuffer) throws StandardException(Code) | | Remove all the rows from the sort buffer and store them
in a temporary conglomerate. The temporary conglomerate
is a "merge run". Returns the container id of the
merge run.
|
dropMergeRuns | void dropMergeRuns(TransactionManager tran)(Code) | | Get rid of the merge runs, if there are any.
Must not cause any errors because it's called
during error processing.
|
|
|