/** * test does not imply that skipTo(doc+1) should work exactly the same as next -- it's only * applicable in this case since we know doc does not contain more than one span */ public void testNearSpansSkipToLikeNext() throws Exception { SpanNearQuery q = makeQuery(); Spans span = q.getSpans(searcher.getIndexReader()); assertEquals(true, span.skipTo(0)); assertEquals(s(0, 0, 3), s(span)); assertEquals(true, span.skipTo(1)); assertEquals(s(1, 0, 4), s(span)); assertEquals(false, span.skipTo(2)); }
@Override public int advance(int target) throws IOException { if (!more) { return doc = NO_MORE_DOCS; } if (spans.doc() < target) { // setFreqCurrentDoc() leaves spans.doc() ahead more = spans.skipTo(target); } if (!setFreqCurrentDoc()) { doc = NO_MORE_DOCS; } return doc; }
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 skipTo(int target) throws IOException { if (length != -1) // subtract old length totalLength -= length; boolean more = spans.skipTo(target); // skip 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; }
public void testNearSpansSkipPast() throws Exception { SpanNearQuery q = makeQuery(); Spans span = q.getSpans(searcher.getIndexReader()); assertEquals(false, span.skipTo(2)); }
@Override public boolean skipTo(int target) throws IOException { if (!spans.skipTo(target)) return false; return doNext(); }