public override DocIdSet GetDocIdSet(AtomicReaderContext context, IBits acceptDocs) { // we transform the floating point numbers to sortable integers // using NumericUtils to easier find the next bigger/lower value float inclusiveLowerPoint; float inclusiveUpperPoint; if (lowerVal != null) { float f = (float)lowerVal; if (!includeUpper && f > 0.0f && float.IsInfinity(f)) { return(null); } int i = NumericUtils.SingleToSortableInt32(f); inclusiveLowerPoint = NumericUtils.SortableInt32ToSingle(includeLower ? i : (i + 1)); } else { inclusiveLowerPoint = float.NegativeInfinity; } if (upperVal != null) { float f = (float)upperVal; if (!includeUpper && f < 0.0f && float.IsInfinity(f)) { return(null); } int i = NumericUtils.SingleToSortableInt32(f); inclusiveUpperPoint = NumericUtils.SortableInt32ToSingle(includeUpper ? i : (i - 1)); } else { inclusiveUpperPoint = float.PositiveInfinity; } if (inclusiveLowerPoint > inclusiveUpperPoint) { return(null); } FieldCache.Singles values = FieldCache.DEFAULT.GetSingles(context.AtomicReader, field, (FieldCache.ISingleParser)parser, false); // we only request the usage of termDocs, if the range contains 0 return(new FieldCacheDocIdSet(context.Reader.MaxDoc, acceptDocs, (doc) => { float value = values.Get(doc); return value >= inclusiveLowerPoint && value <= inclusiveUpperPoint; })); }
protected internal override bool MatchDoc(int doc) { float value = values.Get(doc); return value >= inclusiveLowerPoint && value <= inclusiveUpperPoint; }