Exemplo n.º 1
0
        private static void AddAddendums(
            IDictionary <FilterSpecCompiled, FilterValueSetParam[][]> addendums,
            IList <FilterValueSetParam> addendumFilters,
            FilterSpecCompiled filtersSpec,
            FilterValueSetParam[][] optionalPartitionFilters)
        {
            FilterValueSetParam[][] params2Dim = new FilterValueSetParam[1][];
            params2Dim[0] = addendumFilters.ToArray();

            FilterValueSetParam[][] addendum;
            FilterValueSetParam[][] existing = addendums.Get(filtersSpec);
            if (existing != null)
            {
                addendum = ContextControllerAddendumUtil.MultiplyAddendum(existing, params2Dim);
            }
            else
            {
                addendum = params2Dim;
            }

            if (optionalPartitionFilters != null)
            {
                addendum = ContextControllerAddendumUtil.MultiplyAddendum(addendum, optionalPartitionFilters);
            }

            addendums[filtersSpec] = addendum;
        }
Exemplo n.º 2
0
        public static FilterValueSetParam[][] GetAddendumFilters(
            FilterSpecCompiled filterSpecCompiled,
            int hashCode,
            ContextDetailHash hashSpec,
            ContextControllerStatementDesc statementDesc)
        {
            // determine whether create-named-window
            var isCreateWindow = statementDesc != null && statementDesc.Statement.StatementSpec.CreateWindowDesc != null;
            ContextDetailHashItem foundPartition = null;

            if (!isCreateWindow)
            {
                foundPartition = FindHashItemSpec(hashSpec, filterSpecCompiled);
            }
            else
            {
                string declaredAsName = statementDesc.Statement.StatementSpec.CreateWindowDesc.AsEventTypeName;
                foreach (var partitionItem in hashSpec.Items)
                {
                    if (partitionItem.FilterSpecCompiled.FilterForEventType.Name.Equals(declaredAsName))
                    {
                        foundPartition = partitionItem;
                        break;
                    }
                }
            }

            if (foundPartition == null)
            {
                return(null);
            }

            var filter = new FilterValueSetParamImpl(foundPartition.Lookupable, FilterOperator.EQUAL, hashCode);

            var addendum = new FilterValueSetParam[1][];

            addendum[0] = new FilterValueSetParam[]
            {
                filter
            };

            var partitionFilters = foundPartition.ParametersCompiled;

            if (partitionFilters != null)
            {
                addendum = ContextControllerAddendumUtil.AddAddendum(partitionFilters, filter);
            }
            return(addendum);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Compare filters in statement with filters in segmented context, addendum filter compilation
        /// </summary>
        public static void GetAddendumFilters(IDictionary <FilterSpecCompiled, FilterValueSetParam[][]> addendums, int hashCode, IList <FilterSpecCompiled> filtersSpecs, ContextDetailHash hashSpec, ContextControllerStatementDesc statementDesc)
        {
            foreach (var filtersSpec in filtersSpecs)
            {
                var addendum = GetAddendumFilters(filtersSpec, hashCode, hashSpec, statementDesc);
                if (addendum == null)
                {
                    continue;
                }

                var existing = addendums.Get(filtersSpec);
                if (existing != null)
                {
                    addendum = ContextControllerAddendumUtil.MultiplyAddendum(existing, addendum);
                }
                addendums.Put(filtersSpec, addendum);
            }
        }
        private static void AddAddendums(
            IDictionary <FilterSpecCompiled, FilterValueSetParam[][]> addendums,
            FilterSpecCompiled filtersSpec,
            ContextDetailCategoryItem category,
            ContextDetailCategory categorySpec)
        {
            FilterValueSetParam[][] categoryEventFilters = categorySpec.FilterParamsCompiled;
            FilterValueSetParam[][] categoryItemFilters  = category.CompiledFilterParam;

            FilterValueSetParam[][] addendum = ContextControllerAddendumUtil.MultiplyAddendum(categoryEventFilters, categoryItemFilters);

            FilterValueSetParam[][] existingFilters = addendums.Get(filtersSpec);
            if (existingFilters != null)
            {
                addendum = ContextControllerAddendumUtil.MultiplyAddendum(existingFilters, addendum);
            }

            addendums[filtersSpec] = addendum;
        }
Exemplo n.º 5
0
        // Compare filters in statement with filters in segmented context, addendum filter compilation
        public static void PopulateAddendumFilters(
            object keyValue,
            IList <FilterSpecCompiled> filtersSpecs,
            ContextDetailPartitioned segmentedSpec,
            StatementSpecCompiled optionalStatementSpecCompiled,
            IDictionary <FilterSpecCompiled, FilterValueSetParam[][]> addendums)
        {
            foreach (var filtersSpec in filtersSpecs)
            {
                var addendum = GetAddendumFilters(keyValue, filtersSpec, segmentedSpec, optionalStatementSpecCompiled);
                if (addendum == null)
                {
                    continue;
                }

                var existing = addendums.Get(filtersSpec);
                if (existing != null)
                {
                    addendum = ContextControllerAddendumUtil.MultiplyAddendum(existing, addendum);
                }
                addendums.Put(filtersSpec, addendum);
            }
        }
Exemplo n.º 6
0
        public static FilterValueSetParam[][] GetAddendumFilters(
            object keyValue,
            FilterSpecCompiled filtersSpec,
            ContextDetailPartitioned segmentedSpec,
            StatementSpecCompiled optionalStatementSpecCompiled)
        {
            // determine whether create-named-window
            var isCreateWindow = optionalStatementSpecCompiled != null &&
                                 optionalStatementSpecCompiled.CreateWindowDesc != null;
            ContextDetailPartitionItem foundPartition = null;

            if (!isCreateWindow)
            {
                foreach (var partitionItem in segmentedSpec.Items)
                {
                    var typeOrSubtype = EventTypeUtility.IsTypeOrSubTypeOf(
                        filtersSpec.FilterForEventType, partitionItem.FilterSpecCompiled.FilterForEventType);
                    if (typeOrSubtype)
                    {
                        foundPartition = partitionItem;
                    }
                }
            }
            else
            {
                var declaredAsName = optionalStatementSpecCompiled.CreateWindowDesc.AsEventTypeName;
                if (declaredAsName == null)
                {
                    return(null);
                }
                foreach (var partitionItem in segmentedSpec.Items)
                {
                    if (partitionItem.FilterSpecCompiled.FilterForEventType.Name.Equals(declaredAsName))
                    {
                        foundPartition = partitionItem;
                        break;
                    }
                }
            }

            if (foundPartition == null)
            {
                return(null);
            }

            var addendumFilters = new List <FilterValueSetParam>(foundPartition.PropertyNames.Count);

            if (foundPartition.PropertyNames.Count == 1)
            {
                var propertyName           = foundPartition.PropertyNames[0];
                var getter                 = foundPartition.FilterSpecCompiled.FilterForEventType.GetGetter(propertyName);
                var resultType             = foundPartition.FilterSpecCompiled.FilterForEventType.GetPropertyType(propertyName);
                var lookupable             = new FilterSpecLookupable(propertyName, getter, resultType, false);
                FilterValueSetParam filter = new FilterValueSetParamImpl(lookupable, FilterOperator.EQUAL, keyValue);
                addendumFilters.Add(filter);
            }
            else
            {
                var keys = ((MultiKeyUntyped)keyValue).Keys;
                for (var i = 0; i < foundPartition.PropertyNames.Count; i++)
                {
                    var partitionPropertyName = foundPartition.PropertyNames[i];
                    var getter                 = foundPartition.FilterSpecCompiled.FilterForEventType.GetGetter(partitionPropertyName);
                    var resultType             = foundPartition.FilterSpecCompiled.FilterForEventType.GetPropertyType(partitionPropertyName);
                    var lookupable             = new FilterSpecLookupable(partitionPropertyName, getter, resultType, false);
                    FilterValueSetParam filter = new FilterValueSetParamImpl(lookupable, FilterOperator.EQUAL, keys[i]);
                    addendumFilters.Add(filter);
                }
            }

            var addendum = new FilterValueSetParam[1][];

            addendum[0] = addendumFilters.ToArray();

            var partitionFilters = foundPartition.ParametersCompiled;

            if (partitionFilters != null)
            {
                addendum = ContextControllerAddendumUtil.AddAddendum(partitionFilters, addendum[0]);
            }

            return(addendum);
        }
Exemplo n.º 7
0
        // Compare filters in statement with filters in segmented context, addendum filter compilation
        /// <summary>
        /// Gets the addendum filters.
        /// </summary>
        /// <param name="addendums">The addendums.</param>
        /// <param name="agentInstanceId">The agent instance identifier.</param>
        /// <param name="filtersSpecs">The filters specs.</param>
        /// <param name="hashSpec">The hash spec.</param>
        /// <param name="statementDesc">The statement desc.</param>
        private static void GetAddendumFilters(
            IDictionary <FilterSpecCompiled, FilterValueSetParam[][]> addendums,
            int agentInstanceId,
            IList <FilterSpecCompiled> filtersSpecs,
            ContextDetailHash hashSpec,
            ContextControllerStatementDesc statementDesc)
        {
            // determine whether create-named-window
            var isCreateWindow = statementDesc != null && statementDesc.Statement.StatementSpec.CreateWindowDesc != null;

            if (!isCreateWindow)
            {
                foreach (var filtersSpec in filtersSpecs)
                {
                    var foundPartition = FindHashItemSpec(hashSpec, filtersSpec);
                    if (foundPartition == null)
                    {
                        continue;
                    }

                    FilterValueSetParam filter = new FilterValueSetParamImpl(foundPartition.Lookupable, FilterOperator.EQUAL, agentInstanceId);

                    var addendum = new FilterValueSetParam[1][];
                    addendum[0] = new FilterValueSetParam[] { filter };

                    var partitionFilters = foundPartition.ParametersCompiled;
                    if (partitionFilters != null)
                    {
                        addendum = ContextControllerAddendumUtil.AddAddendum(partitionFilters, filter);
                    }

                    FilterValueSetParam[][] existing = addendums.Get(filtersSpec);
                    if (existing != null)
                    {
                        addendum = ContextControllerAddendumUtil.MultiplyAddendum(existing, addendum);
                    }

                    addendums[filtersSpec] = addendum;
                }
            }
            // handle segmented context for create-window
            else
            {
                var declaredAsName = statementDesc.Statement.StatementSpec.CreateWindowDesc.AsEventTypeName;
                if (declaredAsName != null)
                {
                    foreach (var filterSpec in filtersSpecs)
                    {
                        ContextDetailHashItem foundPartition = null;
                        foreach (var partitionItem in hashSpec.Items)
                        {
                            if (partitionItem.FilterSpecCompiled.FilterForEventType.Name.Equals(declaredAsName))
                            {
                                foundPartition = partitionItem;
                                break;
                            }
                        }

                        if (foundPartition == null)
                        {
                            continue;
                        }

                        FilterValueSetParam filter = new FilterValueSetParamImpl(foundPartition.Lookupable, FilterOperator.EQUAL, agentInstanceId);

                        var addendum = new FilterValueSetParam[1][];
                        addendum[0] = new FilterValueSetParam[] { filter };

                        var existing = addendums.Get(filterSpec);
                        if (existing != null)
                        {
                            addendum = ContextControllerAddendumUtil.MultiplyAddendum(existing, addendum);
                        }

                        addendums[filterSpec] = addendum;
                    }
                }
            }
        }