Class ParallelSearcher<V extends ValueVector>

java.lang.Object
org.apache.arrow.algorithm.search.ParallelSearcher<V>
Type Parameters:
V - the vector type.

public class ParallelSearcher<V extends ValueVector> extends Object
Search for a value in the vector by multiple threads. This is often used in scenarios where the vector is large or low response time is required.
  • Constructor Details

    • ParallelSearcher

      public ParallelSearcher(V vector, ExecutorService threadPool, int numThreads)
      Constructs a parallel searcher.
      Parameters:
      vector - the vector to search.
      threadPool - the thread pool to use.
      numThreads - the number of threads to use.
  • Method Details

    • search

      public int search(V keyVector, int keyIndex) throws ExecutionException, InterruptedException
      Search for the key in the target vector. The element-wise comparison is based on RangeEqualsVisitor, so there are two possible results for each element-wise comparison: equal and un-equal.
      Parameters:
      keyVector - the vector containing the search key.
      keyIndex - the index of the search key in the key vector.
      Returns:
      the position of a matched value in the target vector, or -1 if none is found. Please note that if there are multiple matches of the key in the target vector, this method makes no guarantees about which instance is returned. For an alternative search implementation that always finds the first match of the key, see VectorSearcher.linearSearch(ValueVector, VectorValueComparator, ValueVector, int).
      Throws:
      ExecutionException - if an exception occurs in a thread.
      InterruptedException - if a thread is interrupted.
    • search

      public int search(V keyVector, int keyIndex, VectorValueComparator<V> comparator) throws ExecutionException, InterruptedException
      Search for the key in the target vector. The element-wise comparison is based on VectorValueComparator, so there are three possible results for each element-wise comparison: less than, equal to and greater than.
      Parameters:
      keyVector - the vector containing the search key.
      keyIndex - the index of the search key in the key vector.
      comparator - the comparator for comparing the key against vector elements.
      Returns:
      the position of a matched value in the target vector, or -1 if none is found. Please note that if there are multiple matches of the key in the target vector, this method makes no guarantees about which instance is returned. For an alternative search implementation that always finds the first match of the key, see VectorSearcher.linearSearch(ValueVector, VectorValueComparator, ValueVector, int).
      Throws:
      ExecutionException - if an exception occurs in a thread.
      InterruptedException - if a thread is interrupted.