Example #1
0
        private static void DecomposePopulateConsolidate(
            FilterParamExprMap filterParamExprMap,
            IList<ExprNode> validatedNodes,
            FilterSpecCompilerArgs args)

        {
            IList<ExprNode> constituents = DecomposeCheckAggregation(validatedNodes);

            // Make filter parameter for each expression node, if it can be optimized
            foreach (ExprNode constituent in constituents)
            {
                FilterSpecParam param = FilterSpecCompilerMakeParamUtil.MakeFilterParam(
                    constituent, args.ArrayEventTypes, args.ExprEvaluatorContext, args.StatementName);
                filterParamExprMap.Put(constituent, param);
                    // accepts null values as the expression may not be optimized
            }

            // Consolidate entries as possible, i.e. (a != 5 and a != 6) is (a not in (5,6))
            // Removes duplicates for same property and same filter operator for filter service index optimizations
            FilterSpecCompilerConsolidateUtil.Consolidate(filterParamExprMap, args.StatementName);
        }
Example #2
0
        // consolidate "val != 3 and val != 4 and val != 5"
        // to "val not in (3, 4, 5)"
        private static void HandleConsolidateNotEqual(IList <FilterSpecParam> parameters, FilterParamExprMap filterParamExprMap, string statementName)
        {
            IList <FilterSpecParamInValue> values = new List <FilterSpecParamInValue>();

            ExprNode lastNotEqualsExprNode = null;

            foreach (var param in parameters)
            {
                if (param is FilterSpecParamConstant)
                {
                    var constantParam = (FilterSpecParamConstant)param;
                    var constant      = constantParam.FilterConstant;
                    values.Add(new InSetOfValuesConstant(constant));
                }
                else if (param is FilterSpecParamEventProp)
                {
                    var eventProp = (FilterSpecParamEventProp)param;
                    values.Add(new InSetOfValuesEventProp(eventProp.ResultEventAsName, eventProp.ResultEventProperty,
                                                          eventProp.IsMustCoerce, TypeHelper.GetBoxedType(eventProp.CoercionType)));
                }
                else if (param is FilterSpecParamEventPropIndexed)
                {
                    var eventProp = (FilterSpecParamEventPropIndexed)param;
                    values.Add(new InSetOfValuesEventPropIndexed(eventProp.ResultEventAsName, eventProp.ResultEventIndex, eventProp.ResultEventProperty,
                                                                 eventProp.IsMustCoerce, TypeHelper.GetBoxedType(eventProp.CoercionType), statementName));
                }
                else
                {
                    throw new ArgumentException("Unknown filter parameter:" + param.ToString());
                }

                lastNotEqualsExprNode = filterParamExprMap.RemoveEntry(param);
            }

            var paramIn = new FilterSpecParamIn(parameters[0].Lookupable, FilterOperator.NOT_IN_LIST_OF_VALUES, values);

            filterParamExprMap.Put(lastNotEqualsExprNode, paramIn);
        }