@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; } } }
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 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); } }