Top Description Fields Constructors Methods
org.apache.derby.impl.store.access.sort

pack-priv final Class UniqueWithDuplicateNullsMergeSort

extends MergeSort
Class Inheritance
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.types.DataValueDescriptor

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

Inherited from org.apache.derby.impl.store.access.sort.MergeSort:
alreadyInOrdercolumnOrderingcolumnOrderingAscendingMapcolumnOrderingMapcolumnOrderingNullsLowMappropertiessortBufferMaxsortBufferMinsortObservertemplate

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected int

Returns:

0 for duplicates non zero for distinct keys
compare
(DataValueDescriptor[]
keys
r1
,
DataValueDescriptor[]
keys
r2
)

Overrides org.apache.derby.impl.store.access.sort.MergeSort.compare.

Compares two keys.

Inherited from org.apache.derby.impl.store.access.sort.MergeSort:
checkColumnTypescreateMergeRundoneInsertingdoneScanningdoneScanningdropdropMergeRunsinitializeopenopenSortRowSourceopenSortScan

Constructor Detail

UniqueWithDuplicateNullsMergeSortback to summary
pack-priv UniqueWithDuplicateNullsMergeSort()

Method Detail

compareback to summary
protected int compare(DataValueDescriptor[] r1, DataValueDescriptor[] r2) throws StandardException

Overrides org.apache.derby.impl.store.access.sort.MergeSort.compare.

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.

Parameters
r1:DataValueDescriptor[]

keys

r2:DataValueDescriptor[]

keys

Returns:int

0 for duplicates non zero for distinct keys

Annotations
@Override