Package org.apache.lucene.util

Examples of org.apache.lucene.util.Bits$MatchNoBits


  private void checkExpecteds(BitSet expecteds) throws Exception {
    IndexReader r = DirectoryReader.open(dir);

    //Perhaps not the most efficient approach but meets our
    //needs here.
    final Bits liveDocs = MultiFields.getLiveDocs(r);
    for (int i = 0; i < r.maxDoc(); i++) {
      if (liveDocs == null || liveDocs.get(i)) {
        String sval=r.document(i).get(FIELD_RECORD_ID);
        if(sval!=null) {
          int val=Integer.parseInt(sval);
          assertTrue("Did not expect document #"+val, expecteds.get(val));
          expecteds.set(val,false);
View Full Code Here


        assertNull(norms2);
      }
    }
   
    // check deletions
    final Bits liveDocs1 = MultiFields.getLiveDocs(index1);
    final Bits liveDocs2 = MultiFields.getLiveDocs(index2);
    for (int i = 0; i < index1.maxDoc(); i++) {
      assertEquals("Doc " + i + " only deleted in one index.",
                   liveDocs1 == null || !liveDocs1.get(i),
                   liveDocs2 == null || !liveDocs2.get(i));
    }
   
    // check stored fields
    for (int i = 0; i < index1.maxDoc(); i++) {
      if (liveDocs1 == null || liveDocs1.get(i)) {
        Document doc1 = index1.document(i);
        Document doc2 = index2.document(i);
        List<IndexableField> field1 = doc1.getFields();
        List<IndexableField> field2 = doc2.getFields();
        assertEquals("Different numbers of fields for doc " + i + ".", field1.size(), field2.size());
        Iterator<IndexableField> itField1 = field1.iterator();
        Iterator<IndexableField> itField2 = field2.iterator();
        while (itField1.hasNext()) {
          Field curField1 = (Field) itField1.next();
          Field curField2 = (Field) itField2.next();
          assertEquals("Different fields names for doc " + i + ".", curField1.name(), curField2.name());
          assertEquals("Different field values for doc " + i + ".", curField1.stringValue(), curField2.stringValue());
        }         
      }
    }
   
    // check dictionary and posting lists
    Fields fields1 = MultiFields.getFields(index1);
    Fields fields2 = MultiFields.getFields(index2);
    Iterator<String> fenum2 = fields2.iterator();
    Bits liveDocs = MultiFields.getLiveDocs(index1);
    for (String field1 : fields1) {
      assertEquals("Different fields", field1, fenum2.next());
      Terms terms1 = fields1.terms(field1);
      if (terms1 == null) {
        assertNull(fields2.terms(field1));
View Full Code Here

  }

  public void test1() throws IOException {
    ParallelAtomicReader pr = new ParallelAtomicReader(ir1, ir2);

    Bits liveDocs = pr.getLiveDocs();

    Fields fields = pr.fields();
    Iterator<String> fe = fields.iterator();

    String f = fe.next();
View Full Code Here

    DocValuesProducer dvProducer = dvProducers.get(field);
    assert dvProducer != null;

    Map<String,Bits> dvFields = docsWithFieldLocal.get();

    Bits dvs = dvFields.get(field);
    if (dvs == null) {
      dvs = dvProducer.getDocsWithField(fi);
      dvFields.put(field, dvs);
    }
View Full Code Here

  private Bits getMissingBits(final long offset) throws IOException {
    if (offset == -1) {
      return new Bits.MatchAllBits(maxDoc);
    } else {
      final IndexInput in = data.clone();
      return new Bits() {

        @Override
        public boolean get(int index) {
          try {
            in.seek(offset + (index >> 3));
View Full Code Here

      final int firstFilterDoc = filterIter.nextDoc();
      if (firstFilterDoc == DocIdSetIterator.NO_MORE_DOCS) {
        return null;
      }
     
      final Bits filterAcceptDocs = docIdSet.bits();
      // force if RA is requested
      final boolean useRandomAccess = filterAcceptDocs != null && useRandomAccess(filterAcceptDocs, firstFilterDoc);
      if (useRandomAccess) {
        // if we are using random access, we return the inner scorer, just with other acceptDocs
        return weight.scorer(context, scoreDocsInOrder, topScorer, filterAcceptDocs);
View Full Code Here

  private static final class QueryFirstFilterStrategy extends FilterStrategy {
    @Override
    public Scorer filteredScorer(final AtomicReaderContext context,
        boolean scoreDocsInOrder, boolean topScorer, Weight weight,
        DocIdSet docIdSet) throws IOException {
      Bits filterAcceptDocs = docIdSet.bits();
      if (filterAcceptDocs == null) {
        return LEAP_FROG_QUERY_FIRST_STRATEGY.filteredScorer(context, scoreDocsInOrder, topScorer, weight, docIdSet);
      }
      final Scorer scorer = weight.scorer(context, true, false, null);
      return scorer == null ? null : new QueryFirstScorer(weight,
View Full Code Here

            throw new RuntimeException("too many deleted docs: maxDoc()=" + reader.maxDoc() + " vs del count=" + (info.info.getDocCount()-reader.numDocs()));
          }
          if (info.info.getDocCount() - numDocs != info.getDelCount()) {
            throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs reader=" + (info.info.getDocCount() - numDocs));
          }
          Bits liveDocs = reader.getLiveDocs();
          if (liveDocs == null) {
            throw new RuntimeException("segment should have deletions, but liveDocs is null");
          } else {
            int numLive = 0;
            for (int j = 0; j < liveDocs.length(); j++) {
              if (liveDocs.get(j)) {
                numLive++;
              }
            }
            if (numLive != numDocs) {
              throw new RuntimeException("liveDocs count mismatch: info=" + numDocs + ", vs bits=" + numLive);
            }
          }
         
          segInfoStat.numDeleted = info.info.getDocCount() - numDocs;
          msg(infoStream, "OK [" + (segInfoStat.numDeleted) + " deleted docs]");
        } else {
          if (info.getDelCount() != 0) {
            throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs reader=" + (info.info.getDocCount() - numDocs));
          }
          Bits liveDocs = reader.getLiveDocs();
          if (liveDocs != null) {
            // its ok for it to be non-null here, as long as none are set right?
            for (int j = 0; j < liveDocs.length(); j++) {
              if (!liveDocs.get(j)) {
                throw new RuntimeException("liveDocs mismatch: info says no deletions but doc " + j + " is deleted.");
              }
            }
          }
          msg(infoStream, "OK");
View Full Code Here

    // TODO: we should go and verify term vectors match, if
    // crossCheckTermVectors is on...

    Status.TermIndexStatus status;
    final int maxDoc = reader.maxDoc();
    final Bits liveDocs = reader.getLiveDocs();

    try {
      if (infoStream != null) {
        infoStream.print("    test: terms, freq, prox...");
      }
View Full Code Here

      if (infoStream != null) {
        infoStream.print("    test: stored fields.......");
      }

      // Scan stored fields for all documents
      final Bits liveDocs = reader.getLiveDocs();
      for (int j = 0; j < reader.maxDoc(); ++j) {
        // Intentionally pull even deleted documents to
        // make sure they too are not corrupt:
        Document doc = reader.document(j);
        if (liveDocs == null || liveDocs.get(j)) {
          status.docCount++;
          status.totFields += doc.getFields().size();
        }
      }     
View Full Code Here

TOP

Related Classes of org.apache.lucene.util.Bits$MatchNoBits

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.