|
|||||||||
| 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
class 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 boolean[] |
columnOrderingNullsLowMap
A lookup table to speed up lookup of nulls-low ordering of a column, |
private MergeInserter |
inserter
The inserter that's being used to insert rows into the sort. |
private java.util.Vector |
mergeRuns
A vector of merge runs, produced by the MergeInserter. |
(package private) static java.util.Properties |
properties
Properties for mergeSort |
private Scan |
scan
The scan that's being used to return rows from the sort. |
private 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). |
(package private) int |
sortBufferMax
The maximum number of entries a sort buffer can hold. |
(package private) int |
sortBufferMin
The minimum number of entries a sort buffer can hold. |
(package private) SortObserver |
sortObserver
The sort observer. |
private int |
state
Maintains the current state of the sort as defined in the preceding values. |
private static int |
STATE_CLOSED
|
private static int |
STATE_DONE_INSERTING
|
private static int |
STATE_DONE_SCANNING
|
private static int |
STATE_INITIALIZED
|
private static int |
STATE_INSERTING
|
private static int |
STATE_SCANNING
|
protected DataValueDescriptor[] |
template
The template as passed in on create. |
| Constructor Summary | |
|---|---|
MergeSort()
|
|
| Method Summary | |
|---|---|
private boolean |
checkColumnOrdering(DataValueDescriptor[] template,
ColumnOrdering[] columnOrdering)
Check the column ordering against the template, making sure that each column is present in the template, is not mentioned more than once, and that the columns isn't null. |
(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. |
protected 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 |
|---|
private static final int STATE_CLOSED
private static final int STATE_INITIALIZED
private static final int STATE_INSERTING
private static final int STATE_DONE_INSERTING
private static final int STATE_SCANNING
private static final int STATE_DONE_SCANNING
private int state
protected DataValueDescriptor[] template
protected ColumnOrdering[] columnOrdering
protected int[] columnOrderingMap
protected boolean[] columnOrderingAscendingMap
protected boolean[] columnOrderingNullsLowMap
SortObserver sortObserver
protected boolean alreadyInOrder
private MergeInserter inserter
private Scan scan
private java.util.Vector mergeRuns
private SortBuffer sortBuffer
int sortBufferMax
int sortBufferMin
static java.util.Properties properties
| Constructor Detail |
|---|
MergeSort()
| Method Detail |
|---|
public SortController open(TransactionManager tran)
throws StandardException
This implementation only supports a single sort controller per sort.
open in interface SortStandardException - 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 SortStandardException - Standard exception policy.Sort.openSortScan(org.apache.derby.iapi.store.access.conglomerate.TransactionManager, boolean)
public ScanControllerRowSource openSortRowSource(TransactionManager tran)
throws StandardException
openSortRowSource in interface SortStandardException - Standard exception policy.Sort.openSortRowSource(org.apache.derby.iapi.store.access.conglomerate.TransactionManager)
public void drop(TransactionController tran)
throws StandardException
drop in interface SortStandardExceptionSort.drop(org.apache.derby.iapi.store.access.TransactionController)
private boolean checkColumnOrdering(DataValueDescriptor[] template,
ColumnOrdering[] columnOrdering)
null.
Intended to be called as part of a sanity check. All columns are
orderable, since DataValueDescriptor extends Orderable.
true if the ordering is valid, false if not.
void checkColumnTypes(DataValueDescriptor[] row)
throws StandardException
XXX (nat) Currently checks that the classes implementing each column are the same -- is this right?
StandardException
protected 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
|
Built on Wed 2013-06-12 15:21:56+0000, from revision ??? | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||