Example usage for org.apache.lucene.search DocIdSetIterator all

List of usage examples for org.apache.lucene.search DocIdSetIterator all

Introduction

In this page you can find the example usage for org.apache.lucene.search DocIdSetIterator all.

Prototype

public static final DocIdSetIterator all(int maxDoc) 

Source Link

Document

A DocIdSetIterator that matches all documents up to maxDoc - 1 .

Usage

From source file:org.vootoo.search.function.ValueSourceCollectorFilter.java

License:Apache License

@Override
public DocIdSet getDocIdSet(@SuppressWarnings("rawtypes") final Map context,
        final LeafReaderContext readerContext, Bits acceptDocs) throws IOException {
    collectorFilterable.doSetNextReader(context, readerContext);
    //TODO  check getDocIdSet use
    return BitsFilteredDocIdSet.wrap(new DocIdSet() {
        @Override/* w  w w .  j  a  v a 2s . co m*/
        public long ramBytesUsed() {
            return 0;
        }

        @Override
        public DocIdSetIterator iterator() throws IOException {
            final DocIdSetIterator approximation = DocIdSetIterator.all(readerContext.reader().maxDoc()); // no approximation!
            TwoPhaseIterator twoPhaseIterator = new TwoPhaseIterator(approximation) {
                @Override
                public boolean matches() throws IOException {
                    return collectorFilterable.matches(approximation.docID());
                }

                @Override
                public float matchCost() {
                    return 100; // TODO: use cost of ValueSourceScorer.this.matches()
                }
            };
            return TwoPhaseIterator.asDocIdSetIterator(twoPhaseIterator);
        }

        @Override
        public Bits bits() {
            return null; // don't use random access
        }
    }, acceptDocs);
}