Example #1
0
 protected FilterSpecParam(
     ExprFilterSpecLookupable lookupable,
     FilterOperator filterOperator)
 {
     this.lkupable = lookupable;
     FilterOperator = filterOperator;
 }
Example #2
0
 public ProxyFilterSpecParam(
     ExprFilterSpecLookupable lkupable,
     FilterOperator filterOperator,
     GetFilterValueFunc getFilterValueFunc) : base(lkupable, filterOperator)
 {
     ProcGetFilterValue = getFilterValueFunc;
 }
Example #3
0
 /// <summary>Constructor. </summary>
 /// <param name="filterOperator">is the type of comparison performed.</param>
 /// <param name="lookupable">is the lookupable</param>
 protected FilterParamIndexLookupableBase(
     FilterOperator filterOperator,
     ExprFilterSpecLookupable lookupable)
     : base(filterOperator)
 {
     Lookupable = lookupable;
 }
 public ProxyFilterSpecParamExprNode(
     GetFilterValueFunc getFilterValue,
     ExprFilterSpecLookupable lkupable,
     FilterOperator filterOperator) : base(lkupable, filterOperator)
 {
     ProcGetFilterValue = getFilterValue;
 }
Example #5
0
 public void RegisterLookupable(
     int statementId,
     EventType eventType,
     ExprFilterSpecLookupable lookupable)
 {
     // not required
 }
 internal FilterParamIndexReboolNoValue(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(FilterOperator.REBOOL, lookupable)
 {
     constantsMapRWLock = readWriteLock;
 }
        public override FilterValueSetParam GetFilterValue(
            MatchedEventMap matchedEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            StatementContextFilterEvalEnv filterEvalEnv)
        {
            ExprFilterSpecLookupable lookupable = this.Lkupable.Make(matchedEvents, exprEvaluatorContext);

            return(new FilterValueSetParamImpl(lookupable, FilterOperator, FilterConstant));
        }
 protected FilterParamIndexNotEqualsBase(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock,
     FilterOperator filterOperator)
     : base(filterOperator, lookupable)
 {
     ConstantsMap       = new Dictionary <object, EventEvaluator>().WithNullKeySupport();
     ConstantsMapRwLock = readWriteLock;
 }
 private static FilterValueSetParam GetFilterMayEqualOrNull(
     ExprFilterSpecLookupable lookupable,
     object keyValue)
 {
     if (keyValue != null && keyValue.GetType().IsArray) {
         keyValue = MultiKeyPlanner.ToMultiKey(keyValue);
     }
     return new FilterValueSetParamImpl(lookupable, FilterOperator.IS, keyValue);
 }
 protected FilterParamIndexStringRangeBase(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock,
     FilterOperator filterOperator)
     : base(filterOperator, lookupable)
 {
     Ranges        = new OrderedListDictionary <StringRange, EventEvaluator>(new StringRangeComparator());
     ReadWriteLock = readWriteLock;
 }
Example #11
0
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="lookupable">stuff to use to interrogate</param>
 /// <param name="filterOperator">operator to apply</param>
 /// <param name="filterValue">value to look for</param>
 public FilterValueSetParamImpl(
     ExprFilterSpecLookupable lookupable,
     FilterOperator filterOperator,
     object filterValue)
 {
     Lookupable = lookupable;
     FilterOperator = filterOperator;
     FilterForValue = filterValue;
 }
Example #12
0
 public FilterParamIndexIn(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(FilterOperator.IN_LIST_OF_VALUES, lookupable)
 {
     constantsMap = new HashMap<object, IList<EventEvaluator>>();
     evaluatorsMap = new HashMap<HashableMultiKey, EventEvaluator>();
     constantsMapRWLock = readWriteLock;
 }
Example #13
0
 public FilterParamIndexNotIn(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(FilterOperator.NOT_IN_LIST_OF_VALUES, lookupable)
 {
     constantsMap = new HashMap<object, ISet<EventEvaluator>>();
     filterValueEvaluators = new HashMap<HashableMultiKey, EventEvaluator>();
     evaluatorsSet = new HashSet<EventEvaluator>();
     ReadWriteLock = readWriteLock;
 }
 public FilterParamIndexDoubleRange(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock,
     FilterOperator filterOperator)
     : base(lookupable, readWriteLock, filterOperator)
 {
     if (!filterOperator.IsRangeOperator()) {
         throw new ArgumentException("Invalid filter operator " + filterOperator);
     }
 }
 public FilterParamIndexQuadTreePointRegion(IReaderWriterLock readWriteLock, ExprFilterSpecLookupable lookupable)
     : base(FilterOperator.ADVANCED_INDEX, lookupable)
 {
     _readWriteLock = readWriteLock;
     _advancedIndex = (FilterSpecLookupableAdvancedIndex) lookupable;
     var quadTreeConfig = _advancedIndex.QuadTreeConfig;
     _quadTree = PointRegionQuadTreeFactory<object>.Make(
         quadTreeConfig.X,
         quadTreeConfig.Y,
         quadTreeConfig.Width,
         quadTreeConfig.Height);
 }
Example #16
0
        public FilterParamIndexCompare(
            ExprFilterSpecLookupable lookupable,
            IReaderWriterLock readWriteLock,
            FilterOperator filterOperator)
            : base(filterOperator, lookupable)
        {
            constantsMap = new OrderedListDictionary<object, EventEvaluator>();
            constantsMapRWLock = readWriteLock;

            if (filterOperator != FilterOperator.GREATER &&
                filterOperator != FilterOperator.GREATER_OR_EQUAL &&
                filterOperator != FilterOperator.LESS &&
                filterOperator != FilterOperator.LESS_OR_EQUAL) {
                throw new ArgumentException("Invalid filter operator for index of " + filterOperator);
            }
        }
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="lookupable">is the lookupable</param>
        /// <param name="filterOperator">is the type of compare</param>
        /// <param name="filterConstant">contains the value to match against the event's property value</param>
        /// <throws>IllegalArgumentException if an operator was supplied that does not take a single constant value</throws>
        public SupportFilterSpecParamConstant(
            ExprFilterSpecLookupable lookupable,
            FilterOperator filterOperator,
            object filterConstant)
            : base(lookupable, filterOperator)
        {
            FilterConstant = filterConstant;

            if (filterOperator.IsRangeOperator())
            {
                throw new ArgumentException(
                          "Illegal filter operator " +
                          filterOperator +
                          " supplied to " +
                          "constant filter parameter");
            }
        }
Example #18
0
        public void TestNodeGetSet()
        {
            FilterHandle exprOne = new SupportFilterHandle();

            // Check pre-conditions
            Assert.IsTrue(testNode.NodeRWLock != null);
            Assert.IsFalse(testNode.Contains(exprOne));
            Assert.AreEqual(0, testNode.FilterCallbackCount);
            Assert.AreEqual(0, testNode.Indizes.Count);
            Assert.IsTrue(testNode.IsEmpty());

            testNode.Add(exprOne);

            // Check after add
            Assert.IsTrue(testNode.Contains(exprOne));
            Assert.AreEqual(1, testNode.FilterCallbackCount);
            Assert.IsFalse(testNode.IsEmpty());

            // Add an indexOne
            EventType eventType = SupportEventTypeFactory
                                  .GetInstance(container)
                                  .CreateBeanType(typeof(SupportBean));
            SupportExprEventEvaluator eval       = new SupportExprEventEvaluator(eventType.GetGetter("IntPrimitive"));
            ExprFilterSpecLookupable  lookupable = new ExprFilterSpecLookupable(
                "IntPrimitive",
                eval,
                null,
                eventType.GetPropertyType("IntPrimitive"),
                false,
                null);
            FilterParamIndexBase indexOne = new SupportFilterParamIndex(lookupable);

            testNode.Add(indexOne);

            // Check after add
            Assert.AreEqual(1, testNode.Indizes.Count);
            Assert.AreEqual(indexOne, testNode.Indizes[0]);

            // Check removes
            Assert.IsTrue(testNode.Remove(exprOne));
            Assert.IsFalse(testNode.IsEmpty());
            Assert.IsFalse(testNode.Remove(exprOne));
            Assert.IsTrue(testNode.Remove(indexOne));
            Assert.IsFalse(testNode.Remove(indexOne));
            Assert.IsTrue(testNode.IsEmpty());
        }
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="lookupable">is the lookupable</param>
        /// <param name="filterOperator">is the type of range operator</param>
        /// <param name="min">is the begin point of the range</param>
        /// <param name="max">is the end point of the range</param>
        /// <throws>IllegalArgumentException if an operator was supplied that does not take a double range value</throws>
        public SupportFilterSpecParamRange(
            ExprFilterSpecLookupable lookupable,
            FilterOperator filterOperator,
            FilterSpecParamFilterForEval min,
            FilterSpecParamFilterForEval max)
            : base(lookupable, filterOperator)
        {
            Min = min;
            Max = max;

            if (!filterOperator.IsRangeOperator() && !filterOperator.IsInvertedRangeOperator())
            {
                throw new ArgumentException(
                          "Illegal filter operator " +
                          filterOperator +
                          " supplied to " +
                          "range filter parameter");
            }
        }
        public override FilterValueSetParam GetFilterValue(
            MatchedEventMap matchedEvents,
            ExprEvaluatorContext exprEvaluatorContext,
            StatementContextFilterEvalEnv filterEvalEnv)
        {
            ExprFilterSpecLookupable lookupable = this.Lkupable.Make(matchedEvents, exprEvaluatorContext);
            Object range;

            if (lookupable.ReturnType == typeof(string))
            {
                var begin = (string)Min.GetFilterValue(matchedEvents, exprEvaluatorContext, filterEvalEnv);
                var end   = (string)Max.GetFilterValue(matchedEvents, exprEvaluatorContext, filterEvalEnv);
                range = new StringRange(begin, end);
            }
            else
            {
                var begin = (double)Min.GetFilterValue(matchedEvents, exprEvaluatorContext, filterEvalEnv);
                var end   = (double)Max.GetFilterValue(matchedEvents, exprEvaluatorContext, filterEvalEnv);
                range = new DoubleRange(begin, end);
            }

            return(new FilterValueSetParamImpl(lookupable, FilterOperator, range));
        }
Example #21
0
        /// <summary>
        ///     Factory for indexes that store filter parameter constants for a given event property and filter
        ///     operator.
        ///     <para />
        ///     Does not perform any check of validity of property name.
        /// </summary>
        /// <param name="filterOperator">is the type of index to use</param>
        /// <param name="lockFactory">lock factory</param>
        /// <param name="lookupable">the lookup item</param>
        /// <returns>the proper index based on the filter operator type</returns>
        public static FilterParamIndexBase CreateIndex(
            ExprFilterSpecLookupable lookupable,
            FilterServiceGranularLockFactory lockFactory,
            FilterOperator filterOperator)
        {
            FilterParamIndexBase index;
            var returnValueType = lookupable.ReturnType;

            // Handle all EQUAL comparisons
            if (filterOperator == FilterOperator.EQUAL) {
                index = new FilterParamIndexEquals(lookupable, lockFactory.ObtainNew());
                return index;
            }

            // Handle all NOT-EQUAL comparisons
            if (filterOperator == FilterOperator.NOT_EQUAL) {
                index = new FilterParamIndexNotEquals(lookupable, lockFactory.ObtainNew());
                return index;
            }

            if (filterOperator == FilterOperator.IS) {
                index = new FilterParamIndexEqualsIs(lookupable, lockFactory.ObtainNew());
                return index;
            }

            if (filterOperator == FilterOperator.IS_NOT) {
                index = new FilterParamIndexNotEqualsIs(lookupable, lockFactory.ObtainNew());
                return index;
            }

            // Handle all GREATER, LESS etc. comparisons
            if (filterOperator == FilterOperator.GREATER ||
                filterOperator == FilterOperator.GREATER_OR_EQUAL ||
                filterOperator == FilterOperator.LESS ||
                filterOperator == FilterOperator.LESS_OR_EQUAL) {
                if (returnValueType != typeof(string)) {
                    index = new FilterParamIndexCompare(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                else {
                    index = new FilterParamIndexCompareString(lookupable, lockFactory.ObtainNew(), filterOperator);
                }

                return index;
            }

            // Handle all normal and inverted RANGE comparisons
            if (filterOperator.IsRangeOperator()) {
                if (returnValueType != typeof(string)) {
                    index = new FilterParamIndexDoubleRange(lookupable, lockFactory.ObtainNew(), filterOperator);
                }
                else {
                    index = new FilterParamIndexStringRange(lookupable, lockFactory.ObtainNew(), filterOperator);
                }

                return index;
            }

            if (filterOperator.IsInvertedRangeOperator()) {
                if (returnValueType != typeof(string)) {
                    return new FilterParamIndexDoubleRangeInverted(lookupable, lockFactory.ObtainNew(), filterOperator);
                }

                return new FilterParamIndexStringRangeInverted(lookupable, lockFactory.ObtainNew(), filterOperator);
            }

            // Handle all IN and NOT IN comparisons
            if (filterOperator == FilterOperator.IN_LIST_OF_VALUES) {
                return new FilterParamIndexIn(lookupable, lockFactory.ObtainNew());
            }

            if (filterOperator == FilterOperator.NOT_IN_LIST_OF_VALUES) {
                return new FilterParamIndexNotIn(lookupable, lockFactory.ObtainNew());
            }

            
            // Handle re-usable boolean expression
            if (filterOperator == FilterOperator.REBOOL) {
                if (lookupable.ReturnType == null) {
                    return new FilterParamIndexReboolNoValue(lookupable, lockFactory.ObtainNew());
                }
                return new FilterParamIndexReboolWithValue(lookupable, lockFactory.ObtainNew());
            }
            
            // Handle all boolean expression
            if (filterOperator == FilterOperator.BOOLEAN_EXPRESSION) {
                return new FilterParamIndexBooleanExpr(lockFactory.ObtainNew());
            }

            // Handle advanced-index
            if (filterOperator == FilterOperator.ADVANCED_INDEX) {
                var advLookable = (FilterSpecLookupableAdvancedIndex) lookupable;
                if (advLookable.IndexType.Equals(SettingsApplicationDotMethodPointInsideRectangle.INDEXTYPE_NAME)) {
                    return new FilterParamIndexQuadTreePointRegion(lockFactory.ObtainNew(), lookupable);
                }

                if (advLookable.IndexType.Equals(SettingsApplicationDotMethodRectangeIntersectsRectangle.INDEXTYPE_NAME)) {
                    return new FilterParamIndexQuadTreeMXCIF(lockFactory.ObtainNew(), lookupable);
                }

                throw new IllegalStateException("Unrecognized index type " + advLookable.IndexType);
            }

            throw new ArgumentException("Cannot create filter index instance for filter operator " + filterOperator);
        }
Example #22
0
 public ProxyFilterSpecParamExprNode(
     ExprFilterSpecLookupable lkupable,
     FilterOperator filterOperator) : base(lkupable, filterOperator)
 {
 }
Example #23
0
 public FilterSpecParamAdvancedIndexQuadTreePointRegion(
     ExprFilterSpecLookupable lkupable,
     FilterOperator filterOperator)
     : base(lkupable, filterOperator)
 {
 }
Example #24
0
 public void RegisterLookupable(
     EventType eventType,
     ExprFilterSpecLookupable lookupable)
 {
     ProcRegisterLookupable?.Invoke(eventType, lookupable);
 }
Example #25
0
 public FilterParamIndexEquals(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(lookupable, readWriteLock, FilterOperator.EQUAL)
 {
 }
Example #26
0
 private static FilterValueSetParam GetFilterMayEqualOrNull(
     ExprFilterSpecLookupable lookupable,
     object keyValue)
 {
     return new FilterValueSetParamImpl(lookupable, FilterOperator.IS, keyValue);
 }
Example #27
0
 public FilterParamIndexNotEqualsIs(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(lookupable, readWriteLock, FilterOperator.IS_NOT)
 {
 }
Example #28
0
 internal FilterParamIndexReboolWithValue(
     ExprFilterSpecLookupable lookupable,
     IReaderWriterLock readWriteLock)
     : base(lookupable, readWriteLock, FilterOperator.REBOOL)
 {
 }
Example #29
0
 public SupportFilterParamIndex(ExprFilterSpecLookupable lookupable) : base(FilterOperator.EQUAL, lookupable)
 {
 }