public void testNearSpansNext() throws Exception { SpanNearQuery q = makeQuery(); Spans span = q.getSpans(searcher.getIndexReader()); assertEquals(true, span.next()); assertEquals(s(0, 0, 3), s(span)); assertEquals(true, span.next()); assertEquals(s(1, 0, 4), s(span)); assertEquals(false, span.next()); }
public boolean next() throws IOException { if (firstTime) { more = spans.next(); firstTime = false; } if (!more) return false; freq = 0.0f; doc = spans.doc(); while (more && doc == spans.doc()) { int matchLength = spans.end() - spans.start(); freq += getSimilarity().sloppyFreq(matchLength); more = spans.next(); } return more || freq != 0.0f; }
protected boolean setFreqCurrentDoc() throws IOException { if (!more) { return false; } doc = spans.doc(); freq = 0.0f; do { int matchLength = spans.end() - spans.start(); freq += similarity.sloppyFreq(matchLength); more = spans.next(); } while (more && (doc == spans.doc())); return true; }
protected boolean doNext() throws IOException { for (; ; ) { switch (acceptPosition(this)) { case YES: return true; case NO: if (!spans.next()) return false; break; case NO_AND_ADVANCE: if (!spans.skipTo(spans.doc() + 1)) return false; break; } } }
public boolean skipTo(int target) throws IOException { more = spans.skipTo(target); if (!more) return false; freq = 0.0f; doc = spans.doc(); while (more && spans.doc() == target) { freq += getSimilarity().sloppyFreq(spans.end() - spans.start()); more = spans.next(); } return more || freq != 0.0f; }
public boolean next() throws IOException { if (length != -1) // subtract old length totalLength -= length; boolean more = spans.next(); // move to next if (more) { length = end() - start(); // compute new length totalLength += length; // add new length to total if (max == null || doc() > max.doc() || // maintain max (doc() == max.doc() && end() > max.end())) max = this; } return more; }
@Override public boolean next() throws IOException { if (!spans.next()) return false; return doNext(); }