コード例 #1
0
        private static EvalFactoryNode RecursiveAddAuditNode(
            PatternNodeFactory patternNodeFactory,
            EvalFactoryNode parentNode,
            bool auditPattern,
            bool auditPatternInstance,
            EvalFactoryNode evalNode,
            EvalAuditInstanceCount instanceCount)
        {
            var writer = new StringWriter();

            evalNode.ToEPL(writer, PatternExpressionPrecedenceEnum.MINIMUM);
            var             expressionText         = writer.ToString();
            var             filterChildNonQuitting = parentNode != null && parentNode.IsFilterChildNonQuitting;
            EvalFactoryNode audit = patternNodeFactory.MakeAuditNode(
                auditPattern, auditPatternInstance, expressionText, instanceCount, filterChildNonQuitting);

            audit.AddChildNode(evalNode);

            IList <EvalFactoryNode> newChildNodes = new List <EvalFactoryNode>();

            foreach (var child in evalNode.ChildNodes)
            {
                newChildNodes.Add(
                    RecursiveAddAuditNode(
                        patternNodeFactory, evalNode, auditPattern, auditPatternInstance, child, instanceCount));
            }

            evalNode.ChildNodes.Clear();
            evalNode.AddChildNodes(newChildNodes);

            return(audit);
        }
コード例 #2
0
        private PatternStreamSpecCompiled CompileInternal(
            StatementContext context,
            ICollection <string> eventTypeReferences,
            bool isInsertInto,
            ICollection <int> assignedTypeNumberStack,
            MatchEventSpec tags,
            IEnumerable <string> priorAllTags,
            bool isJoin,
            bool isContextDeclaration,
            bool isOnTrigger)
        {
            // validate
            if ((_suppressSameEventMatches || _discardPartialsOnMatch) &&
                (isJoin || isContextDeclaration || isOnTrigger))
            {
                throw new ExprValidationException(
                          "Discard-partials and suppress-matches is not supported in a joins, context declaration and on-action");
            }

            if (tags == null)
            {
                tags = new MatchEventSpec();
            }
            var subexpressionIdStack = new ArrayDeque <int>(assignedTypeNumberStack);
            var evaluatorContextStmt = new ExprEvaluatorContextStatement(context, false);
            var nodeStack            = new Stack <EvalFactoryNode>();

            // detemine ordered tags
            var filterFactoryNodes = EvalNodeUtil.RecursiveGetChildNodes(
                _evalFactoryNode, FilterForFilterFactoryNodes.INSTANCE);
            var allTagNamesOrdered = new LinkedHashSet <string>();

            if (priorAllTags != null)
            {
                allTagNamesOrdered.AddAll(priorAllTags);
            }
            foreach (var filterNode in filterFactoryNodes)
            {
                var factory = (EvalFilterFactoryNode)filterNode;
                int tagNumber;
                if (factory.EventAsName != null)
                {
                    if (!allTagNamesOrdered.Contains(factory.EventAsName))
                    {
                        allTagNamesOrdered.Add(factory.EventAsName);
                        tagNumber = allTagNamesOrdered.Count - 1;
                    }
                    else
                    {
                        tagNumber = FindTagNumber(factory.EventAsName, allTagNamesOrdered);
                    }
                    factory.EventAsTagNumber = tagNumber;
                }
            }

            RecursiveCompile(
                _evalFactoryNode, context, evaluatorContextStmt, eventTypeReferences, isInsertInto, tags,
                subexpressionIdStack, nodeStack, allTagNamesOrdered);

            var auditPattern            = AuditEnum.PATTERN.GetAudit(context.Annotations);
            var auditPatternInstance    = AuditEnum.PATTERNINSTANCES.GetAudit(context.Annotations);
            var compiledEvalFactoryNode = _evalFactoryNode;

            if (context.PatternNodeFactory.IsAuditSupported && (auditPattern != null || auditPatternInstance != null))
            {
                var instanceCount = new EvalAuditInstanceCount();
                compiledEvalFactoryNode = RecursiveAddAuditNode(
                    context.PatternNodeFactory, null, auditPattern != null, auditPatternInstance != null,
                    _evalFactoryNode, instanceCount);
            }

            return(new PatternStreamSpecCompiled(
                       compiledEvalFactoryNode, tags.TaggedEventTypes, tags.ArrayEventTypes, allTagNamesOrdered, ViewSpecs,
                       OptionalStreamName, Options, _suppressSameEventMatches, _discardPartialsOnMatch));
        }