Exemplo n.º 1
0
 private boolean synchronize() throws IOException {
   while (more && spans.doc() != docIdSetIter.docID()) {
     if (spans.doc() < docIdSetIter.docID()) {
       more = spans.skipTo(docIdSetIter.docID());
     } else if (docIdSetIter.advance(spans.doc()) == DocIdSetIterator.NO_MORE_DOCS) {
       more = false;
     }
   }
   return more;
 }
Exemplo n.º 2
0
  /**
   * Skip to the specified document (or the first document after it containing hits)
   *
   * @param doc the doc number to skip to (or past)
   * @return true if we're still pointing to a valid hit, false if we're done
   * @throws IOException
   */
  @Override
  public boolean skipTo(int doc) throws IOException {
    // Skip both to doc
    stillValidContainers = producer.skipTo(doc);

    // Find first matching container from here
    return synchronize();
  }
Exemplo n.º 3
0
  /**
   * Go to next span.
   *
   * @return true if we're at the next span, false if we're done
   * @throws IOException
   */
  @Override
  public boolean next() throws IOException {
    // Are we done yet?
    if (!stillValidContainers || !stillValidSearch) return false;

    // Advance container
    stillValidContainers = producer.next();
    if (!stillValidContainers) return false; // no more containers; we're done.

    // Find first matching container from here
    return synchronize();
  }
Exemplo n.º 4
0
 @Override
 public boolean hitsAreUnique() {
   return spans.hitsAreUnique();
 }
Exemplo n.º 5
0
 @Override
 public void getCapturedGroups(Span[] capturedGroups) {
   if (!childClausesCaptureGroups) return;
   producer.getCapturedGroups(capturedGroups);
   filter.getCapturedGroups(filterIndex, capturedGroups);
 }
Exemplo n.º 6
0
 @Override
 public int hitsLength() {
   return spans.hitsLength();
 }
Exemplo n.º 7
0
 @Override
 public boolean hitsHaveUniqueEnd() {
   return spans.hitsHaveUniqueEnd();
 }
Exemplo n.º 8
0
 /** @return start of current span */
 @Override
 public int start() {
   return producer.start();
 }
Exemplo n.º 9
0
 @Override
 public boolean hitsAllSameLength() {
   return spans.hitsAllSameLength();
 }
Exemplo n.º 10
0
 @Override
 public int doc() {
   return spans.doc();
 }
Exemplo n.º 11
0
 @Override
 public int start() {
   return spans.start();
 }
Exemplo n.º 12
0
 @Override
 public void passHitQueryContextToClauses(HitQueryContext context) {
   producer.setHitQueryContext(context);
   filter.setHitQueryContext(context);
 }
Exemplo n.º 13
0
 @Override
 public boolean next() throws IOException {
   if (!more) return false;
   more = spans.next();
   return synchronize();
 }
Exemplo n.º 14
0
 @Override
 public boolean hitsAreUnique() {
   return producer.hitsAreUnique();
 }
Exemplo n.º 15
0
 @Override
 public boolean hitsHaveUniqueEnd() {
   return producer.hitsHaveUniqueEnd();
 }
Exemplo n.º 16
0
 @Override
 public int hitsLength() {
   return producer.hitsLength();
 }
Exemplo n.º 17
0
 @Override
 public boolean hitsAllSameLength() {
   return producer.hitsAllSameLength();
 }
Exemplo n.º 18
0
 @Override
 public boolean hitsEndPointSorted() {
   return producer.hitsEndPointSorted();
 }
Exemplo n.º 19
0
 @Override
 public boolean skipTo(int target) throws IOException {
   if (!more) return false;
   more = spans.skipTo(target);
   return synchronize();
 }
Exemplo n.º 20
0
 /** @return the Lucene document id of the current hit */
 @Override
 public int doc() {
   return producer.doc();
 }
Exemplo n.º 21
0
 @Override
 public int end() {
   return spans.end();
 }
Exemplo n.º 22
0
 /** @return end position of current hit */
 @Override
 public int end() {
   return producer.end();
 }
Exemplo n.º 23
0
 @Override
 public boolean hitsStartPointSorted() {
   return spans.hitsStartPointSorted();
 }
Exemplo n.º 24
0
  /**
   * Find a container with search hits in it, starting from the current container.
   *
   * @return true if found, false if no such container exists (i.e. we're done)
   * @throws IOException
   */
  private boolean synchronize() throws IOException {
    // Find the next "valid" container, if there is one.
    while (true) {
      // Are search and container in the same document?
      if (filter.doc() < producer.doc()) {
        // No, advance search to be in the same document as the container
        stillValidSearch = filter.skipTo(producer.doc());
        if (!stillValidSearch) return false; // No more search results, we're done.
      }

      // Are there search results in this document?
      if (filter.doc() == producer.doc()) {
        // Yes. See if the current container contains any of the search results.
        // List<Hit> filterHits = filter.getHits();
        switch (op) {
          case CONTAINING:
            // Looking for producer hits with a filter hit inside
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.start(i) >= producer.start() && filter.end(i) <= producer.end()) {
                // Yes, this filter hit is contained in the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          case WITHIN:
            // Looking for producer hits contained by a filter hit
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.start(i) <= producer.start() && filter.end(i) >= producer.end()) {
                // Yes, this filter hit contains the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          case STARTS_AT:
            // Looking for producer hits starting at a filter hit
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.start(i) == producer.start()) {
                // Yes, this filter hit starts at the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          case ENDS_AT:
            // Looking for producer hits ending at a filter hit
            for (int i = 0; i < filter.bucketSize(); i++) {
              if (filter.end(i) == producer.end()) {
                // Yes, this filter hit ends at the current producer hit.
                filterIndex = i; // remember for captured groups
                return true;
              }
            }
            break;
          default:
            throw new RuntimeException("Unknown filter operation " + op);
        }
      }

      // No search results found in the current container.
      // Advance to the next container.
      stillValidContainers = producer.next();
      if (!stillValidContainers) return false; // no more containers; we're done.
    }
  }