Package org.apache.lucene.index

Examples of org.apache.lucene.index.AtomicReaderContext


      doc.add(newStringField(fieldName, "" + term, Field.Store.YES));
      w.addDocument(doc);
    }
    IndexReader reader = SlowCompositeReaderWrapper.wrap(w.getReader());
    assertTrue(reader.getContext() instanceof AtomicReaderContext);
    AtomicReaderContext context = (AtomicReaderContext) reader.getContext();
    w.close();

    List<Term> terms = new ArrayList<Term>();
    terms.add(new Term(fieldName, "19"));
    FixedBitSet bits = (FixedBitSet) termsFilter(random().nextBoolean(), terms).getDocIdSet(context, context.reader().getLiveDocs());
    assertNull("Must match nothing", bits);

    terms.add(new Term(fieldName, "20"));
    bits = (FixedBitSet) termsFilter(random().nextBoolean(), terms).getDocIdSet(context, context.reader().getLiveDocs());
    assertEquals("Must match 1", 1, bits.cardinality());

    terms.add(new Term(fieldName, "10"));
    bits = (FixedBitSet) termsFilter(random().nextBoolean(), terms).getDocIdSet(context, context.reader().getLiveDocs());
    assertEquals("Must match 2", 2, bits.cardinality());

    terms.add(new Term(fieldName, "00"));
    bits = (FixedBitSet) termsFilter(random().nextBoolean(), terms).getDocIdSet(context, context.reader().getLiveDocs());
    assertEquals("Must match 2", 2, bits.cardinality());

    reader.close();
    rd.close();
  }
View Full Code Here


    w.close();
    assertEquals(1, reader.leaves().size());
   
   
   
    AtomicReaderContext context = reader.leaves().get(0);
    TermsFilter tf = new TermsFilter(terms);

    FixedBitSet bits = (FixedBitSet) tf.getDocIdSet(context, context.reader().getLiveDocs());
    assertEquals("Must be num fields - 1 since we skip only one field", num-1, bits.cardinality())
    reader.close();
    dir.close();
  }
View Full Code Here

    }
    w.forceMerge(1);
    IndexReader reader = w.getReader();
    w.close();
    assertEquals(1, reader.leaves().size());
    AtomicReaderContext context = reader.leaves().get(0);
    TermsFilter tf = new TermsFilter(new ArrayList<Term>(terms));

    FixedBitSet bits = (FixedBitSet) tf.getDocIdSet(context, context.reader().getLiveDocs());
    assertEquals(context.reader().numDocs(), bits.cardinality())
    reader.close();
    dir.close();
  }
View Full Code Here

   * @throws BooleanQuery.TooManyClauses If a query would exceed
   *         {@link BooleanQuery#getMaxClauseCount()} clauses.
   */
  protected Explanation explain(Weight weight, int doc) throws IOException {
    int n = ReaderUtil.subIndex(doc, leafContexts);
    final AtomicReaderContext ctx = leafContexts.get(n);
    int deBasedDoc = doc - ctx.docBase;
   
    return weight.explain(ctx, deBasedDoc);
  }
View Full Code Here

      assert slice.leaves.length == 1;
      final TopFieldDocs docs = searcher.search(Arrays.asList(slice.leaves),
          weight, after, nDocs, sort, true, doDocScores || sort.needsScores(), doMaxScore);
      lock.lock();
      try {
        final AtomicReaderContext ctx = slice.leaves[0];
        final int base = ctx.docBase;
        hq.setNextReader(ctx);
        hq.setScorer(fakeScorer);
        for(ScoreDoc scoreDoc : docs.scoreDocs) {
          fakeScorer.doc = scoreDoc.doc - base;
View Full Code Here

        continue; // nothing to do
      }
      bi.setText(content);
      int doc = docids[i];
      int leaf = ReaderUtil.subIndex(doc, leaves);
      AtomicReaderContext subContext = leaves.get(leaf);
      AtomicReader r = subContext.reader();
      Terms t = r.terms(field);
      if (t == null) {
        continue; // nothing to do
      }
      if (leaf != lastLeaf) {
View Full Code Here

  }

  private Iterable<String> getFields(IndexReader reader) throws IOException {
    Set<String> fields = new TreeSet<String>();
    for (IndexReaderContext ctext : reader.getContext().leaves()) {
      AtomicReaderContext atomicReaderContext = (AtomicReaderContext) ctext;
      AtomicReader atomicReader = atomicReaderContext.reader();
      if (atomicReader instanceof SegmentReader) {
        for (String f : atomicReader.fields()) {
          fields.add(f);
        }
      }
View Full Code Here

    for (IndexReaderContext ctext : reader.getContext().leaves()) {
      if (_isClosed.get()) {
        LOG.info("Context [{0}] index closed", context);
        return null;
      }
      AtomicReaderContext atomicReaderContext = (AtomicReaderContext) ctext;
      AtomicReader atomicReader = atomicReaderContext.reader();
      if (atomicReader instanceof SegmentReader) {
        SegmentReader segmentReader = (SegmentReader) atomicReader;
        if (segmentReader.getSegmentName().equals(segmentName)) {
          return segmentReader.directory();
        }
View Full Code Here

    for (IndexReaderContext ctext : reader.getContext().leaves()) {
      if (_isClosed.get()) {
        LOG.info("Context [{0}] index closed", context);
        return null;
      }
      AtomicReaderContext atomicReaderContext = (AtomicReaderContext) ctext;
      AtomicReader atomicReader = atomicReaderContext.reader();
      results.putAll(sampleIndex(atomicReader, context));
    }
    return results;
  }
View Full Code Here

  }

  private Iterable<String> getFields(IndexReader reader) throws IOException {
    Set<String> fields = new TreeSet<String>();
    for (IndexReaderContext ctext : reader.getContext().leaves()) {
      AtomicReaderContext atomicReaderContext = (AtomicReaderContext) ctext;
      AtomicReader atomicReader = atomicReaderContext.reader();
      if (atomicReader instanceof SegmentReader) {
        for (String f : atomicReader.fields()) {
          fields.add(f);
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.AtomicReaderContext

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.