Пример #1
0
  /*
   * Try and skip all those term positions at documents less than the current
   * max up to value. This is quite likely to fail and leave us with (min !=
   * max) but that is OK, we try again.
   *
   * It is possible that max increases as we process terms, this is OK. We
   * just failed to skip to a given value of max and start doing the next.
   */
  private void skipToMax() throws IOException {
    // Do the terms
    int current;
    for (int i = 0, l = positions.length; i < l; i++) {
      if (i == 0) {
        min = max;
      }
      if (positions[i].getCachingTermPositions() != null) {
        if (positions[i].getCachingTermPositions().doc() < max) {
          if (positions[i].getCachingTermPositions().skipTo(max)) {
            current = positions[i].getCachingTermPositions().doc();
            adjustMinMax(current, false);
          } else {
            more = false;
            return;
          }
        }
      }
    }

    // Do the root
    if (root.doc() < max) {
      if (root.skipTo(max)) {
        rootDoc = root.doc();
      } else {
        more = false;
        return;
      }
    }
  }
Пример #2
0
  /*
   * Go through all the term positions and try and move to next document. Any
   * failure measn we have no more.
   *
   * This can be used at initialisation and when moving away from an existing
   * match.
   *
   * This will set min, max, more and rootDoc
   *
   */
  private void doNextOnAll() throws IOException {
    // Do the terms
    int current;
    boolean first = true;
    for (int i = 0, l = positions.length; i < l; i++) {
      if (positions[i].getCachingTermPositions() != null) {
        if (positions[i].getCachingTermPositions().next()) {

          current = positions[i].getCachingTermPositions().doc();
          adjustMinMax(current, first);
          first = false;
        } else {
          more = false;
          return;
        }
      }
    }

    // Do the root term - it must always exists as the path could well have mutiple entries
    // If an entry in the index does not have a root terminal it is broken
    if (root.next()) {
      rootDoc = root.doc();
    } else {
      more = false;
      return;
    }
    if (root.doc() < max) {
      if (root.skipTo(max)) {
        rootDoc = root.doc();
      } else {
        more = false;
        return;
      }
    }
  }
Пример #3
0
  /*
   * (non-Javadoc)
   *
   * @see org.apache.lucene.search.Scorer#skipTo(int)
   */
  public boolean skipTo(int target) throws IOException {
    if (allContainers()) {
      containers.skipTo(target);
      root.skipTo(containers.doc()); // must match
      if (check(0, root.nextPosition())) {
        return true;
      }
      while (more) {
        if (containers.next() && root.next()) {
          if (check(0, root.nextPosition())) {
            return true;
          }
        } else {
          more = false;
          return false;
        }
      }
    }

    max = target;
    return findNext();
  }