@Override public int doc() { return spans.doc(); }
@Override public int doc() { return includeSpans.doc(); }
@Override public int doc() { return spans.doc(); }
@Override public int doc() { return requiredSpans.doc(); }
@Override public int doc() { return parentSpans.doc(); }
@Override public boolean nextCandidateDocument() throws IOException { if (!this.includeSpans.nextCandidateDocument()) { return false; } // advance the excluded span to or after the included candidate document if (includeSpans.doc() > excludeSpans.doc()) { moreExclude = excludeSpans.skipToCandidate(includeSpans.doc()); } return true; }
/** * Advance the spans to the same candidate document */ private boolean toSameCandidateDocument() throws IOException { docSorter.sort(0, subSpansSort.length); int firstIndex = 0; int maxDoc = subSpansSort[subSpansSort.length - 1].doc(); while (subSpansSort[firstIndex].doc() != maxDoc) { if (!subSpansSort[firstIndex].skipToCandidate(maxDoc)) { matchDoc = DocsAndNodesIterator.NO_MORE_DOC; return false; } maxDoc = subSpansSort[firstIndex].doc(); if (++firstIndex == subSpansSort.length) { firstIndex = 0; } } // assert doc - loop will be removed by jit if assert is disabled for (int i = 0; i < subSpansSort.length; i++) { assert (subSpansSort[i].doc() == maxDoc) : " NearSpansOrdered.toSameCandidateDocument() spans " + subSpansSort[0] + "\n at doc " + subSpansSort[i].doc() + ", but should be at " + maxDoc; } matchDoc = subSpans[0].doc(); return true; }
/** * Check if the specified term spans is the max. If true, update the {@link #max} reference. * <p> * This method must be called whenever a spans is modified. */ private void updateMax(final Spans spans) { if (max == null || spans.doc() > max.doc()) { max = spans; return; } // cache node comparison int nodeComparison = NodeUtils.compare(spans.node(), max.node()); if ((spans.doc() == max.doc()) && (nodeComparison > 0)) { max = spans; return; } if ((spans.doc() == max.doc()) && (nodeComparison == 0) && (spans.end() > max.end())) { max = spans; return; } }
@Override public int doc() { if (top() == null) { return -1; } return top().doc(); }
@Override protected final boolean lessThan(Spans spans1, Spans spans2) { if (spans1.doc() == spans2.doc()) { int comparison = NodeUtils.compare(spans1.node(), spans2.node()); if (comparison == 0) { if (spans1.start() == spans2.start()) { return spans1.end() < spans2.end(); } else { return spans1.start() < spans2.start(); } } else { return comparison < 0; } } else { return spans1.doc() < spans2.doc(); } }
@Override public boolean nextNode() throws IOException { if (!includeSpans.nextNode()) { // Move to the next matching node return false; // exhausted, nothing left } if (includeSpans.doc() != excludeSpans.doc()) { return true; // previous call to includeSpans.nextNode() has returned true } // advance the excluded span to or after the included candidate node while (NodeUtils.compare(includeSpans.node(), excludeSpans.node()) > 0) { if (!(moreExclude = excludeSpans.nextNode())) { return true; } } return true; }
@Override public float scoreInNode() throws IOException { final float reqScore = requiredSpans.scoreInNode(); final int doc = requiredSpans.doc(); else if (optionalSpans.doc() < doc && !optionalSpans.skipToCandidate(doc)) { isOptionalExhausted = true; return reqScore; if (optionalSpans.doc() == doc && cmp > 0) { return reqScore;
@Override public boolean skipToCandidate(int target) throws IOException { if (!qInitialized) { qInitialized = true; return initSpanQueue(target); } boolean skipCalled = false; while (queue.size() != 0 && top().doc() < target) { if (top().skipToCandidate(target)) { queue.updateTop(); } else { queue.pop(); } skipCalled = true; } if (skipCalled) { return queue.size() != 0; } return nextCandidateDocument(); }