public int doc() { return spans.doc(); } public int start() { return spans.start(); }
public int doc() { return includeSpans.doc(); } public int start() { return includeSpans.start(); }
public int doc() { return spans.doc(); } public int start() { return spans.start(); }
/** Check whether two Spans in the same document are ordered. * @param spans1 * @param spans2 * @return true iff spans1 starts before spans2 * or the spans start at the same position, * and spans1 ends before spans2. */ static final boolean docSpansOrdered(Spans spans1, Spans spans2) { assert spans1.doc() == spans2.doc() : "doc1 " + spans1.doc() + " != doc2 " + spans2.doc(); int start1 = spans1.start(); int start2 = spans2.start(); /* Do not call docSpansOrdered(int,int,int,int) to avoid invoking .end() : */ return (start1 == start2) ? (spans1.end() < spans2.end()) : (start1 < start2); }
/** Check whether two Spans in the same document are ordered. * @param spans1 * @param spans2 * @return true iff spans1 starts before spans2 * or the spans start at the same position, * and spans1 ends before spans2. */ static final boolean docSpansOrdered(Spans spans1, Spans spans2) { assert spans1.doc() == spans2.doc() : "doc1 " + spans1.doc() + " != doc2 " + spans2.doc(); int start1 = spans1.start(); int start2 = spans2.start(); /* Do not call docSpansOrdered(int,int,int,int) to avoid invoking .end() : */ return (start1 == start2) ? (spans1.end() < spans2.end()) : (start1 < start2); }
public int doc() { return top().doc(); } public int start() { return top().start(); }
protected final boolean lessThan(Object o1, Object o2) { Spans spans1 = (Spans)o1; Spans spans2 = (Spans)o2; if (spans1.doc() == spans2.doc()) { if (spans1.start() == spans2.start()) { return spans1.end() < spans2.end(); } else { return spans1.start() < spans2.start(); } } else { return spans1.doc() < spans2.doc(); } } }
protected final boolean lessThan(Object o1, Object o2) { Spans spans1 = (Spans)o1; Spans spans2 = (Spans)o2; if (spans1.doc() == spans2.doc()) { if (spans1.start() == spans2.start()) { return spans1.end() < spans2.end(); } else { return spans1.start() < spans2.start(); } } else { return spans1.doc() < spans2.doc(); } } }
protected final boolean lessThan(Object o1, Object o2) { Spans spans1 = (Spans)o1; Spans spans2 = (Spans)o2; if (spans1.doc() == spans2.doc()) { if (spans1.start() == spans2.start()) { return spans1.end() < spans2.end(); } else { return spans1.start() < spans2.start(); } } else { return spans1.doc() < spans2.doc(); } } }
public boolean skipTo(int target) throws IOException { if (firstTime) { more = spans.skipTo(target); firstTime = false; } if (! more) { return false; } if (spans.doc() < target) { // setFreqCurrentDoc() leaves spans.doc() ahead more = spans.skipTo(target); } return setFreqCurrentDoc(); }
public boolean skipTo(int target) throws IOException { if (firstTime) { more = spans.skipTo(target); firstTime = false; } if (! more) { return false; } if (spans.doc() < target) { // setFreqCurrentDoc() leaves spans.doc() ahead more = spans.skipTo(target); } return setFreqCurrentDoc(); }
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; payloadScore = 0; payloadsSeen = 0; Similarity similarity1 = getSimilarity(); while (more && doc == spans.doc()) { int matchLength = spans.end() - spans.start(); freq += similarity1.sloppyFreq(matchLength); processPayload(similarity1); more = spans.next();//this moves positions to the next match in this document } return more || (freq != 0); }
protected boolean setFreqCurrentDoc() throws IOException { if (!more) { return false; } doc = spans.doc(); freq = 0.0f; payloadScore = 0; payloadsSeen = 0; Similarity similarity1 = getSimilarity(); while (more && doc == spans.doc()) { int matchLength = spans.end() - spans.start(); freq += similarity1.sloppyFreq(matchLength); processPayload(similarity1); more = spans.next();//this moves positions to the next match in this document } return more || (freq != 0); }
public boolean next() throws IOException { if (moreInclude) // move to next include moreInclude = includeSpans.next(); while (moreInclude && moreExclude) { if (includeSpans.doc() > excludeSpans.doc()) // skip exclude moreExclude = excludeSpans.skipTo(includeSpans.doc()); while (moreExclude // while exclude is before && includeSpans.doc() == excludeSpans.doc() && excludeSpans.end() <= includeSpans.start()) { moreExclude = excludeSpans.next(); // increment exclude } if (!moreExclude // if no intersection || includeSpans.doc() != excludeSpans.doc() || includeSpans.end() <= excludeSpans.start()) break; // we found a match moreInclude = includeSpans.next(); // intersected: keep scanning } return moreInclude; }