public override void MatchEvent( EventBean theEvent, ICollection<FilterHandle> matches, ExprEvaluatorContext ctx) { object attributeValue = Lookupable.Eval.Eval(theEvent, ctx); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QFilterReverseIndex(this, attributeValue); } EventEvaluator evaluator = null; using (ConstantsMapRwLock.ReadLock.Acquire()) { evaluator = ConstantsMap.Get(attributeValue); } // No listener found for the value, return if (evaluator == null) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AFilterReverseIndex(false); } return; } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AFilterReverseIndex(true); } evaluator.MatchEvent(theEvent, matches, ctx); }
public override void MatchEvent(EventBean theEvent, ICollection <FilterHandle> matches) { var attributeValue = Lookupable.Getter.Get(theEvent); var returnValue = new Mutable <bool>(false); using (Instrument.With( i => i.QFilterReverseIndex(this, attributeValue), i => i.AFilterReverseIndex(returnValue.Value))) { EventEvaluator evaluator = null; using (ConstantsMapRwLock.AcquireReadLock()) { evaluator = ConstantsMap.Get(attributeValue); } // No listener found for the value, return if (evaluator == null) { returnValue.Value = false; } else { evaluator.MatchEvent(theEvent, matches); returnValue.Value = true; } } }
public override void MatchEvent( EventBean theEvent, ICollection <FilterHandle> matches, ExprEvaluatorContext ctx) { if (eventEvaluator == null) { return; } EventBean[] events = new EventBean[] { theEvent }; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QFilterReverseIndex(this, null); } var result = Lookupable.Expr.Evaluate(events, true, ctx).AsBoxedBoolean(); if (result != null && result.Value) { eventEvaluator.MatchEvent(theEvent, matches, ctx); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AFilterReverseIndex(result); } }
public override void MatchEvent(EventBean theEvent, ICollection <FilterHandle> matches) { var propertyValue = Lookupable.Getter.Get(theEvent); var returnValue = new Mutable <bool?>(false); using (Instrument.With( i => i.QFilterReverseIndex(this, propertyValue), i => i.AFilterReverseIndex(returnValue.Value))) { if (propertyValue == null) { return; } // A undefine lower bound indicates an empty index if (_lowerBounds == null) { return; } var filterOperator = FilterOperator; var propertyValueDouble = propertyValue.AsDouble(); // Based on current lower and upper bounds check if the property value falls outside - shortcut submap generation if ((filterOperator == FilterOperator.GREATER) && (propertyValueDouble <= _lowerBounds)) { return; } else if ((filterOperator == FilterOperator.GREATER_OR_EQUAL) && (propertyValueDouble < _lowerBounds)) { return; } else if ((filterOperator == FilterOperator.LESS) && (propertyValueDouble >= _upperBounds)) { return; } else if ((filterOperator == FilterOperator.LESS_OR_EQUAL) && (propertyValueDouble > _upperBounds)) { return; } // Look up in table using (_constantsMapRwLock.AcquireReadLock()) { // Get the head or tail end of the map depending on comparison type IDictionary <Object, EventEvaluator> subMap; if ((filterOperator == FilterOperator.GREATER) || (filterOperator == FilterOperator.GREATER_OR_EQUAL)) { // At the head of the map are those with a lower numeric constants subMap = _constantsMap.Head(propertyValue); } else { subMap = _constantsMap.Tail(propertyValue); } // All entries in the subMap are elgibile, with an exception EventEvaluator exactEquals = null; if (filterOperator == FilterOperator.LESS) { exactEquals = _constantsMap.Get(propertyValue); } foreach (EventEvaluator matcher in subMap.Values) { // For the LESS comparison type we ignore the exactly equal case // The subMap is sorted ascending, thus the exactly equals case is the first if (exactEquals != null) { exactEquals = null; continue; } matcher.MatchEvent(theEvent, matches); } if (filterOperator == FilterOperator.GREATER_OR_EQUAL) { EventEvaluator matcher = _constantsMap.Get(propertyValue); if (matcher != null) { matcher.MatchEvent(theEvent, matches); } } } returnValue.Value = null; } }