|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.impl.store.access.sort.MergeSort
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.
Field Summary | |
protected boolean |
alreadyInOrder
Whether the rows are expected to be in order on insert, as passed in on create. |
protected ColumnOrdering[] |
columnOrdering
The column ordering as passed in on create. |
protected boolean[] |
columnOrderingAscendingMap
A lookup table to speed up lookup of Ascending state of a column, |
protected int[] |
columnOrderingMap
A lookup table to speed up lookup of a column associated with the i'th column to compare. |
protected MergeInserter |
inserter
The inserter that's being used to insert rows into the sort. |
protected java.util.Vector |
mergeRuns
A vector of merge runs, produced by the MergeInserter. |
(package private) static java.util.Properties |
properties
Properties for mergeSort |
protected Scan |
scan
The scan that's being used to return rows from the sort. |
protected SortBuffer |
sortBuffer
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). |
protected int |
sortBufferMax
The maximum number of entries a sort buffer can hold. |
protected int |
sortBufferMin
The minimum number of entries a sort buffer can hold. |
protected SortObserver |
sortObserver
The sort observer. |
protected int |
state
Maintains the current state of the sort as defined in the preceding values. |
(package private) static int |
STATE_CLOSED
|
(package private) static int |
STATE_DONE_INSERTING
|
(package private) static int |
STATE_DONE_SCANNING
|
(package private) static int |
STATE_INITIALIZED
|
(package private) static int |
STATE_INSERTING
|
(package private) static int |
STATE_SCANNING
|
protected DataValueDescriptor[] |
template
The template as passed in on create. |
Constructor Summary | |
MergeSort()
|
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. |
(package private) void |
checkColumnTypes(DataValueDescriptor[] row)
Check that the columns in the row agree with the columns in the template, both in number and in type. |
(package private) int |
compare(DataValueDescriptor[] r1,
DataValueDescriptor[] r2)
|
(package private) long |
createMergeRun(TransactionManager tran,
SortBuffer sortBuffer)
Remove all the rows from the sort buffer and store them in a temporary conglomerate. |
(package private) void |
doneInserting(MergeInserter inserter,
SortBuffer sortBuffer,
java.util.Vector mergeRuns)
An inserter is closing. |
(package private) void |
doneScanning(Scan scan,
SortBuffer sortBuffer)
|
(package private) void |
doneScanning(Scan scan,
SortBuffer sortBuffer,
java.util.Vector mergeRuns)
|
void |
drop(TransactionController tran)
Drop the sort. |
(package private) void |
dropMergeRuns(TransactionManager tran)
Get rid of the merge runs, if there are any. |
void |
initialize(DataValueDescriptor[] template,
ColumnOrdering[] columnOrdering,
SortObserver sortObserver,
boolean alreadyInOrder,
long estimatedRows,
int sortBufferMax)
Go from the CLOSED to the INITIALIZED state. |
private void |
multiStageMerge(TransactionManager tran)
|
SortController |
open(TransactionManager tran)
Open a sort controller. |
ScanControllerRowSource |
openSortRowSource(TransactionManager tran)
Open a row source to get rows out of the sorter. |
ScanController |
openSortScan(TransactionManager tran,
boolean hold)
Open a scan controller. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final int STATE_CLOSED
static final int STATE_INITIALIZED
static final int STATE_INSERTING
static final int STATE_DONE_INSERTING
static final int STATE_SCANNING
static final int STATE_DONE_SCANNING
protected int state
protected DataValueDescriptor[] template
protected ColumnOrdering[] columnOrdering
protected int[] columnOrderingMap
protected boolean[] columnOrderingAscendingMap
protected SortObserver sortObserver
protected boolean alreadyInOrder
protected MergeInserter inserter
protected Scan scan
protected java.util.Vector mergeRuns
protected SortBuffer sortBuffer
protected int sortBufferMax
protected int sortBufferMin
static java.util.Properties properties
Constructor Detail |
public MergeSort()
Method Detail |
public SortController open(TransactionManager tran) throws StandardException
This implementation only supports a single sort controller per sort.
open
in interface Sort
StandardException
- Standard exception policy.Sort.open(org.apache.derby.iapi.store.access.conglomerate.TransactionManager)
public ScanController openSortScan(TransactionManager tran, boolean hold) throws StandardException
openSortScan
in interface Sort
StandardException
- Standard exception policy.Sort.openSortScan(org.apache.derby.iapi.store.access.conglomerate.TransactionManager, boolean)
public ScanControllerRowSource openSortRowSource(TransactionManager tran) throws StandardException
openSortRowSource
in interface Sort
StandardException
- Standard exception policy.Sort.openSortRowSource(org.apache.derby.iapi.store.access.conglomerate.TransactionManager)
public void drop(TransactionController tran) throws StandardException
drop
in interface Sort
StandardException
Sort.drop(org.apache.derby.iapi.store.access.TransactionController)
protected boolean checkColumnOrdering(DataValueDescriptor[] template, ColumnOrdering[] columnOrdering)
void checkColumnTypes(DataValueDescriptor[] row) throws StandardException
XXX (nat) Currently checks that the classes implementing each column are the same -- is this right?
StandardException
int compare(DataValueDescriptor[] r1, DataValueDescriptor[] r2) throws StandardException
StandardException
public void initialize(DataValueDescriptor[] template, ColumnOrdering[] columnOrdering, SortObserver sortObserver, boolean alreadyInOrder, long estimatedRows, int sortBufferMax) throws StandardException
StandardException
void doneInserting(MergeInserter inserter, SortBuffer sortBuffer, java.util.Vector mergeRuns)
void doneScanning(Scan scan, SortBuffer sortBuffer)
void doneScanning(Scan scan, SortBuffer sortBuffer, java.util.Vector mergeRuns)
void dropMergeRuns(TransactionManager tran)
private void multiStageMerge(TransactionManager tran) throws StandardException
StandardException
long createMergeRun(TransactionManager tran, SortBuffer sortBuffer) throws StandardException
StandardException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |