예제 #1
0
 private void  InitBlock(NumericRangeQuery <T> enclosingInstance)
 {
     this.enclosingInstance = enclosingInstance;
     termTemplate           = new Term(Enclosing_Instance.field);
 }
예제 #2
0
            internal NumericRangeTermEnum(NumericRangeQuery <T> enclosingInstance, IndexReader reader)
            {
                InitBlock(enclosingInstance);
                this.reader = reader;

                Type rangeType = Nullable.GetUnderlyingType(typeof(T?));

                switch (Enclosing_Instance.valSize)
                {
                case 64:  {
                    // lower
                    long minBound = System.Int64.MinValue;
                    if (rangeType == typeof(System.Int64))
                    {
                        // added in these checks to emulate java.  passing null give it no type (in old code),
                        // but .net can identifies it with generics and sets the bounds to 0, causing tests to fail
                        if (Enclosing_Instance.min != null)
                        {
                            minBound = System.Convert.ToInt64(Enclosing_Instance.min);
                        }
                    }
                    else if (rangeType == typeof(System.Double))
                    {
                        if (Enclosing_Instance.min != null)
                        {
                            minBound = NumericUtils.DoubleToSortableLong(System.Convert.ToDouble(Enclosing_Instance.min));
                        }
                    }
                    if (!Enclosing_Instance.minInclusive && Enclosing_Instance.min != null)
                    {
                        if (minBound == System.Int64.MaxValue)
                        {
                            break;
                        }
                        minBound++;
                    }

                    // upper
                    long maxBound = System.Int64.MaxValue;
                    if (rangeType == typeof(System.Int64))
                    {
                        if (Enclosing_Instance.max != null)
                        {
                            maxBound = System.Convert.ToInt64(Enclosing_Instance.max);
                        }
                    }
                    else if (rangeType == typeof(System.Double))
                    {
                        if (Enclosing_Instance.max != null)
                        {
                            maxBound = NumericUtils.DoubleToSortableLong(System.Convert.ToDouble(Enclosing_Instance.max));
                        }
                    }
                    if (!Enclosing_Instance.maxInclusive && Enclosing_Instance.max != null)
                    {
                        if (maxBound == System.Int64.MinValue)
                        {
                            break;
                        }
                        maxBound--;
                    }

                    NumericUtils.SplitLongRange(new AnonymousClassLongRangeBuilder(this), Enclosing_Instance.precisionStep, minBound, maxBound);
                    break;
                }


                case 32:  {
                    // lower
                    int minBound = System.Int32.MinValue;
                    if (rangeType == typeof(System.Int32))
                    {
                        if (Enclosing_Instance.min != null)
                        {
                            minBound = System.Convert.ToInt32(Enclosing_Instance.min);
                        }
                    }
                    else if (rangeType == typeof(System.Single))
                    {
                        if (Enclosing_Instance.min != null)
                        {
                            minBound = NumericUtils.FloatToSortableInt(System.Convert.ToSingle(Enclosing_Instance.min));
                        }
                    }
                    if (!Enclosing_Instance.minInclusive && Enclosing_Instance.min != null)
                    {
                        if (minBound == System.Int32.MaxValue)
                        {
                            break;
                        }
                        minBound++;
                    }

                    // upper
                    int maxBound = System.Int32.MaxValue;
                    if (rangeType == typeof(System.Int32))
                    {
                        if (Enclosing_Instance.max != null)
                        {
                            maxBound = System.Convert.ToInt32(Enclosing_Instance.max);
                        }
                    }
                    else if (rangeType == typeof(System.Single))
                    {
                        if (Enclosing_Instance.max != null)
                        {
                            maxBound = NumericUtils.FloatToSortableInt(System.Convert.ToSingle(Enclosing_Instance.max));
                        }
                    }
                    if (!Enclosing_Instance.maxInclusive && Enclosing_Instance.max != null)
                    {
                        if (maxBound == System.Int32.MinValue)
                        {
                            break;
                        }
                        maxBound--;
                    }

                    NumericUtils.SplitIntRange(new AnonymousClassIntRangeBuilder(this), Enclosing_Instance.precisionStep, minBound, maxBound);
                    break;
                }


                default:
                    // should never happen
                    throw new System.ArgumentException("valSize must be 32 or 64");
                }

                // seek to first term
                Next();
            }
예제 #3
0
 internal NumericRangeFilter(NumericRangeQuery <T> query)
     : base(query)
 {
 }