public void testEmptyTermsWithOrds() throws IOException { IncludeExclude inexcl = new IncludeExclude( new TreeSet<>(Collections.singleton(new BytesRef("foo"))), null); OrdinalsFilter filter = inexcl.convertToOrdinalsFilter(DocValueFormat.RAW); LongBitSet acceptedOrds = filter.acceptedGlobalOrdinals(DocValues.emptySortedSet()); assertEquals(0, acceptedOrds.length()); inexcl = new IncludeExclude( null, new TreeSet<>(Collections.singleton(new BytesRef("foo")))); filter = inexcl.convertToOrdinalsFilter(DocValueFormat.RAW); acceptedOrds = filter.acceptedGlobalOrdinals(DocValues.emptySortedSet()); assertEquals(0, acceptedOrds.length()); }
@Override public Scorer scorer(LeafReaderContext context) throws IOException { if (remaining == 0) { return null; } if (shortCircuitFilter != null) { DocIdSet docIdSet = shortCircuitFilter.getDocIdSet(context, null); if (!Lucene.isEmpty(docIdSet)) { DocIdSetIterator iterator = docIdSet.iterator(); if (iterator != null) { return ConstantScorer.create(iterator, this, queryWeight); } } return null; } DocIdSet parentDocIdSet = this.parentFilter.getDocIdSet(context, null); if (!Lucene.isEmpty(parentDocIdSet)) { // We can't be sure of the fact that liveDocs have been applied, so we apply it here. The "remaining" // count down (short circuit) logic will then work as expected. parentDocIdSet = BitsFilteredDocIdSet.wrap(parentDocIdSet, context.reader().getLiveDocs()); DocIdSetIterator innerIterator = parentDocIdSet.iterator(); if (innerIterator != null) { LongBitSet parentOrds = collector.parentOrds; SortedDocValues globalValues = globalIfd.load(context).getOrdinalsValues(parentType); if (globalValues != null) { DocIdSetIterator parentIdIterator = new ParentOrdIterator(innerIterator, parentOrds, globalValues, this); return ConstantScorer.create(parentIdIterator, this, queryWeight); } } } return null; }
void ensureCapacity(long bit) { impl = LongBitSet.ensureCapacity(impl, bit); }
private FilteredOrdinals(RandomAccessOrds inner, LongBitSet accepted) { this.inner = inner; this.accepted = accepted; }
public void testSingleTermWithOrds() throws IOException { RandomAccessOrds ords = new RandomAccessOrds() { boolean consumed = true; @Override public void setDocument(int docID) { consumed = false; } @Override public long nextOrd() { if (consumed) { return SortedSetDocValues.NO_MORE_ORDS; } else { consumed = true; return 0; } } @Override public BytesRef lookupOrd(long ord) { assertEquals(0, ord); return new BytesRef("foo"); } @Override public long getValueCount() { return 1; } @Override public long ordAt(int index) { return 0; } @Override public int cardinality() { return 1; } }; IncludeExclude inexcl = new IncludeExclude( new TreeSet<>(Collections.singleton(new BytesRef("foo"))), null); OrdinalsFilter filter = inexcl.convertToOrdinalsFilter(DocValueFormat.RAW); LongBitSet acceptedOrds = filter.acceptedGlobalOrdinals(ords); assertEquals(1, acceptedOrds.length()); assertTrue(acceptedOrds.get(0)); inexcl = new IncludeExclude( new TreeSet<>(Collections.singleton(new BytesRef("bar"))), null); filter = inexcl.convertToOrdinalsFilter(DocValueFormat.RAW); acceptedOrds = filter.acceptedGlobalOrdinals(ords); assertEquals(1, acceptedOrds.length()); assertFalse(acceptedOrds.get(0)); inexcl = new IncludeExclude( new TreeSet<>(Collections.singleton(new BytesRef("foo"))), new TreeSet<>(Collections.singleton(new BytesRef("foo")))); filter = inexcl.convertToOrdinalsFilter(DocValueFormat.RAW); acceptedOrds = filter.acceptedGlobalOrdinals(ords); assertEquals(1, acceptedOrds.length()); assertFalse(acceptedOrds.get(0)); inexcl = new IncludeExclude( null, // means everything included new TreeSet<>(Collections.singleton(new BytesRef("foo")))); filter = inexcl.convertToOrdinalsFilter(DocValueFormat.RAW); acceptedOrds = filter.acceptedGlobalOrdinals(ords); assertEquals(1, acceptedOrds.length()); assertFalse(acceptedOrds.get(0)); }
BitsFilteredTermsEnum(TermsEnum in, LongBitSet liveTerms) { super(in, false); // <-- not passing false here wasted about 3 hours of my time!!!!!!!!!!!!! assert liveTerms != null; this.liveTerms = liveTerms; }
ChildrenDocIdIterator(DocIdSetIterator innerIterator, LongBitSet parentOrds, SortedDocValues globalOrdinals) { super(innerIterator); this.parentOrds = parentOrds; this.globalOrdinals = globalOrdinals; }
ParentOrdsCollector(IndexParentChildFieldData globalIfd, long maxOrd, String parentType) { this.parentOrds = new LongBitSet(maxOrd); this.globalIfd = globalIfd; this.parentType = parentType; }
private ParentOrdCollector(IndexParentChildFieldData indexFieldData, long maxOrd, String parentType) { // TODO: look into reusing LongBitSet#bits array this.parentOrds = new LongBitSet(maxOrd + 1); this.indexFieldData = indexFieldData; this.parentType = parentType; }
private ParentOrdIterator(DocIdSetIterator innerIterator, LongBitSet parentOrds, SortedDocValues ordinals, ParentWeight parentWeight) { super(innerIterator); this.parentOrds = parentOrds; this.ordinals = ordinals; this.parentWeight = parentWeight; }
public BlockLocks(long numBits) { int length = LongBitSet.bits2words(numBits); bits = new AtomicLongArray(length); wlen = length; }
public abstract LongBitSet acceptedGlobalOrdinals(RandomAccessOrds globalOrdinals) throws IOException;
public abstract LongBitSet acceptedGlobalOrdinals(RandomAccessOrds globalOrdinals, ValuesSource.Bytes.WithOrdinals valueSource) throws IOException;