Example usage for org.apache.lucene.util SparseFixedBitSet approximateCardinality

List of usage examples for org.apache.lucene.util SparseFixedBitSet approximateCardinality

Introduction

In this page you can find the example usage for org.apache.lucene.util SparseFixedBitSet approximateCardinality.

Prototype

@Override
    public int approximateCardinality() 

Source Link

Usage

From source file:org.elasticsearch.xpack.core.security.authz.accesscontrol.SecurityIndexSearcherWrapper.java

License:Open Source License

static void intersectScorerAndRoleBits(Scorer scorer, SparseFixedBitSet roleBits, LeafCollector collector,
        Bits acceptDocs) throws IOException {
    // ConjunctionDISI uses the DocIdSetIterator#cost() to order the iterators, so if roleBits has the lowest cardinality it should
    // be used first:
    DocIdSetIterator iterator = ConjunctionDISI.intersectIterators(
            Arrays.asList(new BitSetIterator(roleBits, roleBits.approximateCardinality()), scorer.iterator()));
    for (int docId = iterator.nextDoc(); docId < DocIdSetIterator.NO_MORE_DOCS; docId = iterator.nextDoc()) {
        if (acceptDocs == null || acceptDocs.get(docId)) {
            collector.collect(docId);// w ww. j  a  v  a 2  s. com
        }
    }
}