internal NumericRangeTermsEnum(NumericRangeQuery <T> outerInstance, TermsEnum tenum) : base(tenum) { this.outerInstance = outerInstance; switch (this.outerInstance.dataType) { case NumericType.INT64: case NumericType.DOUBLE: { // lower long minBound; if (this.outerInstance.dataType == NumericType.INT64) { minBound = (this.outerInstance.min == null) ? long.MinValue : Convert.ToInt64(this.outerInstance.min.Value, CultureInfo.InvariantCulture); } else { Debug.Assert(this.outerInstance.dataType == NumericType.DOUBLE); minBound = (this.outerInstance.min == null) ? INT64_NEGATIVE_INFINITY : NumericUtils.DoubleToSortableInt64(Convert.ToDouble(this.outerInstance.min.Value, CultureInfo.InvariantCulture)); } if (!this.outerInstance.minInclusive && this.outerInstance.min != null) { if (minBound == long.MaxValue) { break; } minBound++; } // upper long maxBound; if (this.outerInstance.dataType == NumericType.INT64) { maxBound = (this.outerInstance.max == null) ? long.MaxValue : Convert.ToInt64(this.outerInstance.max, CultureInfo.InvariantCulture); } else { Debug.Assert(this.outerInstance.dataType == NumericType.DOUBLE); maxBound = (this.outerInstance.max == null) ? INT64_POSITIVE_INFINITY : NumericUtils.DoubleToSortableInt64(Convert.ToDouble(this.outerInstance.max, CultureInfo.InvariantCulture)); } if (!this.outerInstance.maxInclusive && this.outerInstance.max != null) { if (maxBound == long.MinValue) { break; } maxBound--; } NumericUtils.SplitInt64Range(new Int64RangeBuilderAnonymousInnerClassHelper(this), this.outerInstance.precisionStep, minBound, maxBound); break; } case NumericType.INT32: case NumericType.SINGLE: { // lower int minBound; if (this.outerInstance.dataType == NumericType.INT32) { minBound = (this.outerInstance.min == null) ? int.MinValue : Convert.ToInt32(this.outerInstance.min, CultureInfo.InvariantCulture); } else { Debug.Assert(this.outerInstance.dataType == NumericType.SINGLE); minBound = (this.outerInstance.min == null) ? INT32_NEGATIVE_INFINITY : NumericUtils.SingleToSortableInt32(Convert.ToSingle(this.outerInstance.min, CultureInfo.InvariantCulture)); } if (!this.outerInstance.minInclusive && this.outerInstance.min != null) { if (minBound == int.MaxValue) { break; } minBound++; } // upper int maxBound; if (this.outerInstance.dataType == NumericType.INT32) { maxBound = (this.outerInstance.max == null) ? int.MaxValue : Convert.ToInt32(this.outerInstance.max, CultureInfo.InvariantCulture); } else { Debug.Assert(this.outerInstance.dataType == NumericType.SINGLE); maxBound = (this.outerInstance.max == null) ? INT32_POSITIVE_INFINITY : NumericUtils.SingleToSortableInt32(Convert.ToSingle(this.outerInstance.max, CultureInfo.InvariantCulture)); } if (!this.outerInstance.maxInclusive && this.outerInstance.max != null) { if (maxBound == int.MinValue) { break; } maxBound--; } NumericUtils.SplitInt32Range(new Int32RangeBuilderAnonymousInnerClassHelper(this), this.outerInstance.precisionStep, minBound, maxBound); break; } default: // should never happen throw new System.ArgumentException("Invalid NumericType"); } termComp = Comparer; }
internal NumericRangeTermsEnum(NumericRangeQuery <T> outerInstance, TermsEnum tenum) : base(tenum) { this.outerInstance = outerInstance; switch (this.outerInstance.dataType) { case NumericType.INT64: case NumericType.DOUBLE: { // lower long minBound; if (this.outerInstance.dataType == NumericType.INT64) { minBound = (!this.outerInstance.min.HasValue) ? long.MinValue : CastTo <long> .From(this.outerInstance.min.Value); } else { if (Debugging.AssertsEnabled) { Debugging.Assert(this.outerInstance.dataType == NumericType.DOUBLE); } minBound = (!this.outerInstance.min.HasValue) ? INT64_NEGATIVE_INFINITY : NumericUtils.DoubleToSortableInt64(CastTo <double> .From(this.outerInstance.min.Value)); } if (!this.outerInstance.minInclusive && this.outerInstance.min != null) { if (minBound == long.MaxValue) { break; } minBound++; } // upper long maxBound; if (this.outerInstance.dataType == NumericType.INT64) { maxBound = (!this.outerInstance.max.HasValue) ? long.MaxValue : CastTo <long> .From(this.outerInstance.max.Value); } else { if (Debugging.AssertsEnabled) { Debugging.Assert(this.outerInstance.dataType == NumericType.DOUBLE); } maxBound = (!this.outerInstance.max.HasValue) ? INT64_POSITIVE_INFINITY : NumericUtils.DoubleToSortableInt64(CastTo <double> .From(this.outerInstance.max.Value)); } if (!this.outerInstance.maxInclusive && this.outerInstance.max != null) { if (maxBound == long.MinValue) { break; } maxBound--; } NumericUtils.SplitInt64Range(new Int64RangeBuilderAnonymousClass(this), this.outerInstance.precisionStep, minBound, maxBound); break; } case NumericType.INT32: case NumericType.SINGLE: { // lower int minBound; if (this.outerInstance.dataType == NumericType.INT32) { minBound = (!this.outerInstance.min.HasValue) ? int.MinValue : CastTo <int> .From(this.outerInstance.min.Value); } else { if (Debugging.AssertsEnabled) { Debugging.Assert(this.outerInstance.dataType == NumericType.SINGLE); } minBound = (!this.outerInstance.min.HasValue) ? INT32_NEGATIVE_INFINITY : NumericUtils.SingleToSortableInt32(CastTo <float> .From(this.outerInstance.min.Value)); } if (!this.outerInstance.minInclusive && this.outerInstance.min != null) { if (minBound == int.MaxValue) { break; } minBound++; } // upper int maxBound; if (this.outerInstance.dataType == NumericType.INT32) { maxBound = (!this.outerInstance.max.HasValue) ? int.MaxValue : CastTo <int> .From(this.outerInstance.max.Value); } else { if (Debugging.AssertsEnabled) { Debugging.Assert(this.outerInstance.dataType == NumericType.SINGLE); } maxBound = (!this.outerInstance.max.HasValue) ? INT32_POSITIVE_INFINITY : NumericUtils.SingleToSortableInt32(CastTo <float> .From(this.outerInstance.max.Value)); } if (!this.outerInstance.maxInclusive && this.outerInstance.max != null) { if (maxBound == int.MinValue) { break; } maxBound--; } NumericUtils.SplitInt32Range(new Int32RangeBuilderAnonymousClass(this), this.outerInstance.precisionStep, minBound, maxBound); break; } default: // should never happen throw new ArgumentException("Invalid NumericType"); } termComp = Comparer; }
internal NumericRangeFilter(NumericRangeQuery <T> query) : base(query) { }