/** * Go to next location of this term current document, and set * <code>position</code> as <code>location - offset</code>, so that a * matching exact phrase is easily identified when all PhrasePositions * have exactly the same <code>position</code>. */ final boolean nextPosition() throws IOException { if (count-- > 0) { // read subsequent pos's position = postings.nextPosition() - offset; return true; } else { return false; } }
/** Advance the given pos enum to the first doc on or after {@code target}. * Return {@code false} if the enum was exhausted before reaching * {@code target} and {@code true} otherwise. */ private static boolean advancePosition(PostingsAndPosition posting, int target) throws IOException { while (posting.pos < target) { if (posting.upTo == posting.freq) { return false; } else { posting.pos = posting.postings.nextPosition(); posting.upTo += 1; } } return true; }
@Override public boolean next() throws IOException { if (upto-- > 0) { pos = pe.nextPosition(); return true; } return false; }
@Override public int nextPosition() throws IOException { return current.nextPosition(); }
@Override public int nextPosition() throws IOException { return in.nextPosition(); }
/** * Go to next location of this term current document, and set * <code>position</code> as <code>location - offset</code>, so that a * matching exact phrase is easily identified when all PhrasePositions * have exactly the same <code>position</code>. */ final boolean nextPosition() throws IOException { if (count-- > 0) { // read subsequent pos's position = postings.nextPosition() - offset; return true; } else return false; }
/** Advance the given pos enum to the first doc on or after {@code target}. * Return {@code false} if the enum was exhausted before reaching * {@code target} and {@code true} otherwise. */ private static boolean advancePosition(PostingsAndPosition posting, int target) throws IOException { while (posting.pos < target) { if (posting.upTo == posting.freq) { return false; } else { posting.pos = posting.postings.nextPosition(); posting.upTo += 1; } } return true; }
@Override public int nextStartPosition() throws IOException { if (count == freq) { assert position != NO_MORE_POSITIONS; return position = NO_MORE_POSITIONS; } int prevPosition = position; position = postings.nextPosition(); assert position >= prevPosition : "prevPosition="+prevPosition+" > position="+position; assert position != NO_MORE_POSITIONS; // int endPosition not possible count++; readPayload = false; return position; }
@Override public int nextPosition() throws IOException { int pos = current.postings.nextPosition(); if (pos < 0) { throw new CorruptIndexException("position=" + pos + " is negative, field=\"" + field + " doc=" + current.mappedDocID, current.postings.toString()); } else if (pos > IndexWriter.MAX_POSITION) { throw new CorruptIndexException("position=" + pos + " is too large (> IndexWriter.MAX_POSITION=" + IndexWriter.MAX_POSITION + "), field=\"" + field + "\" doc=" + current.mappedDocID, current.postings.toString()); } return pos; }
final PostingsAndPosition lead = postings[0]; if (lead.upTo < lead.freq) { lead.pos = lead.postings.nextPosition(); lead.upTo += 1;
for (PostingsAndPosition posting : postings) { posting.freq = posting.postings.freq(); posting.pos = posting.postings.nextPosition(); posting.upTo = 1; break; lead.pos = lead.postings.nextPosition(); lead.upTo += 1;
@Override public int freq() throws IOException { int doc = docID(); if (doc == posQueueDoc) { return freq; } freq = 0; started = false; posQueue.clear(); for (PostingsAndPosition pp : subs) { if (pp.pe.docID() == doc) { pp.pos = pp.pe.nextPosition(); pp.upto = pp.pe.freq(); posQueue.add(pp); freq += pp.upto; } } return freq; }
private int getPhraseScore(final ComplexQueryData data, final int docBase, final PostingsEnum postingsEnum) throws IOException { int weight = 0; while (postingsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) { int docId = postingsEnum.docID(); if (data.documentIds.has(docBase + docId)) { IntsHolder positions = data.scorer.getPositions(docBase + docId); if (positions == null) { continue; } int freq = postingsEnum.freq(); for (int i = 0; i < freq; i++) { int pos = postingsEnum.nextPosition(); if (positions.has(pos)) { weight++; } } } } return weight; }
@Override public int freq() throws IOException { int doc = docID(); if (doc != posQueueDoc) { posQueue.clear(); for (PostingsEnum sub : subs) { if (sub.docID() == doc) { int freq = sub.freq(); for (int i = 0; i < freq; i++) { posQueue.add(sub.nextPosition()); } } } posQueue.sort(); posQueueDoc = doc; } return posQueue.size(); }
@Override public int nextPosition() throws IOException { if (started == false) { started = true; return posQueue.top().pos; } if (posQueue.top().upto == 1) { posQueue.pop(); return posQueue.top().pos; } posQueue.top().pos = posQueue.top().pe.nextPosition(); posQueue.top().upto--; posQueue.updateTop(); return posQueue.top().pos; }
int pos = postings.nextPosition(); if (postingsTerms.hasPositions()) { int postingsPos = postingsDocs.nextPosition(); if (terms.hasPositions() && pos != postingsPos) { throw new RuntimeException("vector term=" + term + " field=" + field + " doc=" + j + ": pos=" + pos + " differs from postings pos=" + postingsPos);
private void addPositions(final PostingsEnum in, final IndexOutput out) throws IOException { int freq = in.freq(); out.writeVInt(freq); int previousPosition = 0; int previousEndOffset = 0; for (int i = 0; i < freq; i++) { final int pos = in.nextPosition(); final BytesRef payload = in.getPayload(); // The low-order bit of token is set only if there is a payload, the // previous bits are the delta-encoded position. final int token = (pos - previousPosition) << 1 | (payload == null ? 0 : 1); out.writeVInt(token); previousPosition = pos; if (storeOffsets) { // don't encode offsets if they are not stored final int startOffset = in.startOffset(); final int endOffset = in.endOffset(); out.writeVInt(startOffset - previousEndOffset); out.writeVInt(endOffset - startOffset); previousEndOffset = endOffset; } if (payload != null) { out.writeVInt(payload.length); out.writeBytes(payload.bytes, payload.offset, payload.length); } } }
int pos = postingsEnum.nextPosition(); BytesRef payload = writePayloads ? postingsEnum.getPayload() : null; int startOffset;
final int pos = docsAndPositionsEnum.nextPosition(); final int startOffset = docsAndPositionsEnum.startOffset(); final int endOffset = docsAndPositionsEnum.endOffset();
final int pos = docsAndPositionsEnum.nextPosition(); final int startOffset = docsAndPositionsEnum.startOffset(); final int endOffset = docsAndPositionsEnum.endOffset();