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).
  • Constructor Details

    • UniqueWithDuplicateNullsMergeSort

      UniqueWithDuplicateNullsMergeSort()
  • Method Details

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