@Override public boolean nextPosition() throws IOException { return parentSpans.nextPosition(); }
@Override public boolean nextPosition() throws IOException { return this.requiredSpans.nextPosition(); }
@Override public boolean nextPosition() throws IOException { // move the included spans to its next position if (!includeSpans.nextPosition()) { // no match for included spans return false; } // try to find a non excluded position return this.toNonExcludedPosition(); }
@Override public boolean nextPosition() throws IOException { if (!spans.nextPosition()){ return false; } return doNextPosition(); }
protected boolean doNextPosition() throws IOException { for (;;) { switch (acceptPosition(this)) { case YES: return true; case NO: if (!spans.nextPosition()) return false; break; } } }
protected void computeScoreAndFreq() throws IOException { numMatches = 0; scoreInNode = 0.0f; // we have already called one time #nextPosition do { numMatches++; scoreInNode += spans.scoreInNode(); } while (spans.nextPosition()); // set the flag isScoreAndFreqComputed = true; }
@Override public boolean nextNode() throws IOException { // reset score and freq flag isScoreAndFreqComputed = false; do { // check if all the terms appear in the node if (!spans.nextNode()) { return false; } // we might have a match, call #nextPosition to check } while (!spans.nextPosition()); return true; }
@Override public boolean nextPosition() throws IOException { // Initialise the first spans if (!subSpans[0].nextPosition()) { matchStart = matchEnd = PositionsIterator.NO_MORE_POS; return false; } // Ensure that all the spans are ordered while (stretchToOrder()) { // check if the spans are within the allowed slop if (shrinkToAfterShortestMatch()) { return true; } // the spans were not in the allowed slop, try the next one // subSpans[0] has been advanced after the possible match, no need to call subSpans[0].nextPosition() } // if we are out of the loop, then this means that one of the sub-span is exhausted matchStart = matchEnd = PositionsIterator.NO_MORE_POS; return false; }
/** * Advances includeSpans to the next non excluded position, if any. {@link #includeSpans} must have been advanced * once to a new position using {@link #nextPosition()}. * * @return true iff the current candidate document and node has a non excluded position. */ private boolean toNonExcludedPosition() throws IOException { boolean moreInclude = true; while (moreInclude) { // moving exclude position to find if there is an overlap while (moreExclude && (excludeSpans.start() == -1 || excludeSpans.end() <= includeSpans.start() - pre)) { moreExclude = excludeSpans.nextPosition(); } // excluded if (moreExclude && excludeSpans.start() < includeSpans.end() + post) { // try another include position moreInclude = includeSpans.nextPosition(); } else { return moreInclude; } } return moreInclude; }
/** * Initialise the spans by advancing them to their first position, compute the initial total length, and find the max. */ private boolean initialiseSpansPosition() throws IOException { // reset totalLength to 0 totalLength = 0; // reset max max = null; // Initialise the spans, compute the initial total length, and find the max for (Spans spans : subSpans) { if (!spans.nextPosition()) { return false; } // increment total length totalLength += spans.end() - spans.start(); // update max reference this.updateMax(spans); } // rebuild the queue this.rebuildQueue(); return true; }
/** * Order the subSpans within the same document and same node by advancing all later spans * after the previous one. */ private boolean stretchToOrder() throws IOException { for (int i = 1; i < subSpans.length; i++) { while (!isSpansOrdered(subSpans[i-1].start(), subSpans[i-1].end(), subSpans[i].start(), subSpans[i].end())) { if (!subSpans[i].nextPosition()) { return false; } } } return true; }
/** * Move all the least spans in the queue that are positioned on the same document, node and position to their * next position and adjust the heap. * * @return If the least spans has no more positions, returns false. */ public final boolean nextPositionAndAdjust() throws IOException { // Count number of spans, starting from the top, having the same document, node and position. // Add 1 to count the top. int count = this.countPositionEqualToTop(1) + 1; // Move the spans to the next position for (int i = 0; i < count; i++) { this.top().nextPosition(); this.updateTop(); } // if the top's position is the sentinel value, it means that the positions are exhausted return (this.top().start() == PositionsIterator.NO_MORE_POS) ? false : true; }
/** * Advance the min to its next position, update the total length and the max. */ private boolean advanceMinToNextPosition() throws IOException { // retrieve the min Spans min = queue.top(); // cache length before advancing to the next position int oldLength = min.end() - min.start(); // we advance the min to its next position if (!min.nextPosition()) { return false; } // update total length this.updateTotalLength(oldLength, min.end() - min.start()); // update max reference this.updateMax(min); // update queue queue.updateTop(); return true; }
if (!prevSpans.nextPosition()) {
while (optionalSpans.nextPosition() && optionalSpans.start() <= (requiredSpans.end() + allowedOptionalSlop)) {