Class BasicSortObserver
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.BasicSortObserver
-
- All Implemented Interfaces:
SortObserver
- Direct Known Subclasses:
AggregateSortObserver
,UniqueIndexSortObserver
,UniqueWithDuplicateNullsIndexSortObserver
public class BasicSortObserver extends java.lang.Object implements SortObserver
This is the most basic sort observer. It handles distinct sorts and non-distinct sorts.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
distinct
protected boolean
doClone
private ExecRow
execRow
private boolean
reuseWrappers
private java.util.Vector<DataValueDescriptor[]>
vector
-
Constructor Summary
Constructors Constructor Description BasicSortObserver(boolean doClone, boolean distinct, ExecRow execRow, boolean reuseWrappers)
Simple constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToFreeList(DataValueDescriptor[] objectArray, int maxFreeListSize)
boolean
deferrable()
Overridden by subclasses that observe sorters with uniqueness checking.boolean
deferred()
Overridden by subclasses that observe sorters with uniqueness checking.DataValueDescriptor[]
getArrayClone()
private DataValueDescriptor[]
getClone(DataValueDescriptor[] origArray)
DataValueDescriptor[]
insertDuplicateKey(DataValueDescriptor[] insertRow, DataValueDescriptor[] existingRow)
Called prior to inserting a duplicate sort key.DataValueDescriptor[]
insertNonDuplicateKey(DataValueDescriptor[] insertRow)
Called prior to inserting a distinct sort key.void
rememberDuplicate(DataValueDescriptor[] row)
Overridden by subclasses that observe sorters with uniqueness checking.
-
-
-
Field Detail
-
doClone
protected boolean doClone
-
distinct
protected boolean distinct
-
reuseWrappers
private boolean reuseWrappers
-
execRow
private ExecRow execRow
-
vector
private java.util.Vector<DataValueDescriptor[]> vector
-
-
Constructor Detail
-
BasicSortObserver
public BasicSortObserver(boolean doClone, boolean distinct, ExecRow execRow, boolean reuseWrappers)
Simple constructor- Parameters:
doClone
- If true, then rows that are retained by the sorter will be cloned. This is needed if language is reusing row wrappers.distinct
- If true, toss out duplicates. Otherwise, retain them.execRow
- ExecRow to use as source of clone for store.reuseWrappers
- Whether or not we can reuse the wrappers
-
-
Method Detail
-
insertNonDuplicateKey
public DataValueDescriptor[] insertNonDuplicateKey(DataValueDescriptor[] insertRow) throws StandardException
Called prior to inserting a distinct sort key.- Specified by:
insertNonDuplicateKey
in interfaceSortObserver
- Parameters:
insertRow
- the current row that the sorter is on the verge of retaining- Returns:
- the row to be inserted by the sorter. If null, then nothing is inserted by the sorter. Distinct sorts will want to return null.
- Throws:
StandardException
- never thrown
-
insertDuplicateKey
public DataValueDescriptor[] insertDuplicateKey(DataValueDescriptor[] insertRow, DataValueDescriptor[] existingRow) throws StandardException
Called prior to inserting a duplicate sort key.- Specified by:
insertDuplicateKey
in interfaceSortObserver
- Parameters:
insertRow
- the current row that the sorter is on the verge of retaining. It is a duplicate of existingRow.existingRow
- the row that is already in the the sorter which is a duplicate of insertRow- Returns:
- the row to be inserted by the sorter. If null, then nothing is inserted by the sorter. Distinct sorts will want to return null.
- Throws:
StandardException
- never thrown
-
addToFreeList
public void addToFreeList(DataValueDescriptor[] objectArray, int maxFreeListSize)
- Specified by:
addToFreeList
in interfaceSortObserver
-
getArrayClone
public DataValueDescriptor[] getArrayClone() throws StandardException
- Specified by:
getArrayClone
in interfaceSortObserver
- Throws:
StandardException
-
getClone
private DataValueDescriptor[] getClone(DataValueDescriptor[] origArray)
-
deferred
public boolean deferred()
Description copied from interface:SortObserver
Overridden by subclasses that observe sorters with uniqueness checking.- Specified by:
deferred
in interfaceSortObserver
- Returns:
- true if constraint mode of the index's constraint is effectively deferred. Any SortObserver implementations that implement uniqueness checking need to keep track of this information.
-
deferrable
public boolean deferrable()
Description copied from interface:SortObserver
Overridden by subclasses that observe sorters with uniqueness checking.- Specified by:
deferrable
in interfaceSortObserver
- Returns:
- true if the index's constraint is deferrable. Any SortObserver implementations that implement uniqueness checking need to keep track of this information.
-
rememberDuplicate
public void rememberDuplicate(DataValueDescriptor[] row) throws StandardException
Description copied from interface:SortObserver
Overridden by subclasses that observe sorters with uniqueness checking. Will be called by sorters iff deferrable() and deferred() and uniqueness violation, so implementations that sometimes return true to these must implement this method to save duplicate information till commit time.- Specified by:
rememberDuplicate
in interfaceSortObserver
- Parameters:
row
- data of offending key- Throws:
StandardException
- standard error policy
-
-