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);
        }
Example #2
0
        public override object GetFilterValue(MatchedEventMap matchedEvents, ExprEvaluatorContext exprEvaluatorContext)
        {
            EventBean[] events = null;

            if ((_taggedEventTypes != null && !_taggedEventTypes.IsEmpty()) || (_arrayEventTypes != null && !_arrayEventTypes.IsEmpty()))
            {
                var size = 0;
                size  += (_taggedEventTypes != null) ? _taggedEventTypes.Count : 0;
                size  += (_arrayEventTypes != null) ? _arrayEventTypes.Count : 0;
                events = new EventBean[size + 1];

                var count = 1;
                if (_taggedEventTypes != null)
                {
                    foreach (var tag in _taggedEventTypes.Keys)
                    {
                        events[count] = matchedEvents.GetMatchingEventByTag(tag);
                        count++;
                    }
                }

                if (_arrayEventTypes != null)
                {
                    foreach (var entry in _arrayEventTypes)
                    {
                        var compositeEventType = entry.Value.First;
                        events[count] = _eventAdapterService.AdapterForTypedMap(matchedEvents.MatchingEventsAsMap, compositeEventType);
                        count++;
                    }
                }
            }

            // handle table evaluator context
            if (_hasTableAccess)
            {
                exprEvaluatorContext = new ExprEvaluatorContextWTableAccess(exprEvaluatorContext, _tableService);
            }

            // non-pattern case
            ExprNodeAdapterBase adapter;

            if (events == null)
            {
                // if a subquery is present in a filter stream acquire the agent instance lock
                if (_hasFilterStreamSubquery)
                {
                    adapter = new ExprNodeAdapterBaseStmtLock(_filterSpecId, _filterSpecParamPathNum, _exprNode, exprEvaluatorContext, _variableService);
                }
                // no-variable no-prior event evaluation
                else if (!_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
                var variableServiceToUse = _hasVariable == false ? null : _variableService;
                if (_useLargeThreadingProfile)
                {
                    // no-threadlocal evaluation
                    // if a subquery is present in a pattern filter acquire the agent instance lock
                    if (_hasFilterStreamSubquery)
                    {
                        adapter = new ExprNodeAdapterMultiStreamNoTLStmtLock(_filterSpecId, _filterSpecParamPathNum, _exprNode, exprEvaluatorContext, variableServiceToUse, events);
                    }
                    else
                    {
                        adapter = new ExprNodeAdapterMultiStreamNoTL(_filterSpecId, _filterSpecParamPathNum, _exprNode, exprEvaluatorContext, variableServiceToUse, events);
                    }
                }
                else
                {
                    if (_hasFilterStreamSubquery)
                    {
                        adapter = new ExprNodeAdapterMultiStreamStmtLock(_filterSpecId, _filterSpecParamPathNum, _exprNode, exprEvaluatorContext, variableServiceToUse, events);
                    }
                    else
                    {
                        // evaluation with threadlocal cache
                        adapter = new ExprNodeAdapterMultiStream(_filterSpecId, _filterSpecParamPathNum, _exprNode, exprEvaluatorContext, variableServiceToUse, events);
                    }
                }
            }

            if (!_hasTableAccess)
            {
                return(adapter);
            }

            // handle table
            return(new ExprNodeAdapterBaseWTableAccess(_filterSpecId, _filterSpecParamPathNum, _exprNode, exprEvaluatorContext, adapter, _tableService));
        }