private void singleCellToPositionQueue() { maxEndPositionCell = subSpanCells.get(0); assert maxEndPositionCell.docID() == -1; assert maxEndPositionCell.startPosition() == -1; spanPositionQueue.add(maxEndPositionCell); }
private void singleCellToPositionQueue() { maxEndPositionCell = subSpanCells.get(0); assert maxEndPositionCell.docID() == -1; assert maxEndPositionCell.startPosition() == -1; spanPositionQueue.add(maxEndPositionCell); }
@Override public int nextStartPosition() throws IOException { if (atFirstInCurrentDoc) { atFirstInCurrentDoc = false; return minPositionCell().startPosition(); } while (minPositionCell().startPosition() == -1) { // initially at current doc minPositionCell().nextStartPosition(); spanPositionQueue.updateTop(); } assert minPositionCell().startPosition() != NO_MORE_POSITIONS; while (true) { if (minPositionCell().nextStartPosition() == NO_MORE_POSITIONS) { oneExhaustedInCurrentDoc = true; return NO_MORE_POSITIONS; } spanPositionQueue.updateTop(); if (atMatch()) { return minPositionCell().startPosition(); } } }
@Override boolean twoPhaseCurrentDocMatches() throws IOException { // at doc with all subSpans subSpanCellsToPositionQueue(); while (true) { if (atMatch()) { atFirstInCurrentDoc = true; oneExhaustedInCurrentDoc = false; return true; } assert minPositionCell().startPosition() != NO_MORE_POSITIONS; if (minPositionCell().nextStartPosition() != NO_MORE_POSITIONS) { spanPositionQueue.updateTop(); } else { // exhausted a subSpan in current doc return false; } } }
@Override public int nextStartPosition() throws IOException { if (atFirstInCurrentDoc) { atFirstInCurrentDoc = false; return minPositionCell().startPosition(); } while (minPositionCell().startPosition() == -1) { // initially at current doc minPositionCell().nextStartPosition(); spanPositionQueue.updateTop(); } assert minPositionCell().startPosition() != NO_MORE_POSITIONS; while (true) { if (minPositionCell().nextStartPosition() == NO_MORE_POSITIONS) { oneExhaustedInCurrentDoc = true; return NO_MORE_POSITIONS; } spanPositionQueue.updateTop(); if (atMatch()) { return minPositionCell().startPosition(); } } }
@Override boolean twoPhaseCurrentDocMatches() throws IOException { // at doc with all subSpans subSpanCellsToPositionQueue(); while (true) { if (atMatch()) { atFirstInCurrentDoc = true; oneExhaustedInCurrentDoc = false; return true; } assert minPositionCell().startPosition() != NO_MORE_POSITIONS; if (minPositionCell().nextStartPosition() != NO_MORE_POSITIONS) { spanPositionQueue.updateTop(); } else { // exhausted a subSpan in current doc return false; } } }
@Override public int width() { return maxEndPositionCell.startPosition() - minPositionCell().startPosition(); }
@Override public int width() { return maxEndPositionCell.startPosition() - minPositionCell().startPosition(); }
private void adjustLength() { if (spanLength != -1) { totalSpanLength -= spanLength; // subtract old, possibly from a previous doc } assert in.startPosition() != NO_MORE_POSITIONS; spanLength = endPosition() - startPosition(); assert spanLength >= 0; totalSpanLength += spanLength; // add new }
private void adjustLength() { if (spanLength != -1) { totalSpanLength -= spanLength; // subtract old, possibly from a previous doc } assert in.startPosition() != NO_MORE_POSITIONS; spanLength = endPosition() - startPosition(); assert spanLength >= 0; totalSpanLength += spanLength; // add new }
private void subSpanCellsToPositionQueue() throws IOException { // used when all subSpanCells arrived at the same doc. spanPositionQueue.clear(); for (SpansCell cell : subSpanCells) { assert cell.startPosition() == -1; cell.nextStartPosition(); assert cell.startPosition() != NO_MORE_POSITIONS; spanPositionQueue.add(cell); } }
private boolean atMatch() { assert minPositionCell().docID() == maxEndPositionCell.docID(); return (maxEndPositionCell.endPosition() - minPositionCell().startPosition() - totalSpanLength) <= allowedSlop; }
private boolean atMatch() { assert minPositionCell().docID() == maxEndPositionCell.docID(); return (maxEndPositionCell.endPosition() - minPositionCell().startPosition() - totalSpanLength) <= allowedSlop; }
@Override public int startPosition() { assert minPositionCell() != null; return atFirstInCurrentDoc ? -1 : oneExhaustedInCurrentDoc ? NO_MORE_POSITIONS : minPositionCell().startPosition(); }
@Override public int startPosition() { assert minPositionCell() != null; return atFirstInCurrentDoc ? -1 : oneExhaustedInCurrentDoc ? NO_MORE_POSITIONS : minPositionCell().startPosition(); }
private void subSpanCellsToPositionQueue() throws IOException { // used when all subSpanCells arrived at the same doc. spanPositionQueue.clear(); for (SpansCell cell : subSpanCells) { assert cell.startPosition() == -1; cell.nextStartPosition(); assert cell.startPosition() != NO_MORE_POSITIONS; spanPositionQueue.add(cell); } }