示例#1
0
 /**
  * Skips to the first match (including the current) whose entity, tuple and cell numbers are
  * greater than or equal to the given targets. <br>
  * When this method is used the {@link #explain(int)} method should not be used. <br>
  * The implementation uses the skipTo() method on the subscorers.
  *
  * @param entityID The target entity number.
  * @param tupleID The target tuple number.
  * @param cellID The target cell number.
  * @return true iff there is such a match.
  */
 @Override
 public int advance(final int entityID, final int tupleID, final int cellID) throws IOException {
   if (scorerCellQueue == null) {
     this.initScorerCellQueue();
   }
   if (entityID < entity
       || (entityID == entity && tupleID <= tuple)
       || (entityID == entity && tupleID == tuple && cellID <= cell)) {
     return entity;
   }
   while (queueSize > 0) {
     if (scorerCellQueue.topEntity() > entityID
         || (scorerCellQueue.topEntity() == entityID
             && (scorerCellQueue.topTuple() != Integer.MAX_VALUE
                 && scorerCellQueue.topTuple() >= tupleID))
         || (scorerCellQueue.topEntity() == entityID
             && scorerCellQueue.topTuple() == tupleID
             && (scorerCellQueue.topCell() != Integer.MAX_VALUE
                 && scorerCellQueue.topCell() >= cellID))) {
       entity = scorerCellQueue.topEntity();
       this.nextPosition();
       return entity;
     } else if (!scorerCellQueue.topSkipToAndAdjustElsePop(entityID, tupleID, cellID)) {
       if (--queueSize == 0) {
         return NO_MORE_DOCS;
       }
     }
   }
   return NO_MORE_DOCS;
 }
示例#2
0
 /**
  * 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.
 }