Class UniqueWithDuplicateNullsMergeSort
- java.lang.Object
-
- org.apache.derby.impl.store.access.sort.MergeSort
-
- org.apache.derby.impl.store.access.sort.UniqueWithDuplicateNullsMergeSort
-
- All Implemented Interfaces:
Sort
final class UniqueWithDuplicateNullsMergeSort extends MergeSort
This class extends and customizes MergeSort to support unique indexes with duplicate nulls. It overrides compare method to consider keypart - 1 parts of the keys while comparing (only for non null keys).
-
-
Field Summary
-
Fields inherited from class org.apache.derby.impl.store.access.sort.MergeSort
alreadyInOrder, columnOrdering, columnOrderingAscendingMap, columnOrderingMap, columnOrderingNullsLowMap, properties, sortBufferMax, sortBufferMin, sortObserver, template
-
-
Constructor Summary
Constructors Constructor Description UniqueWithDuplicateNullsMergeSort()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
compare(DataValueDescriptor[] r1, DataValueDescriptor[] r2)
Compares two keys.-
Methods inherited from class org.apache.derby.impl.store.access.sort.MergeSort
checkColumnTypes, createMergeRun, doneInserting, doneScanning, doneScanning, drop, dropMergeRuns, initialize, open, openSortRowSource, openSortScan
-
-
-
-
Method Detail
-
compare
protected int compare(DataValueDescriptor[] r1, DataValueDescriptor[] r2) throws StandardException
Compares two keys. If all the parts of the keys are not null then the leading (keys.length - 1) parts are compared, else if a part of the key is null then all parts of the key are compared (keys.length). This behavior is useful for implementing unique constraints where multiple null values are allowed, but uniqueness must still be guaranteed for keys with no null values. In this case the leading parts of the key are the user key columns, while the last column is a system provided column which is guaranteed unique per base row.- Overrides:
compare
in classMergeSort
- Parameters:
r1
- keysr2
- keys- Returns:
- 0 for duplicates non zero for distinct keys
- Throws:
StandardException
-
-