public override void MatchEvent( EventBean theEvent, ICollection<FilterHandle> matches, ExprEvaluatorContext ctx) { var objAttributeValue = Lookupable.Eval.Eval(theEvent, ctx); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QFilterReverseIndex(this, objAttributeValue); } if (objAttributeValue == null) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AFilterReverseIndex(false); } return; } var attributeValue = objAttributeValue.AsDouble(); var rangeStart = new DoubleRange(attributeValue - LargestRangeValueDouble, attributeValue); var rangeEnd = new DoubleRange(attributeValue, double.MaxValue); var subMap = Ranges.Between(rangeStart, true, rangeEnd, true); // For not including either endpoint // A bit awkward to duplicate the loop code, however better than checking the boolean many times over // This may be a bit of an early performance optimization - the optimizer after all may do this better if (FilterOperator == FilterOperator.RANGE_OPEN) { // include neither endpoint foreach (KeyValuePair<DoubleRange, EventEvaluator> entry in subMap) { if (attributeValue > entry.Key.Min && attributeValue < entry.Key.Max) { entry.Value.MatchEvent(theEvent, matches, ctx); } } } else if (FilterOperator == FilterOperator.RANGE_CLOSED) { // include all endpoints foreach (KeyValuePair<DoubleRange, EventEvaluator> entry in subMap) { if (attributeValue >= entry.Key.Min && attributeValue <= entry.Key.Max) { entry.Value.MatchEvent(theEvent, matches, ctx); } } } else if (FilterOperator == FilterOperator.RANGE_HALF_CLOSED) { // include high endpoint not low endpoint foreach (KeyValuePair<DoubleRange, EventEvaluator> entry in subMap) { if (attributeValue > entry.Key.Min && attributeValue <= entry.Key.Max) { entry.Value.MatchEvent(theEvent, matches, ctx); } } } else if (FilterOperator == FilterOperator.RANGE_HALF_OPEN) { // include low endpoint not high endpoint foreach (KeyValuePair<DoubleRange, EventEvaluator> entry in subMap) { if (attributeValue >= entry.Key.Min && attributeValue < entry.Key.Max) { entry.Value.MatchEvent(theEvent, matches, ctx); } } } else { throw new IllegalStateException("Invalid filter operator " + FilterOperator); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AFilterReverseIndex(null); } }
public override void MatchEvent(EventBean theEvent, ICollection <FilterHandle> matches) { var objAttributeValue = Lookupable.Getter.Get(theEvent); var returnValue = new Mutable <bool?>(false); using (Instrument.With( i => i.QFilterReverseIndex(this, objAttributeValue), i => i.AFilterReverseIndex(returnValue.Value))) { if (objAttributeValue == null) { return; } var attributeValue = objAttributeValue.AsDouble(); var rangeStart = new DoubleRange(attributeValue - LargestRangeValueDouble, attributeValue); var rangeEnd = new DoubleRange(attributeValue, Double.MaxValue); var subMap = Ranges.Between(rangeStart, true, rangeEnd, true); // For not including either endpoint // A bit awkward to duplicate the loop code, however better than checking the bool many times over // This may be a bit of an early performance optimization - the optimizer after all may do this better if (FilterOperator == FilterOperator.RANGE_OPEN) // include neither endpoint { foreach (var entry in subMap) { if ((attributeValue > entry.Key.Min) && (attributeValue < entry.Key.Max)) { entry.Value.MatchEvent(theEvent, matches); } } } else if (FilterOperator == FilterOperator.RANGE_CLOSED) // include all endpoints { foreach (var entry in subMap) { if ((attributeValue >= entry.Key.Min) && (attributeValue <= entry.Key.Max)) { entry.Value.MatchEvent(theEvent, matches); } } } else if (FilterOperator == FilterOperator.RANGE_HALF_CLOSED) // include high endpoint not low endpoint { foreach (var entry in subMap) { if ((attributeValue > entry.Key.Min) && (attributeValue <= entry.Key.Max)) { entry.Value.MatchEvent(theEvent, matches); } } } else if (FilterOperator == FilterOperator.RANGE_HALF_OPEN) // include low endpoint not high endpoint { foreach (var entry in subMap) { if ((attributeValue >= entry.Key.Min) && (attributeValue < entry.Key.Max)) { entry.Value.MatchEvent(theEvent, matches); } } } else { throw new IllegalStateException("Invalid filter operator " + FilterOperator); } returnValue.Value = null; } }