Module org.apache.arrow.algorithm
Package org.apache.arrow.algorithm.sort
Class StableVectorComparator<V extends ValueVector>
java.lang.Object
org.apache.arrow.algorithm.sort.VectorValueComparator<V>
org.apache.arrow.algorithm.sort.StableVectorComparator<V>
- Type Parameters:
V- type of the vector.
Stable sorter. It compares values like ordinary comparators. However, when values are equal, it
breaks ties by the value indices. Therefore, sort algorithms using this comparator always produce
stable sort results.
-
Field Summary
Fields inherited from class org.apache.arrow.algorithm.sort.VectorValueComparator
valueWidth, vector1, vector2 -
Constructor Summary
ConstructorsConstructorDescriptionStableVectorComparator(VectorValueComparator<V> innerComparator) Constructs a stable comparator from a given comparator. -
Method Summary
Modifier and TypeMethodDescriptionvoidattachVector(V vector) Attach both vectors to compare to the same input vector.voidattachVectors(V vector1, V vector2) Attach vectors to compare.intcompareNotNull(int index1, int index2) Compare two values, given their indices.Creates a comparator of the same type.Methods inherited from class org.apache.arrow.algorithm.sort.VectorValueComparator
checkNullsOnCompare, compare, getValueWidth
-
Constructor Details
-
StableVectorComparator
Constructs a stable comparator from a given comparator.- Parameters:
innerComparator- the comparator to convert to stable comparator..
-
-
Method Details
-
attachVector
Description copied from class:VectorValueComparatorAttach both vectors to compare to the same input vector.- Overrides:
attachVectorin classVectorValueComparator<V extends ValueVector>- Parameters:
vector- the vector to attach.
-
attachVectors
Description copied from class:VectorValueComparatorAttach vectors to compare.- Overrides:
attachVectorsin classVectorValueComparator<V extends ValueVector>- Parameters:
vector1- the first vector to compare.vector2- the second vector to compare.
-
compareNotNull
public int compareNotNull(int index1, int index2) Description copied from class:VectorValueComparatorCompare two values, given their indices. This is a fast path for comparing non-null values, so the caller must make sure that values at both indices are not null.- Specified by:
compareNotNullin classVectorValueComparator<V extends ValueVector>- Parameters:
index1- index of the first value to compare.index2- index of the second value to compare.- Returns:
- an integer greater than 0, if the first value is greater; an integer smaller than 0, if the first value is smaller; or 0, if both values are equal.
-
createNew
Description copied from class:VectorValueComparatorCreates a comparator of the same type.- Specified by:
createNewin classVectorValueComparator<V extends ValueVector>- Returns:
- the newly created comparator.
-