当前位置: 首页>>代码示例>>Java>>正文


Java Bits.get方法代码示例

本文整理汇总了Java中org.apache.lucene.util.Bits.get方法的典型用法代码示例。如果您正苦于以下问题:Java Bits.get方法的具体用法?Java Bits.get怎么用?Java Bits.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.util.Bits的用法示例。


在下文中一共展示了Bits.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkSortedNumericDocValues

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
private static void checkSortedNumericDocValues(String fieldName, AtomicReader reader, SortedNumericDocValues ndv, Bits docsWithField) {
  for (int i = 0; i < reader.maxDoc(); i++) {
    ndv.setDocument(i);
    int count = ndv.count();
    if (docsWithField.get(i)) {
      if (count == 0) {
        throw new RuntimeException("dv for field: " + fieldName + " is not marked missing but has zero count for doc: " + i);
      }
      long previous = Long.MIN_VALUE;
      for (int j = 0; j < count; j++) {
        long value = ndv.valueAt(j);
        if (value < previous) {
          throw new RuntimeException("values out of order: " + value + " < " + previous + " for doc: " + i);
        }
        previous = value;
      }
    } else {
      if (count != 0) {
        throw new RuntimeException("dv for field: " + fieldName + " is marked missing but has count=" + count + " for doc: " + i);
      }
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:CheckIndex.java

示例2: lookup

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
/** Return null if id is not found. */
public DocIdAndVersion lookup(BytesRef id, Bits liveDocs, LeafReaderContext context) throws IOException {
    if (termsEnum.seekExact(id)) {
        // there may be more than one matching docID, in the case of nested docs, so we want the last one:
        docsEnum = termsEnum.postings(docsEnum, 0);
        int docID = DocIdSetIterator.NO_MORE_DOCS;
        for (int d = docsEnum.nextDoc(); d != DocIdSetIterator.NO_MORE_DOCS; d = docsEnum.nextDoc()) {
            if (liveDocs != null && liveDocs.get(d) == false) {
                continue;
            }
            docID = d;
        }

        if (docID != DocIdSetIterator.NO_MORE_DOCS) {
            return new DocIdAndVersion(docID, versions.get(docID), context);
        }
    }

    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:PerThreadIDAndVersionLookup.java

示例3: exists

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
/**
 * Check whether there is one or more documents matching the provided query.
 */
public static boolean exists(IndexSearcher searcher, Query query) throws IOException {
    final Weight weight = searcher.createNormalizedWeight(query, false);
    // the scorer API should be more efficient at stopping after the first
    // match than the bulk scorer API
    for (LeafReaderContext context : searcher.getIndexReader().leaves()) {
        final Scorer scorer = weight.scorer(context);
        if (scorer == null) {
            continue;
        }
        final Bits liveDocs = context.reader().getLiveDocs();
        final DocIdSetIterator iterator = scorer.iterator();
        for (int doc = iterator.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.nextDoc()) {
            if (liveDocs == null || liveDocs.get(doc)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:Lucene.java

示例4: getSeqNosSet

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
private static FixedBitSet getSeqNosSet(final IndexReader reader, final long highestSeqNo) throws IOException {
    // _seq_no are stored as doc values for the time being, so this is how we get them
    // (as opposed to using an IndexSearcher or IndexReader)
    final FixedBitSet bitSet = new FixedBitSet((int) highestSeqNo + 1);
    final List<LeafReaderContext> leaves = reader.leaves();
    if (leaves.isEmpty()) {
        return bitSet;
    }

    for (int i = 0; i < leaves.size(); i++) {
        final LeafReader leaf = leaves.get(i).reader();
        final NumericDocValues values = leaf.getNumericDocValues(SeqNoFieldMapper.NAME);
        if (values == null) {
            continue;
        }
        final Bits bits = leaf.getLiveDocs();
        for (int docID = 0; docID < leaf.maxDoc(); docID++) {
            if (bits == null || bits.get(docID)) {
                final long seqNo = values.get(docID);
                assertFalse("should not have more than one document with the same seq_no[" + seqNo + "]", bitSet.get((int) seqNo));
                bitSet.set((int) seqNo);
            }
        }
    }
    return bitSet;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:InternalEngineTests.java

示例5: merge

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
/** Merges in the stored fields from the readers in 
 *  <code>mergeState</code>. The default implementation skips
 *  over deleted documents, and uses {@link #startDocument()},
 *  {@link #writeField(FieldInfo, IndexableField)}, and {@link #finish(FieldInfos, int)},
 *  returning the number of documents that were written.
 *  Implementations can override this method for more sophisticated
 *  merging (bulk-byte copying, etc). */
public int merge(MergeState mergeState) throws IOException {
  int docCount = 0;
  for (AtomicReader reader : mergeState.readers) {
    final int maxDoc = reader.maxDoc();
    final Bits liveDocs = reader.getLiveDocs();
    for (int i = 0; i < maxDoc; i++) {
      if (liveDocs != null && !liveDocs.get(i)) {
        // skip deleted docs
        continue;
      }
      // TODO: this could be more efficient using
      // FieldVisitor instead of loading/writing entire
      // doc; ie we just have to renumber the field number
      // on the fly?
      // NOTE: it's very important to first assign to doc then pass it to
      // fieldsWriter.addDocument; see LUCENE-1282
      Document doc = reader.document(i);
      addDocument(doc, mergeState.fieldInfos);
      docCount++;
      mergeState.checkAbort.work(300);
    }
  }
  finish(mergeState.fieldInfos, docCount);
  return docCount;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:StoredFieldsWriter.java

示例6: createStore

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
private static PercolateQuery.QueryStore createStore(PercolatorFieldMapper.FieldType fieldType,
                                                     QueryShardContext context,
                                                     boolean mapUnmappedFieldsAsString) {
    return ctx -> {
        LeafReader leafReader = ctx.reader();
        BinaryDocValues binaryDocValues = leafReader.getBinaryDocValues(fieldType.queryBuilderField.name());
        if (binaryDocValues == null) {
            return docId -> null;
        }

        Bits bits = leafReader.getDocsWithField(fieldType.queryBuilderField.name());
        return docId -> {
            if (bits.get(docId)) {
                BytesRef qbSource = binaryDocValues.get(docId);
                if (qbSource.length > 0) {
                    XContent xContent = PercolatorFieldMapper.QUERY_BUILDER_CONTENT_TYPE.xContent();
                    try (XContentParser sourceParser = xContent.createParser(context.getXContentRegistry(), qbSource.bytes,
                            qbSource.offset, qbSource.length)) {
                        return parseQuery(context, mapUnmappedFieldsAsString, sourceParser);
                    }
                } else {
                    return null;
                }
            } else {
                return null;
            }
        };
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:PercolateQueryBuilder.java

示例7: doPostCollection

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
protected void doPostCollection() throws IOException {
    IndexReader indexReader = context().searcher().getIndexReader();
    for (LeafReaderContext ctx : indexReader.leaves()) {
        Scorer childDocsScorer = childFilter.scorer(ctx);
        if (childDocsScorer == null) {
            continue;
        }
        DocIdSetIterator childDocsIter = childDocsScorer.iterator();

        final LeafBucketCollector sub = collectableSubAggregators.getLeafCollector(ctx);
        final SortedDocValues globalOrdinals = valuesSource.globalOrdinalsValues(parentType, ctx);

        // Set the scorer, since we now replay only the child docIds
        sub.setScorer(new ConstantScoreScorer(null, 1f,childDocsIter));

        final Bits liveDocs = ctx.reader().getLiveDocs();
        for (int docId = childDocsIter.nextDoc(); docId != DocIdSetIterator.NO_MORE_DOCS; docId = childDocsIter.nextDoc()) {
            if (liveDocs != null && liveDocs.get(docId) == false) {
                continue;
            }
            long globalOrdinal = globalOrdinals.getOrd(docId);
            if (globalOrdinal != -1) {
                long bucketOrd = parentOrdToBuckets.get(globalOrdinal);
                if (bucketOrd != -1) {
                    collectBucket(sub, docId, bucketOrd);
                    if (multipleBucketsPerParentOrd) {
                        long[] otherBucketOrds = parentOrdToOtherBuckets.get(globalOrdinal);
                        if (otherBucketOrds != null) {
                            for (long otherBucketOrd : otherBucketOrds) {
                                collectBucket(sub, docId, otherBucketOrd);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:ParentToChildrenAggregator.java

示例8: getLeafCollector

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {
    // no need to provide deleted docs to the filter
    final Bits bits = Lucene.asSequentialAccessBits(ctx.reader().maxDoc(), filter.scorer(ctx));
    return new LeafBucketCollectorBase(sub, null) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            if (bits.get(doc)) {
                collectBucket(sub, doc, bucket);
            }
        }
    };
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:15,代码来源:FilterAggregator.java

示例9: getLeafCollector

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException {
    final Scorer filterScorer = filter.scorer(context);
    final LeafCollector in = collector.getLeafCollector(context);
    final Bits bits = Lucene.asSequentialAccessBits(context.reader().maxDoc(), filterScorer);

    return new FilterLeafCollector(in) {
        @Override
        public void collect(int doc) throws IOException {
            if (bits.get(doc)) {
                in.collect(doc);
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:FilteredCollector.java

示例10: linearScan

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
protected final int linearScan(int scanTo) throws IOException {
  final int[] docs = this.docs;
  final int upTo = count;
  final Bits liveDocs = this.liveDocs;
  for (int i = start; i < upTo; i++) {
    int d = docs[i];
    if (scanTo <= d && liveDocs.get(d)) {
      start = i;
      freq = freqs[i];
      return doc = docs[i];
    }
  }
  return doc = refill();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:Lucene40PostingsReader.java

示例11: scanTo

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
protected int scanTo(int target) throws IOException { 
  int docAcc = accum;
  int frq = 1;
  final IndexInput freqIn = this.freqIn;
  final boolean omitTF = indexOmitsTF;
  final int loopLimit = limit;
  final Bits liveDocs = this.liveDocs;
  for (int i = ord; i < loopLimit; i++) {
    int code = freqIn.readVInt();
    if (omitTF) {
      docAcc += code;
    } else {
      docAcc += code >>> 1; // shift off low bit
      frq = readFreq(freqIn, code);
    }
    if (docAcc >= target && liveDocs.get(docAcc)) {
      freq = frq;
      ord = i + 1;
      return accum = docAcc;
    }
  }
  ord = limit;
  freq = frq;
  accum = docAcc;
  return NO_MORE_DOCS;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:Lucene40PostingsReader.java

示例12: nextUnreadDoc

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
protected final int nextUnreadDoc() throws IOException {
  int docAcc = accum;
  int frq = 1;
  final IndexInput freqIn = this.freqIn;
  final boolean omitTF = indexOmitsTF;
  final int loopLimit = limit;
  final Bits liveDocs = this.liveDocs;
  for (int i = ord; i < loopLimit; i++) {
    int code = freqIn.readVInt();
    if (omitTF) {
      docAcc += code;
    } else {
      docAcc += code >>> 1; // shift off low bit
      frq = readFreq(freqIn, code);
    }
    if (liveDocs.get(docAcc)) {
      freq = frq;
      ord = i + 1;
      return accum = docAcc;
    }
  }
  ord = limit;
  freq = frq;
  accum = docAcc;
  return NO_MORE_DOCS;
  
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:Lucene40PostingsReader.java

示例13: nextLiveDoc

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
private static int nextLiveDoc(int doc, Bits liveDocs, int maxDoc) {
  if (liveDocs == null) {
    return doc;
  }
  while (doc < maxDoc && !liveDocs.get(doc)) {
    ++doc;
  }
  return doc;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:CompressingTermVectorsWriter.java

示例14: score

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
@Override
public int score(LeafCollector collector, Bits acceptDocs, int min, int max) throws IOException {
    // TODO: figure out if min/max can be used to optimize this and still work correctly with pause/resume
    // and also check if twoPhaseIterator can be used
    collector.setScorer(scorer);
    for (int doc = iterator.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = iterator.nextDoc()) {
        if (acceptDocs == null || acceptDocs.get(doc)) {
            collector.collect(doc);
        }
    }
    return DocIdSetIterator.NO_MORE_DOCS;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:CrateDocCollector.java

示例15: checkNumericDocValues

import org.apache.lucene.util.Bits; //导入方法依赖的package包/类
private static void checkNumericDocValues(String fieldName, AtomicReader reader, NumericDocValues ndv, Bits docsWithField) {
  for (int i = 0; i < reader.maxDoc(); i++) {
    long value = ndv.get(i);
    if (docsWithField.get(i) == false && value != 0) {
      throw new RuntimeException("dv for field: " + fieldName + " is marked missing but has value=" + value + " for doc: " + i);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:CheckIndex.java


注:本文中的org.apache.lucene.util.Bits.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。