java.lang.Object
org.apache.arrow.algorithm.search.VectorSearcher
Search for a particular element in the vector.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Result returned when a search fails. -
Method Summary
Modifier and TypeMethodDescriptionstatic <V extends ValueVector>
intbinarySearch
(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for a particular element from the key vector in the target vector by binary search.static <V extends ValueVector>
intlinearSearch
(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for a particular element from the key vector in the target vector by traversing the vector in sequence.
-
Field Details
-
SEARCH_FAIL_RESULT
public static final int SEARCH_FAIL_RESULTResult returned when a search fails.- See Also:
-
-
Method Details
-
binarySearch
public static <V extends ValueVector> int binarySearch(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for a particular element from the key vector in the target vector by binary search. The target vector must be sorted.- Type Parameters:
V
- the vector type.- Parameters:
targetVector
- the vector from which to perform the sort.comparator
- the criterion for the sort.keyVector
- the vector containing the element to search.keyIndex
- the index of the search key in the key vector.- Returns:
- the index of a matched element if any, and -1 otherwise.
-
linearSearch
public static <V extends ValueVector> int linearSearch(V targetVector, VectorValueComparator<V> comparator, V keyVector, int keyIndex) Search for a particular element from the key vector in the target vector by traversing the vector in sequence.- Type Parameters:
V
- the vector type.- Parameters:
targetVector
- the vector from which to perform the search.comparator
- the criterion for element equality.keyVector
- the vector containing the element to search.keyIndex
- the index of the search key in the key vector.- Returns:
- the index of a matched element if any, and -1 otherwise.
-