Exemplo n.º 1
0
        public virtual float ParseFloat(System.String val)
        {
            int shift = val[0] - NumericUtils.SHIFT_START_INT;

            if (shift > 0 && shift <= 31)
            {
                throw new FieldCacheImpl.StopFillCacheException();
            }
            return(NumericUtils.SortableIntToFloat(NumericUtils.PrefixCodedToInt(val)));
        }
Exemplo n.º 2
0
            public override DocIdSet GetDocIdSet(IndexReader reader)
            {
                // 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 = System.Convert.ToSingle(((System.ValueType)lowerVal));
                    if (!includeUpper && f > 0.0f && System.Single.IsInfinity(f))
                    {
                        return(DocIdSet.EMPTY_DOCIDSET);
                    }
                    int i = NumericUtils.FloatToSortableInt(f);
                    inclusiveLowerPoint = NumericUtils.SortableIntToFloat(includeLower?i:(i + 1));
                }
                else
                {
                    inclusiveLowerPoint = System.Single.NegativeInfinity;
                }
                if (upperVal != null)
                {
                    float f = System.Convert.ToSingle(((System.ValueType)upperVal));
                    if (!includeUpper && f < 0.0f && System.Single.IsInfinity(f))
                    {
                        return(DocIdSet.EMPTY_DOCIDSET);
                    }
                    int i = NumericUtils.FloatToSortableInt(f);
                    inclusiveUpperPoint = NumericUtils.SortableIntToFloat(includeUpper?i:(i - 1));
                }
                else
                {
                    inclusiveUpperPoint = System.Single.PositiveInfinity;
                }

                if (inclusiveLowerPoint > inclusiveUpperPoint)
                {
                    return(DocIdSet.EMPTY_DOCIDSET);
                }

                float[] values = Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT.GetFloats(reader, field, (Mono.Lucene.Net.Search.FloatParser)parser);
                // we only request the usage of termDocs, if the range contains 0
                return(new AnonymousClassFieldCacheDocIdSet(values, inclusiveLowerPoint, inclusiveUpperPoint, this, reader, (inclusiveLowerPoint <= 0.0f && inclusiveUpperPoint >= 0.0f)));
            }