Package org.apache.lucene.search

Examples of org.apache.lucene.search.DocIdSetIterator


      int currentLength;
      boolean done = false;
     
      @Override
      public DocIdSetIterator iterator() throws IOException {
        return new DocIdSetIterator() {
         
          @Override
          public int nextDoc() throws IOException {
            if (done) {
              return DocIdSetIterator.NO_MORE_DOCS;
View Full Code Here


    if (docIdSet instanceof FixedBitSet) {
      // That is the most common case, if ScoredDocIdsCollector was used.
      complement = ((FixedBitSet) docIdSet).clone();
    } else {
      complement = new FixedBitSet(maxDoc);
      DocIdSetIterator iter = docIdSet.iterator();
      int doc;
      while ((doc = iter.nextDoc()) < maxDoc) {
        complement.set(doc);
      }
    }
    complement.flip(0, maxDoc);
    clearDeleted(reader, complement);
View Full Code Here

    // If there are no deleted docs
    if (!reader.hasDeletions()) {
      return; // return immediately
    }
   
    DocIdSetIterator it = set.iterator();
    int doc = it.nextDoc();
    for (AtomicReaderContext context : reader.leaves()) {
      AtomicReader r = context.reader();
      final int maxDoc = r.maxDoc() + context.docBase;
      if (doc >= maxDoc) { // skip this segment
        continue;
      }
      if (!r.hasDeletions()) { // skip all docs that belong to this reader as it has no deletions
        while ((doc = it.nextDoc()) < maxDoc) {}
        continue;
      }
      Bits liveDocs = r.getLiveDocs();
      do {
        if (!liveDocs.get(doc - context.docBase)) {
          set.clear(doc);
        }
      } while ((doc = it.nextDoc()) < maxDoc);
    }
  }
View Full Code Here

          @Override
          public boolean isCacheable() { return true; }

          @Override
          public DocIdSetIterator iterator() {
            return new DocIdSetIterator() {

              private int next = -1;

              @Override
              public int advance(int target) {
View Full Code Here

      @Override
      public DocIdSet getDocIDs() { return docIdSet; }

      @Override
      public ScoredDocIDsIterator iterator() throws IOException {
        final DocIdSetIterator docIterator = docIdSet.iterator();
        return new ScoredDocIDsIterator() {
          @Override
          public boolean next() {
            try {
              return docIterator.nextDoc() != DocIdSetIterator.NO_MORE_DOCS;
            } catch (IOException e) {
              throw new RuntimeException(e);
            }
          }

          @Override
          public float getScore() { return DEFAULT_SCORE; }

          @Override
          public int getDocID() { return docIterator.docID(); }
        };
      }

      @Override
      public int size() {
View Full Code Here

    if (mode==2) doIterate2(a, b);
  }

  void doIterate1(BitSet a, FixedBitSet b) throws IOException {
    int aa=-1,bb=-1;
    DocIdSetIterator iterator = b.iterator();
    do {
      aa = a.nextSetBit(aa+1);
      bb = (bb < b.length() && random().nextBoolean()) ? iterator.nextDoc() : iterator.advance(bb + 1);
      assertEquals(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
    } while (aa>=0);
  }
View Full Code Here

    } while (aa>=0);
  }

  void doIterate2(BitSet a, FixedBitSet b) throws IOException {
    int aa=-1,bb=-1;
    DocIdSetIterator iterator = b.iterator();
    do {
      aa = a.nextSetBit(aa+1);
      bb = random().nextBoolean() ? iterator.nextDoc() : iterator.advance(bb + 1);
      assertEquals(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
    } while (aa>=0);
  }
View Full Code Here

    for (int expectedDoc : expectedDocs) {
      expected.set(expectedDoc);
    }

    int docId;
    DocIdSetIterator iterator = expected.iterator();
    while ((docId = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
      if (!actual.get(docId)) {
        return false;
      }
    }
View Full Code Here

    // we dont pass acceptDocs, we will filter at the end using an additional filter
    DocIdSet docIdSet = filter.getDocIdSet(context, null);
    if (docIdSet == null) {
      return DocIdSetIterator.empty();
    } else {
      DocIdSetIterator iter = docIdSet.iterator();
      if (iter == null) {
        return DocIdSetIterator.empty();
      } else {
        return iter;
      }
View Full Code Here

        default:
          doChain(result, DEFAULT, dis);
          break;
      }
    } else {
      DocIdSetIterator disi;
      if (dis == null) {
        disi = DocIdSetIterator.empty();
      } else {
        disi = dis.iterator();
        if (disi == null) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.DocIdSetIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.