Example usage for org.apache.lucene.util FixedBitSet FixedBitSet

List of usage examples for org.apache.lucene.util FixedBitSet FixedBitSet

Introduction

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

Prototype

public FixedBitSet(long[] storedBits, int numBits) 

Source Link

Document

Creates a new LongBitSet using the provided long[] array as backing store.

Usage

From source file:org.apache.solr.search.DocSetUtil.java

License:Apache License

private static DocSet createBigSet(List<LeafReaderContext> leaves, PostingsEnum[] postList, int maxDoc,
        int firstReader) throws IOException {
    long[] bits = new long[FixedBitSet.bits2words(maxDoc)];
    int sz = 0;/*from   w  w  w. j  av a 2  s.  com*/
    for (int i = firstReader; i < postList.length; i++) {
        PostingsEnum postings = postList[i];
        if (postings == null)
            continue;
        LeafReaderContext ctx = leaves.get(i);
        Bits liveDocs = ctx.reader().getLiveDocs();
        int base = ctx.docBase;
        for (;;) {
            int subId = postings.nextDoc();
            if (subId == DocIdSetIterator.NO_MORE_DOCS)
                break;
            if (liveDocs != null && !liveDocs.get(subId))
                continue;
            int globalId = subId + base;
            bits[globalId >> 6] |= (1L << globalId);
            sz++;
        }
    }

    BitDocSet docSet = new BitDocSet(new FixedBitSet(bits, maxDoc), sz);

    int smallSetSize = smallSetSize(maxDoc);
    if (sz < smallSetSize) {
        // make this optional?
        DocSet smallSet = toSmallSet(docSet);
        // assert equals(docSet, smallSet);
        return smallSet;
    }

    return docSet;
}