org.apache.derby.impl.store.access.sort
Class UniqueWithDuplicateNullsMergeSort

java.lang.Object
  extended by org.apache.derby.impl.store.access.sort.MergeSort
      extended by 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
UniqueWithDuplicateNullsMergeSort()
           
 
Method Summary
protected  int compare(DataValueDescriptor[] r1, DataValueDescriptor[] r2)
          Compares two keys.
 
Methods inherited from class org.apache.derby.impl.store.access.sort.MergeSort
checkColumnOrdering, checkColumnTypes, createMergeRun, doneInserting, doneScanning, doneScanning, drop, dropMergeRuns, initialize, open, openSortRowSource, openSortScan
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniqueWithDuplicateNullsMergeSort

UniqueWithDuplicateNullsMergeSort()
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 no 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 class MergeSort
Parameters:
r1 - keys
r2 - keys
Returns:
0 for duplicates non zero for distinct keys
Throws:
StandardException

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.