CompareBottom() public abstract method

Compare the bottom of the queue with doc. This will only invoked after setBottom has been called. This should return the same result as Compare(int,int) } as if bottom were slot1 and the new document were slot 2.

For a search that hits many results, this method will be the hotspot (invoked by far the most frequently).

public abstract CompareBottom ( int doc ) : int
doc int that was hit ///
return int
Beispiel #1
0
            public override void  Collect(int doc)
            {
                ++totalHits;
                if (queueFull)
                {
                    if ((reverseMul * comparator.CompareBottom(doc)) <= 0)
                    {
                        // since docs are visited in doc Id order, if compare is 0, it means
                        // this document is largest than anything else in the queue, and
                        // therefore not competitive.
                        return;
                    }

                    // This hit is competitive - replace bottom element in queue & adjustTop
                    comparator.Copy(bottom.slot, doc);
                    UpdateBottom(doc);
                    comparator.SetBottom(bottom.slot);
                }
                else
                {
                    // Startup transient: queue hasn't gathered numHits yet
                    int slot = totalHits - 1;
                    // Copy hit into queue
                    comparator.Copy(slot, doc);
                    Add(slot, doc, System.Single.NaN);
                    if (queueFull)
                    {
                        comparator.SetBottom(bottom.slot);
                    }
                }
            }