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


Java Bits类代码示例

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


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

示例1: getLeafCollector

import org.apache.lucene.util.Bits; //导入依赖的package包/类
@Override
public LeafBucketCollector getLeafCollector(LeafReaderContext ctx,
        final LeafBucketCollector sub) throws IOException {

    final Bits docsWithValue;
    if (valuesSource != null) {
        docsWithValue = valuesSource.docsWithValue(ctx);
    } else {
        docsWithValue = new Bits.MatchNoBits(ctx.reader().maxDoc());
    }
    return new LeafBucketCollectorBase(sub, docsWithValue) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            if (docsWithValue != null && !docsWithValue.get(doc)) {
                collectBucket(sub, doc, bucket);
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:MissingAggregator.java

示例2: 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 = new Bits[filters.length];
    for (int i = 0; i < filters.length; ++i) {
        bits[i] = Lucene.asSequentialAccessBits(ctx.reader().maxDoc(), filters[i].scorer(ctx));
    }
    return new LeafBucketCollectorBase(sub, null) {
        @Override
        public void collect(int doc, long bucket) throws IOException {
            boolean matched = false;
            for (int i = 0; i < bits.length; i++) {
                if (bits[i].get(doc)) {
                    collectBucket(sub, doc, bucketOrd(bucket, i));
                    matched = true;
                }
            }
            if (showOtherBucket && !matched) {
                collectBucket(sub, doc, bucketOrd(bucket, bits.length));
            }
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:FiltersAggregator.java

示例3: NearSpansOrdered

import org.apache.lucene.util.Bits; //导入依赖的package包/类
public NearSpansOrdered(SpanNearQuery spanNearQuery, AtomicReaderContext context, Bits acceptDocs, Map<Term,TermContext> termContexts, boolean collectPayloads)
throws IOException {
  if (spanNearQuery.getClauses().length < 2) {
    throw new IllegalArgumentException("Less than 2 clauses: "
                                       + spanNearQuery);
  }
  this.collectPayloads = collectPayloads;
  allowedSlop = spanNearQuery.getSlop();
  SpanQuery[] clauses = spanNearQuery.getClauses();
  subSpans = new Spans[clauses.length];
  matchPayload = new LinkedList<>();
  subSpansByDoc = new Spans[clauses.length];
  for (int i = 0; i < clauses.length; i++) {
    subSpans[i] = clauses[i].getSpans(context, acceptDocs, termContexts);
    subSpansByDoc[i] = subSpans[i]; // used in toSameDoc()
  }
  query = spanNearQuery; // kept for toString() only.
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:NearSpansOrdered.java

示例4: 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

示例5: getMissingBits

import org.apache.lucene.util.Bits; //导入依赖的package包/类
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));
          return (in.readByte() & (1 << (index & 7))) != 0;
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      @Override
      public int length() {
        return maxDoc;
      }
    };
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene45DocValuesProducer.java

示例6: getDocsWithField

import org.apache.lucene.util.Bits; //导入依赖的package包/类
@Override
public Bits getDocsWithField(FieldInfo field) throws IOException {
  switch(field.getDocValuesType()) {
    case SORTED_SET:
      return DocValues.docsWithValue(getSortedSet(field), maxDoc);
    case SORTED:
      return DocValues.docsWithValue(getSorted(field), maxDoc);
    case BINARY:
      BinaryEntry be = binaries.get(field.number);
      return getMissingBits(be.missingOffset);
    case NUMERIC:
      NumericEntry ne = numerics.get(field.number);
      return getMissingBits(ne.missingOffset);
    default:
      throw new AssertionError();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:Lucene45DocValuesProducer.java

示例7: getMissingBits

import org.apache.lucene.util.Bits; //导入依赖的package包/类
private Bits getMissingBits(final long offset) throws IOException {
  if (offset == -1) {
    return new Bits.MatchAllBits(maxDoc);
  } else {
    int length = (int) ((maxDoc + 7L) >>> 3);
    final RandomAccessInput in = data.randomAccessSlice(offset, length);
    return new Bits() {
      @Override
      public boolean get(int index) {
        try {
          return (in.readByte(index >> 3) & (1 << (index & 7))) != 0;
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      @Override
      public int length() {
        return maxDoc;
      }
    };
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:Lucene49DocValuesProducer.java

示例8: getDocsWithField

import org.apache.lucene.util.Bits; //导入依赖的package包/类
@Override
public Bits getDocsWithField(FieldInfo field) throws IOException {
  switch(field.getDocValuesType()) {
    case SORTED_SET:
      return DocValues.docsWithValue(getSortedSet(field), maxDoc);
    case SORTED_NUMERIC:
      return DocValues.docsWithValue(getSortedNumeric(field), maxDoc);
    case SORTED:
      return DocValues.docsWithValue(getSorted(field), maxDoc);
    case BINARY:
      BinaryEntry be = binaries.get(field.number);
      return getMissingBits(be.missingOffset);
    case NUMERIC:
      NumericEntry ne = numerics.get(field.number);
      return getMissingBits(ne.missingOffset);
    default:
      throw new AssertionError();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Lucene49DocValuesProducer.java

示例9: UnionDocsAndPositionsEnum

import org.apache.lucene.util.Bits; //导入依赖的package包/类
public UnionDocsAndPositionsEnum(Bits liveDocs, AtomicReaderContext context, Term[] terms, Map<Term,TermContext> termContexts, TermsEnum termsEnum) throws IOException {
  List<DocsAndPositionsEnum> docsEnums = new LinkedList<>();
  for (int i = 0; i < terms.length; i++) {
    final Term term = terms[i];
    TermState termState = termContexts.get(term).get(context.ord);
    if (termState == null) {
      // Term doesn't exist in reader
      continue;
    }
    termsEnum.seekExact(term.bytes(), termState);
    DocsAndPositionsEnum postings = termsEnum.docsAndPositions(liveDocs, null, DocsEnum.FLAG_NONE);
    if (postings == null) {
      // term does exist, but has no positions
      throw new IllegalStateException("field \"" + term.field() + "\" was indexed without position data; cannot run PhraseQuery (term=" + term.text() + ")");
    }
    cost += postings.cost();
    docsEnums.add(postings);
  }

  _queue = new DocsQueue(docsEnums);
  _posList = new IntQueue();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:MultiPhraseQuery.java

示例10: merge

import org.apache.lucene.util.Bits; //导入依赖的package包/类
/** Merges in the term vectors from the readers in 
 *  <code>mergeState</code>. The default implementation skips
 *  over deleted documents, and uses {@link #startDocument(int)},
 *  {@link #startField(FieldInfo, int, boolean, boolean, boolean)}, 
 *  {@link #startTerm(BytesRef, int)}, {@link #addPosition(int, int, int, BytesRef)},
 *  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 (int i = 0; i < mergeState.readers.size(); i++) {
    final AtomicReader reader = mergeState.readers.get(i);
    final int maxDoc = reader.maxDoc();
    final Bits liveDocs = reader.getLiveDocs();

    for (int docID = 0; docID < maxDoc; docID++) {
      if (liveDocs != null && !liveDocs.get(docID)) {
        // skip deleted docs
        continue;
      }
      // NOTE: it's very important to first assign to vectors then pass it to
      // termVectorsWriter.addAllDocVectors; see LUCENE-1282
      Fields vectors = reader.getTermVectors(docID);
      addAllDocVectors(vectors, mergeState);
      docCount++;
      mergeState.checkAbort.work(300);
    }
  }
  finish(mergeState.fieldInfos, docCount);
  return docCount;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:TermVectorsWriter.java

示例11: docsWithValue

import org.apache.lucene.util.Bits; //导入依赖的package包/类
@Override
public Bits docsWithValue(LeafReaderContext context) throws IOException {
    final SortedBinaryDocValues bytes = bytesValues(context);
    if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(bytes) != null) {
        return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(bytes);
    } else {
        return org.elasticsearch.index.fielddata.FieldData.docsWithValue(bytes, context.reader().maxDoc());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ValuesSource.java

示例12: bulkScorer

import org.apache.lucene.util.Bits; //导入依赖的package包/类
@Override
public BulkScorer bulkScorer(AtomicReaderContext context, boolean scoreDocsInOrder, Bits acceptDocs) throws IOException {
  final DocIdSetIterator disi;
  if (filter != null) {
    assert query == null;
    return super.bulkScorer(context, scoreDocsInOrder, acceptDocs);
  } else {
    assert query != null && innerWeight != null;
    BulkScorer bulkScorer = innerWeight.bulkScorer(context, scoreDocsInOrder, acceptDocs);
    if (bulkScorer == null) {
      return null;
    }
    return new ConstantBulkScorer(bulkScorer, this, queryWeight);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ConstantScoreQuery.java

示例13: docsWithValue

import org.apache.lucene.util.Bits; //导入依赖的package包/类
@Override
public Bits docsWithValue(LeafReaderContext context) {
    final MultiGeoPointValues geoPoints = geoPointValues(context);
    if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(geoPoints) != null) {
        return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(geoPoints);
    } else {
        return org.elasticsearch.index.fielddata.FieldData.docsWithValue(geoPoints, context.reader().maxDoc());
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:10,代码来源:ValuesSource.java

示例14: createWeight

import org.apache.lucene.util.Bits; //导入依赖的package包/类
@Override
public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
    return new RandomAccessWeight(this) {
        @Override
        protected Bits getMatchingDocs(final LeafReaderContext context) throws IOException {
            final LeafSearchScript leafScript = searchScript.getLeafSearchScript(context);
            return new Bits() {

                @Override
                public boolean get(int doc) {
                    leafScript.setDocument(doc);
                    Object val = leafScript.run();
                    if (val == null) {
                        return false;
                    }
                    if (val instanceof Boolean) {
                        return (Boolean) val;
                    }
                    if (val instanceof Number) {
                        return ((Number) val).longValue() != 0;
                    }
                    throw new IllegalArgumentException("Can't handle type [" + val + "] in script filter");
                }

                @Override
                public int length() {
                    return context.reader().maxDoc();
                }

            };
        }
    };
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:ScriptQueryBuilder.java

示例15: getReadOnlyLiveDocs

import org.apache.lucene.util.Bits; //导入依赖的package包/类
public synchronized Bits getReadOnlyLiveDocs() {
  //System.out.println("getROLiveDocs seg=" + info);
  assert Thread.holdsLock(writer);
  liveDocsShared = true;
  //if (liveDocs != null) {
  //System.out.println("  liveCount=" + liveDocs.count());
  //}
  return liveDocs;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:ReadersAndUpdates.java


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