Exemple #1
0
        internal static IList<FilterSpecParam>[] PlanFilterParameters(
            IList<ExprNode> validatedNodes,
            FilterSpecCompilerArgs args)
        {
            if (validatedNodes.IsEmpty())
            {
                return AllocateListArray(0);
            }

            var filterParamExprMap = new FilterParamExprMap();

            // Make filter parameter for each expression node, if it can be optimized
            DecomposePopulateConsolidate(filterParamExprMap, validatedNodes, args);

            // Use all filter parameter and unassigned expressions
            IList<FilterSpecParam> filterParams = new List<FilterSpecParam>();
            filterParams.AddAll(filterParamExprMap.FilterParams);
            int countUnassigned = filterParamExprMap.CountUnassignedExpressions();

            // we are done if there are no remaining nodes
            if (countUnassigned == 0)
            {
                return AllocateListArraySizeOne(filterParams);
            }

            // determine max-width
            int filterServiceMaxFilterWidth =
                args.ConfigurationInformation.EngineDefaults.ExecutionConfig.FilterServiceMaxFilterWidth;
            HintAttribute hint = HintEnum.MAX_FILTER_WIDTH.GetHint(args.Annotations);
            if (hint != null)
            {
                string hintValue = HintEnum.MAX_FILTER_WIDTH.GetHintAssignedValue(hint);
                filterServiceMaxFilterWidth = int.Parse(hintValue);
            }

            IList<FilterSpecParam>[] plan = null;
            if (filterServiceMaxFilterWidth > 0)
            {
                plan = PlanRemainingNodesIfFeasible(filterParamExprMap, args, filterServiceMaxFilterWidth);
            }

            if (plan != null)
            {
                return plan;
            }

            // handle no-plan
            FilterSpecParamExprNode node = MakeRemainingNode(filterParamExprMap.UnassignedExpressions, args);
            filterParams.Add(node);
            return AllocateListArraySizeOne(filterParams);
        }
        public ExprNodeAdapterBase Make(
            FilterSpecParamExprNode node,
            EventBean[] events,
            ExprEvaluatorContext exprEvaluatorContext,
            StatementContext statementContext,
            int agentInstanceId)
        {
            int filterSpecId = node.FilterSpecId;
            int filterSpecParamPathNum = node.FilterSpecParamPathNum;
            ExprNode exprNode = node.ExprNode;
            VariableService variableService = node.VariableService;

            // handle table evaluator context
            if (node.HasTableAccess)
            {
                exprEvaluatorContext = new ExprEvaluatorContextWTableAccess(exprEvaluatorContext, node.TableService);
            }

            // non-pattern case
            ExprNodeAdapterBase adapter;
            if (events == null)
            {
                // if a subquery is present in a filter stream acquire the agent instance lock
                if (node.HasFilterStreamSubquery)
                {
                    adapter = GetLockableSingle(
                        filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext, variableService,
                        statementContext, agentInstanceId);
                }
                    // no-variable no-prior event evaluation
                else if (!node.HasVariable)
                {
                    adapter = new ExprNodeAdapterBase(
                        filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext);
                }
                else
                {
                    // with-variable no-prior event evaluation
                    adapter = new ExprNodeAdapterBaseVariables(
                        filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext, variableService);
                }
            }
            else
            {
                // pattern cases
                VariableService variableServiceToUse = node.HasVariable ? variableService : null;
                if (node.UseLargeThreadingProfile)
                {
                    // no-threadlocal evaluation
                    // if a subquery is present in a pattern filter acquire the agent instance lock
                    if (node.HasFilterStreamSubquery)
                    {
                        adapter = GetLockableMultiStreamNoTL(
                            filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext, variableServiceToUse,
                            events);
                    }
                    else
                    {
                        adapter = new ExprNodeAdapterMultiStreamNoTL(
                            filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext, variableServiceToUse,
                            events);
                    }
                }
                else
                {
                    if (node.HasFilterStreamSubquery)
                    {
                        adapter = GetLockableMultiStream(
                            filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext, variableServiceToUse,
                            events);
                    }
                    else
                    {
                        // evaluation with threadlocal cache
                        adapter = new ExprNodeAdapterMultiStream(
                            filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext, variableServiceToUse,
                            events);
                    }
                }
            }

            if (!node.HasTableAccess)
            {
                return adapter;
            }

            // handle table
            return new ExprNodeAdapterBaseWTableAccess(
                filterSpecId, filterSpecParamPathNum, exprNode, exprEvaluatorContext, adapter, node.TableService);
        }