FieldValueHitQueue<Entry> queue = FieldValueHitQueue.create(sort.fields, numHits);
docBase = context.docBase; final LeafFieldComparator[] comparators = queue.getComparators(context); final int[] reverseMul = queue.getReverseMul(); final Sort indexSort = context.reader().getMetaData().getSort(); final boolean canEarlyStopComparing = indexSort != null &&
@Override protected void populateResults(ScoreDoc[] results, int howMany) { if (fillFields) { // avoid casting if unnecessary. FieldValueHitQueue<Entry> queue = (FieldValueHitQueue<Entry>) pq; for (int i = howMany - 1; i >= 0; i--) { results[i] = queue.fillFields(queue.pop()); } } else { for (int i = howMany - 1; i >= 0; i--) { Entry entry = pq.pop(); results[i] = new FieldDoc(entry.doc, entry.score); } } }
/** Creates a ToParentBlockJoinCollector. The provided sort must * not be null. If you pass true trackScores, all * ToParentBlockQuery instances must not use * ScoreMode.None. */ public ToParentBlockJoinCollector(Sort sort, int numParentHits, boolean trackScores, boolean trackMaxScore) throws IOException { // TODO: allow null sort to be specialized to relevance // only collector this.sort = sort; this.trackMaxScore = trackMaxScore; if (trackMaxScore) { maxScore = Float.MIN_VALUE; } //System.out.println("numParentHits=" + numParentHits); this.trackScores = trackScores; this.numParentHits = numParentHits; queue = FieldValueHitQueue.create(sort.getSort(), numParentHits); comparators = queue.getComparators(); }
org.apache.lucene.search.SortField[] sortFields = search.usesSorting() ? search.sort(options) : null; if (sortFields == null) { hitQueue = FieldValueHitQueue.create(new org.apache.lucene.search.SortField[]{org.apache.lucene.search.SortField.FIELD_SCORE}, maxResults); isSorted = false; } else { hitQueue = FieldValueHitQueue.create(sortFields, maxResults); isSorted = true; reverseMul = hitQueue.getReverseMul(); numericDocValueNamesToFetch = new ArrayList<>(); binaryDocValueNamesToFetch = new ArrayList<>();
@Override protected TopDocs newTopDocs(ScoreDoc[] results, int start) { if (results == null) { results = EMPTY_SCOREDOCS; // Set maxScore to NaN, in case this is a maxScore tracking collector. maxScore = Float.NaN; } // If this is a maxScoring tracking collector and there were no results, return new TopFieldDocs(totalHits, results, ((FieldValueHitQueue<Entry>) pq).getFields(), maxScore); }
public List<IndexEntry> docs() { if (indexEntries == null) { indexEntries = new ArrayList<>(); IndexEntry entry; while ((entry = hitQueue.pop()) != null) { indexEntries.add(entry); } } return indexEntries; }
@Override protected void doSetNextReader(LeafReaderContext context) throws IOException { docBase = context.docBase; comparators = hitQueue.getComparators(context); pkNames = LuceneUtils.getPKNameDocValues(context.reader()); primaryKeys = LuceneUtils.getPKBytesDocValues(context.reader()); rowKeys = LuceneUtils.getRKBytesDocValues(context.reader()); for (String docValName : numericDocValueNamesToFetch) { numericDocValuesMap.put(docValName, context.reader().getNumericDocValues(docValName)); } for (String docValName : binaryDocValueNamesToFetch) { stringDocValues.put(docValName, context.reader().getSortedDocValues(docValName)); } }
final void add(int slot, int doc, float score) throws IOException { IndexEntry entry = getIndexEntry(slot, doc, score); bottom = hitQueue.add(entry); queueFull = (totalHits == numHits); }
@Override protected TopDocs newTopDocs(ScoreDoc[] results, int start) { if (results == null) { results = EMPTY_SCOREDOCS; // Set maxScore to NaN, in case this is a maxScore tracking collector. maxScore = Float.NaN; } // If this is a maxScoring tracking collector and there were no results, return new TopFieldDocs(totalHits, results, ((FieldValueHitQueue<Entry>) pq).getFields(), maxScore); }
public TreeMultimap<DecoratedKey, IndexEntry> docsByRowKey() { if (indexEntries != null) throw new IllegalStateException("Hit queue already traversed"); if (indexEntryTreeMultiMap == null) { indexEntryTreeMultiMap = TreeMultimap.create(Ordering.natural(), new Comparator<IndexEntry>() { @Override public int compare(IndexEntry o1, IndexEntry o2) { return tableMapper.clusteringCType.compare(o1.clusteringKey, o2.clusteringKey); } }); IndexEntry entry; while ((entry = hitQueue.pop()) != null) { indexEntryTreeMultiMap.put(entry.decoratedKey, entry); } } return indexEntryTreeMultiMap; }
canEarlyStopComparing; final int initialTotalHits = totalHits; return new MultiComparatorLeafCollector(queue.getComparators(context), queue.getReverseMul(), mayNeedScoresTwice) {
@Override protected void populateResults(ScoreDoc[] results, int howMany) { if (fillFields) { // avoid casting if unnecessary. FieldValueHitQueue<Entry> queue = (FieldValueHitQueue<Entry>) pq; for (int i = howMany - 1; i >= 0; i--) { results[i] = queue.fillFields(queue.pop()); } } else { for (int i = howMany - 1; i >= 0; i--) { Entry entry = pq.pop(); results[i] = new FieldDoc(entry.doc, entry.score); } } }
FieldValueHitQueue<Entry> queue = FieldValueHitQueue.create(sort.fields, numHits);
@Override protected TopDocs newTopDocs(ScoreDoc[] results, int start) { if (results == null) { results = EMPTY_SCOREDOCS; // Set maxScore to NaN, in case this is a maxScore tracking collector. maxScore = Float.NaN; } // If this is a maxScoring tracking collector and there were no results, return new TopFieldDocs(totalHits, results, ((FieldValueHitQueue<Entry>) pq).getFields(), maxScore); }
docBase = context.docBase; final int afterDoc = after.doc - docBase; return new MultiComparatorLeafCollector(queue.getComparators(context), queue.getReverseMul(), mayNeedScoresTwice) {
@Override protected void populateResults(ScoreDoc[] results, int howMany) { if (fillFields) { // avoid casting if unnecessary. FieldValueHitQueue<Entry> queue = (FieldValueHitQueue<Entry>) pq; for (int i = howMany - 1; i >= 0; i--) { results[i] = queue.fillFields(queue.pop()); } } else { for (int i = howMany - 1; i >= 0; i--) { Entry entry = pq.pop(); results[i] = new FieldDoc(entry.doc, entry.score); } } }