Module org.apache.arrow.algorithm
Class VectorRangeSearcher
java.lang.Object
org.apache.arrow.algorithm.search.VectorRangeSearcher
Search for the range of a particular element in the target vector.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Result returned when a search fails. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V extends ValueVector>
intgetFirstMatch
(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for the first occurrence of an element.static <V extends ValueVector>
intgetLastMatch
(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for the last occurrence of an element.
-
Field Details
-
SEARCH_FAIL_RESULT
public static final int SEARCH_FAIL_RESULTResult returned when a search fails.- See Also:
-
-
Constructor Details
-
VectorRangeSearcher
public VectorRangeSearcher()
-
-
Method Details
-
getFirstMatch
public static <V extends ValueVector> int getFirstMatch(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for the first occurrence of an element. The search is based on the binary search algorithm. So the target vector must be sorted.- Type Parameters:
V
- the vector type.- Parameters:
targetVector
- the vector from which to perform the search.comparator
- the criterion for the comparison.keyVector
- the vector containing the element to search.keyIndex
- the index of the search key in the key vector.- Returns:
- the index of the first matched element if any, and -1 otherwise.
-
getLastMatch
public static <V extends ValueVector> int getLastMatch(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for the last occurrence of an element. The search is based on the binary search algorithm. So the target vector must be sorted.- Type Parameters:
V
- the vector type.- Parameters:
targetVector
- the vector from which to perform the search.comparator
- the criterion for the comparison.keyVector
- the vector containing the element to search.keyIndex
- the index of the search key in the key vector.- Returns:
- the index of the last matched element if any, and -1 otherwise.
-