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

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

Introduction

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

Prototype

public static int bits2words(int numBits) 

Source Link

Document

returns the number of 64 bit words it would take to hold numBits

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;/*  www.j a va  2s.  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;
}