@Test public void testFullySetDocIdSet() throws IOException { int len = 10; DocIdSet docIdSet = BitSetDocumentVisibilityFilterCacheStrategy.getFullySetDocIdSet(len); Bits bits = docIdSet.bits(); assertEquals(len, bits.length()); for (int i = 0; i < len; i++) { assertTrue(bits.get(i)); } assertTrue(docIdSet.isCacheable()); { DocIdSetIterator iterator = docIdSet.iterator(); int adoc; int edoc = 0; assertEquals(-1, iterator.docID()); while ((adoc = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { assertEquals(edoc, adoc); assertEquals(edoc, iterator.docID()); edoc++; } assertEquals(len, edoc); } { DocIdSetIterator iterator = docIdSet.iterator(); int adoc; int edoc = 0; assertEquals(-1, iterator.docID()); while ((adoc = iterator.advance(edoc)) != DocIdSetIterator.NO_MORE_DOCS) { assertEquals(edoc, adoc); assertEquals(edoc, iterator.docID()); edoc++; } assertEquals(len, edoc); } }
public static DocIdSet getFullySetDocIdSet(int maxDoc) { Bits bits = getFullySetBits(maxDoc); return new DocIdSet() { @Override public DocIdSetIterator iterator() throws IOException { return getFullySetDocIdSetIterator(maxDoc); } @Override public Bits bits() throws IOException { return bits; } @Override public boolean isCacheable() { return true; } }; }
BitSetDocumentVisibilityFilterCacheStrategy extends DocumentVisibilityFilterCacheStrategy { public static DocIdSet getFullySetDocIdSet(int maxDoc) { Bits bits = getFullySetBits(maxDoc); return new DocIdSet() { @Override public DocIdSetIterator iterator() throws IOException { return getFullySetDocIdSetIterator(maxDoc); } @Override public Bits bits() throws IOException { return bits; } @Override public boolean isCacheable() { return true; } }; } }
BitSetDocumentVisibilityFilterCacheStrategy extends DocumentVisibilityFilterCacheStrategy { public static DocIdSet getFullySetDocIdSet(int maxDoc) { Bits bits = getFullySetBits(maxDoc); return new DocIdSet() { @Override public DocIdSetIterator iterator() throws IOException { return getFullySetDocIdSetIterator(maxDoc); } @Override public Bits bits() throws IOException { return bits; } @Override public boolean isCacheable() { return true; } }; } BitSetDocumentVisibilityFilterCacheStrategy(); }
BitSetDocumentVisibilityFilterCacheStrategy extends DocumentVisibilityFilterCacheStrategy { public static DocIdSet getFullySetDocIdSet(int maxDoc) { Bits bits = getFullySetBits(maxDoc); return new DocIdSet() { @Override public DocIdSetIterator iterator() throws IOException { return getFullySetDocIdSetIterator(maxDoc); } @Override public Bits bits() throws IOException { return bits; } @Override public boolean isCacheable() { return true; } }; } BitSetDocumentVisibilityFilterCacheStrategy(); @Override DocIdSet getDocIdSet(String fieldName, BytesRef term, AtomicReader reader); @Override Builder createBuilder(String fieldName, BytesRef term, final AtomicReader reader); static DocIdSet getFullyEmptyDocIdSet(int maxDoc); static DocIdSetIterator getFullyEmptyDocIdSetIterator(int maxDoc); static Bits getFullyEmptyBits(int maxDoc); static DocIdSet getFullySetDocIdSet(int maxDoc); static DocIdSetIterator getFullySetDocIdSetIterator(int maxDoc); static Bits getFullySetBits(int maxDoc); static boolean isFullyEmpty(OpenBitSet bitSet, long cardinality); static boolean isFullySet(int maxDoc, OpenBitSet bitSet, long cardinality); static SegmentReader getSegmentReader(IndexReader indexReader); @Override String toString(); }
BitSetDocumentVisibilityFilterCacheStrategy extends DocumentVisibilityFilterCacheStrategy { public static DocIdSet getFullySetDocIdSet(int maxDoc) { Bits bits = getFullySetBits(maxDoc); return new DocIdSet() { @Override public DocIdSetIterator iterator() throws IOException { return getFullySetDocIdSetIterator(maxDoc); } @Override public Bits bits() throws IOException { return bits; } @Override public boolean isCacheable() { return true; } }; } BitSetDocumentVisibilityFilterCacheStrategy(); @Override DocIdSet getDocIdSet(String fieldName, BytesRef term, AtomicReader reader); @Override Builder createBuilder(String fieldName, BytesRef term, final AtomicReader reader); static DocIdSet getFullyEmptyDocIdSet(int maxDoc); static DocIdSetIterator getFullyEmptyDocIdSetIterator(int maxDoc); static Bits getFullyEmptyBits(int maxDoc); static DocIdSet getFullySetDocIdSet(int maxDoc); static DocIdSetIterator getFullySetDocIdSetIterator(int maxDoc); static Bits getFullySetBits(int maxDoc); static boolean isFullyEmpty(OpenBitSet bitSet, long cardinality); static boolean isFullySet(int maxDoc, OpenBitSet bitSet, long cardinality); static SegmentReader getSegmentReader(IndexReader indexReader); @Override String toString(); static final DocumentVisibilityFilterCacheStrategy INSTANCE; }