Class MultiLeafKnnCollector

java.lang.Object
org.apache.lucene.search.KnnCollector.Decorator
org.apache.lucene.search.knn.MultiLeafKnnCollector
All Implemented Interfaces:
KnnCollector

public final class MultiLeafKnnCollector extends KnnCollector.Decorator
MultiLeafKnnCollector is a specific KnnCollector that can exchange the top collected results across segments through a shared global queue.
WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Constructor Details

    • MultiLeafKnnCollector

      public MultiLeafKnnCollector(int k, BlockingFloatHeap globalSimilarityQueue, AbstractKnnCollector subCollector)
      Create a new MultiLeafKnnCollector.
      Parameters:
      k - the number of neighbors to collect
      globalSimilarityQueue - the global queue of the highest similarities collected so far across all segments
      subCollector - the local collector
    • MultiLeafKnnCollector

      public MultiLeafKnnCollector(int k, float greediness, int interval, BlockingFloatHeap globalSimilarityQueue, AbstractKnnCollector subCollector)
      Create a new MultiLeafKnnCollector.
      Parameters:
      k - the number of neighbors to collect
      greediness - the greediness of the global search
      interval - (by number of collected values) the interval to synchronize the local and global queues
      globalSimilarityQueue - the global queue of the highest similarities collected so far
      subCollector - the local collector
  • Method Details

    • collect

      public boolean collect(int docId, float similarity)
      Description copied from interface: KnnCollector
      Collect the provided docId and include in the result set.
      Specified by:
      collect in interface KnnCollector
      Overrides:
      collect in class KnnCollector.Decorator
      Parameters:
      docId - of the vector to collect
      similarity - its calculated similarity
      Returns:
      true if the vector is collected
    • minCompetitiveSimilarity

      public float minCompetitiveSimilarity()
      Description copied from interface: KnnCollector
      This method is utilized during search to ensure only competitive results are explored.

      Consequently, if this results collector wants to collect `k` results, this should return Float.NEGATIVE_INFINITY when not full.

      When full, the minimum score should be returned.

      Specified by:
      minCompetitiveSimilarity in interface KnnCollector
      Overrides:
      minCompetitiveSimilarity in class KnnCollector.Decorator
      Returns:
      the current minimum competitive similarity in the collection
    • toString

      public String toString()
      Overrides:
      toString in class Object