/** * Advance to the next position.<br> * Set the cell and tuple information.<br> * Iterate over the queue, and count how many matchers there are. Increment the score * consequently. */ @Override public int nextPosition() throws IOException { // if tuple or cell have been set to sentinel value, there is no more position if (scorerCellQueue.topTuple() == Integer.MAX_VALUE || scorerCellQueue.topCell() == Integer.MAX_VALUE) { return NO_MORE_POS; } tuple = scorerCellQueue.topTuple(); cell = scorerCellQueue.topCell(); currentScore = 0; nrMatchers = 0; // Count how many matchers there are, and increment current score while (scorerCellQueue.topEntity() == entity && scorerCellQueue.topTuple() == tuple && scorerCellQueue.topCell() == cell) { // while top is a match, advance currentScore += scorerCellQueue.topScore(); if (scorerCellQueue.topIncMatchers()) nrMatchers++; if (!scorerCellQueue.topNextPositionAndAdjust()) { return 0; // stop, no more position. position is invalid in this scorer, // return 0. // All positions in the queue are consumed. If nextPosition // is called another time, we will return NO_MORE_POS. } } return 0; // position is invalid in this scorer, return 0. }