private OpenBitSetDISI initialResult(IndexReader reader, int logic, int[] index) { OpenBitSetDISI result; /** * First AND operation takes place against a completely false * bitset and will always return zero results. */ if (logic == AND) { result = new OpenBitSetDISI(getDISI(chain[index[0]], reader), reader.MaxDoc); ++index[0]; } else if (logic == ANDNOT) { result = new OpenBitSetDISI(getDISI(chain[index[0]], reader), reader.MaxDoc); result.Flip(0, reader.MaxDoc); // NOTE: may set bits for deleted docs. ++index[0]; } else { result = new OpenBitSetDISI(reader.MaxDoc); } return result; }
/// <summary> /// Get the id set for the filter. /// </summary> /// <param name="reader">The reader.</param> /// <returns>The filter set to use.</returns> public override DocIdSet GetDocIdSet(IndexReader reader) { OpenBitSetDISI res = null; if (shouldFilters != null) { for (int i = 0; i < shouldFilters.Count; i++) { if (res == null) { res = new OpenBitSetDISI(GetDISI(shouldFilters, i, reader), reader.MaxDoc()); } else { DocIdSet dis = ((Filter)shouldFilters[i]).GetDocIdSet(reader); if (dis is OpenBitSet) { // optimized case for OpenBitSets res.Or((OpenBitSet)dis); } else { res.InPlaceOr(GetDISI(shouldFilters, i, reader)); } } } } if (notFilters != null) { for (int i = 0; i < notFilters.Count; i++) { if (res == null) { res = new OpenBitSetDISI(GetDISI(notFilters, i, reader), reader.MaxDoc()); res.Flip(0, reader.MaxDoc()); // NOTE: may set bits on deleted docs } else { DocIdSet dis = ((Filter)notFilters[i]).GetDocIdSet(reader); if (dis is OpenBitSet) { // optimized case for OpenBitSets res.AndNot((OpenBitSet)dis); } else { res.InPlaceNot(GetDISI(notFilters, i, reader)); } } } } if (mustFilters != null) { for (int i = 0; i < mustFilters.Count; i++) { if (res == null) { res = new OpenBitSetDISI(GetDISI(mustFilters, i, reader), reader.MaxDoc()); } else { DocIdSet dis = ((Filter)mustFilters[i]).GetDocIdSet(reader); if (dis is OpenBitSet) { // optimized case for OpenBitSets res.And((OpenBitSet)dis); } else { res.InPlaceAnd(GetDISI(mustFilters, i, reader)); } } } } if (res != null) return FinalResult(res, reader.MaxDoc()); else { //TODO: 2.- change return DocIdSet.EMPTY_DOCIDSET; return null; } }