Ejemplo n.º 1
0
        public void TestLongNeitherEndpointIncluded()
        {
            FilterParamIndexDoubleRange index = GetLongDataset(FilterOperator.RANGE_OPEN);

            VerifyLongPrimitive(index, -1, 0);
            VerifyLongPrimitive(index, 0, 0);
            VerifyLongPrimitive(index, 1, 2);
            VerifyLongPrimitive(index, 2, 5);
            VerifyLongPrimitive(index, 3, 4);
            VerifyLongPrimitive(index, 4, 6);
            VerifyLongPrimitive(index, 5, 3);
            VerifyLongPrimitive(index, 6, 2);
            VerifyLongPrimitive(index, 7, 3);
            VerifyLongPrimitive(index, 8, 3);
            VerifyLongPrimitive(index, 9, 3);
            VerifyLongPrimitive(index, 10, 1);
            VerifyLongPrimitive(index, 11, 1);
        }
Ejemplo n.º 2
0
        public void TestLongHighEndpointIncluded()
        {
            FilterParamIndexDoubleRange index = GetLongDataset(FilterOperator.RANGE_HALF_CLOSED);

            VerifyLongPrimitive(index, -1, 0);
            VerifyLongPrimitive(index, 0, 0);
            VerifyLongPrimitive(index, 1, 2);
            VerifyLongPrimitive(index, 2, 5);
            VerifyLongPrimitive(index, 3, 5);
            VerifyLongPrimitive(index, 4, 6);
            VerifyLongPrimitive(index, 5, 6);
            VerifyLongPrimitive(index, 6, 3);
            VerifyLongPrimitive(index, 7, 5);
            VerifyLongPrimitive(index, 8, 4);
            VerifyLongPrimitive(index, 9, 5);
            VerifyLongPrimitive(index, 10, 3);
            VerifyLongPrimitive(index, 11, 1);
        }
Ejemplo n.º 3
0
        public void TestDoubleBothEndpointsIncluded()
        {
            FilterParamIndexDoubleRange index = GetDoubleDataset(FilterOperator.RANGE_CLOSED);

            VerifyDoublePrimitive(index, 1.49, 0);
            VerifyDoublePrimitive(index, 1.5, 1);
            VerifyDoublePrimitive(index, 2.5, 1);
            VerifyDoublePrimitive(index, 2.51, 0);
            VerifyDoublePrimitive(index, 3.5, 2);
            VerifyDoublePrimitive(index, 4.4, 2);
            VerifyDoublePrimitive(index, 4.5, 2);
            VerifyDoublePrimitive(index, 4.5001, 1);
            VerifyDoublePrimitive(index, 5.1, 1);
            VerifyDoublePrimitive(index, 5.8, 2);
            VerifyDoublePrimitive(index, 6.7, 2);
            VerifyDoublePrimitive(index, 6.8, 1);
            VerifyDoublePrimitive(index, 9.5, 1);
            VerifyDoublePrimitive(index, 10.1, 0);
        }
Ejemplo n.º 4
0
        private FilterParamIndexDoubleRange GetLongDataset(FilterOperator operatorType)
        {
            FilterParamIndexDoubleRange index = MakeOne("LongPrimitive", operatorType, _testEventType);

            AddToIndex(index, 0, 5);
            AddToIndex(index, 0, 6);
            AddToIndex(index, 1, 3);
            AddToIndex(index, 1, 5);
            AddToIndex(index, 1, 7);
            AddToIndex(index, 3, 5);
            AddToIndex(index, 3, 7);
            AddToIndex(index, 6, 9);
            AddToIndex(index, 6, 10);
            AddToIndex(index, 6, int.MaxValue - 1);
            AddToIndex(index, 7, 8);
            AddToIndex(index, 8, 9);
            AddToIndex(index, 8, 10);

            return(index);
        }
Ejemplo n.º 5
0
        public void TestDoubleVariableRangeSize()
        {
            FilterParamIndexDoubleRange index = MakeOne("DoublePrimitive", FilterOperator.RANGE_CLOSED, _testEventType);

            for (int i = 0; i < 100; i++)
            {
                var range = new DoubleRange(i, 2 * i);
                index.Put(range, _testEvaluator);
            }

            // 1 to 2
            // 2 to 4
            // 3 to 6
            // and so on

            VerifyDoublePrimitive(index, 1, 1);
            VerifyDoublePrimitive(index, 2, 2);
            VerifyDoublePrimitive(index, 2.001, 1);
            VerifyDoublePrimitive(index, 3, 2);
            VerifyDoublePrimitive(index, 4, 3);
            VerifyDoublePrimitive(index, 4.5, 2);
            VerifyDoublePrimitive(index, 50, 26);
        }
Ejemplo n.º 6
0
        private void AddToIndex(FilterParamIndexDoubleRange index, double min, double max)
        {
            var r = new DoubleRange(min, max);

            index.Put(r, _testEvaluator);
        }
Ejemplo n.º 7
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="lookupable">The lookupable.</param>
        /// <param name="lockFactory">The lock factory.</param>
        /// <param name="filterOperator">is the type of index to use</param>
        /// <returns>
        /// the proper index based on the filter operator type
        /// </returns>
        /// <exception cref="System.ArgumentException">Cannot create filter index instance for filter operator  + filterOperator</exception>
        public static FilterParamIndexBase CreateIndex(FilterSpecLookupable lookupable, FilterServiceGranularLockFactory lockFactory, FilterOperator filterOperator)
        {
            FilterParamIndexBase index;
            Type 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));
                }
                else
                {
                    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 all bool expression
            if (filterOperator == FilterOperator.BOOLEAN_EXPRESSION)
            {
                return(new FilterParamIndexBooleanExpr(lockFactory.ObtainNew()));
            }
            throw new ArgumentException("Cannot create filter index instance for filter operator " + filterOperator);
        }
Ejemplo n.º 8
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="lookupable">The lookupable.</param>
        /// <param name="lockFactory">The lock factory.</param>
        /// <param name="filterOperator">is the type of index to use</param>
        /// <returns>
        /// the proper index based on the filter operator type
        /// </returns>
        /// <exception cref="System.ArgumentException">Cannot create filter index instance for filter operator  + filterOperator</exception>
        public static FilterParamIndexBase CreateIndex(
            FilterSpecLookupable lookupable,
            FilterServiceGranularLockFactory lockFactory,
            FilterOperator filterOperator)
        {
            FilterParamIndexBase index;
            Type 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));
                }
                else
                {
                    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 all bool expression
            if (filterOperator == FilterOperator.BOOLEAN_EXPRESSION)
            {
                return(new FilterParamIndexBooleanExpr(lockFactory.ObtainNew()));
            }

            // Handle advanced-index
            if (filterOperator == FilterOperator.ADVANCED_INDEX)
            {
                FilterSpecLookupableAdvancedIndex advLookable = (FilterSpecLookupableAdvancedIndex)lookupable;
                if (advLookable.IndexType.Equals(EngineImportApplicationDotMethodPointInsideRectangle.INDEX_TYPE_NAME))
                {
                    return(new FilterParamIndexQuadTreePointRegion(lockFactory.ObtainNew(), lookupable));
                }
                else if (advLookable.IndexType.Equals(EngineImportApplicationDotMethodRectangeIntersectsRectangle.INDEX_TYPE_NAME))
                {
                    return(new FilterParamIndexQuadTreeMXCIF(lockFactory.ObtainNew(), lookupable));
                }
                else
                {
                    throw new IllegalStateException("Unrecognized index type " + advLookable.IndexType);
                }
            }

            throw new ArgumentException("Cannot create filter index instance for filter operator " + filterOperator);
        }