private static void VisitSubselectOnTrigger(
            OnTriggerDesc onTriggerDesc,
            ExprNodeSubselectDeclaredDotVisitor visitor)
        {
            if (onTriggerDesc is OnTriggerWindowUpdateDesc) {
                OnTriggerWindowUpdateDesc updates = (OnTriggerWindowUpdateDesc) onTriggerDesc;
                foreach (OnTriggerSetAssignment assignment in updates.Assignments) {
                    assignment.Expression.Accept(visitor);
                }
            }
            else if (onTriggerDesc is OnTriggerSetDesc) {
                OnTriggerSetDesc sets = (OnTriggerSetDesc) onTriggerDesc;
                foreach (OnTriggerSetAssignment assignment in sets.Assignments) {
                    assignment.Expression.Accept(visitor);
                }
            }
            else if (onTriggerDesc is OnTriggerSplitStreamDesc) {
                OnTriggerSplitStreamDesc splits = (OnTriggerSplitStreamDesc) onTriggerDesc;
                foreach (OnTriggerSplitStream split in splits.SplitStreams) {
                    split.WhereClause?.Accept(visitor);

                    if (split.SelectClause.SelectExprList != null) {
                        WalkSubselectSelectClause(split.SelectClause.SelectExprList, visitor);
                    }
                }
            }
            else if (onTriggerDesc is OnTriggerMergeDesc) {
                OnTriggerMergeDesc merge = (OnTriggerMergeDesc) onTriggerDesc;
                foreach (OnTriggerMergeMatched matched in merge.Items) {
                    matched.OptionalMatchCond?.Accept(visitor);

                    foreach (OnTriggerMergeAction action in matched.Actions) {
                        action.OptionalWhereClause?.Accept(visitor);

                        if (action is OnTriggerMergeActionUpdate) {
                            OnTriggerMergeActionUpdate update = (OnTriggerMergeActionUpdate) action;
                            foreach (OnTriggerSetAssignment assignment in update.Assignments) {
                                assignment.Expression.Accept(visitor);
                            }
                        }

                        if (action is OnTriggerMergeActionInsert) {
                            OnTriggerMergeActionInsert insert = (OnTriggerMergeActionInsert) action;
                            WalkSubselectSelectClause(insert.SelectClause, visitor);
                        }
                    }
                }

                if (merge.OptionalInsertNoMatch != null) {
                    WalkSubselectSelectClause(merge.OptionalInsertNoMatch.SelectClause, visitor);
                }
            }
        }
 public static TableOnViewFactory Make(TableMetadata tableMetadata,
                                       OnTriggerDesc onTriggerDesc,
                                       EventType filterEventType,
                                       string filterStreamName,
                                       StatementContext statementContext,
                                       StatementMetricHandle metricsHandle,
                                       bool isDistinct,
                                       InternalEventRouter internalEventRouter
                                       )
 {
     if (onTriggerDesc.OnTriggerType == OnTriggerType.ON_DELETE)
     {
         return(new TableOnDeleteViewFactory(statementContext.StatementResultService, tableMetadata));
     }
     else if (onTriggerDesc.OnTriggerType == OnTriggerType.ON_SELECT)
     {
         EventBeanReader eventBeanReader = null;
         if (isDistinct)
         {
             eventBeanReader = tableMetadata.InternalEventType.Reader;
         }
         OnTriggerWindowDesc windowDesc = (OnTriggerWindowDesc)onTriggerDesc;
         return(new TableOnSelectViewFactory(tableMetadata, internalEventRouter, statementContext.EpStatementHandle,
                                             eventBeanReader, isDistinct, statementContext.StatementResultService, statementContext.InternalEventEngineRouteDest, windowDesc.IsDeleteAndSelect));
     }
     else if (onTriggerDesc.OnTriggerType == OnTriggerType.ON_UPDATE)
     {
         OnTriggerWindowUpdateDesc updateDesc     = (OnTriggerWindowUpdateDesc)onTriggerDesc;
         EventBeanUpdateHelper     updateHelper   = EventBeanUpdateHelperFactory.Make(tableMetadata.TableName, (EventTypeSPI)tableMetadata.InternalEventType, updateDesc.Assignments, updateDesc.OptionalAsName, filterEventType, false, statementContext.StatementName, statementContext.EngineURI, statementContext.EventAdapterService);
         TableUpdateStrategy       updateStrategy = statementContext.TableService.GetTableUpdateStrategy(tableMetadata, updateHelper, false);
         var onUpdateViewFactory = new TableOnUpdateViewFactory(statementContext.StatementResultService, tableMetadata, updateHelper, updateStrategy);
         statementContext.TableService.AddTableUpdateStrategyReceiver(tableMetadata, statementContext.StatementName, onUpdateViewFactory, updateHelper, false);
         return(onUpdateViewFactory);
     }
     else if (onTriggerDesc.OnTriggerType == OnTriggerType.ON_MERGE)
     {
         OnTriggerMergeDesc onMergeTriggerDesc = (OnTriggerMergeDesc)onTriggerDesc;
         var onMergeHelper = new TableOnMergeHelper(statementContext, onMergeTriggerDesc, filterEventType, filterStreamName, internalEventRouter, tableMetadata);
         return(new TableOnMergeViewFactory(tableMetadata, onMergeHelper, statementContext.StatementResultService, metricsHandle, statementContext.MetricReportingService));
     }
     else
     {
         throw new IllegalStateException("Unknown trigger type " + onTriggerDesc.OnTriggerType);
     }
 }
示例#3
0
        private static void VisitSubselectOnTrigger(OnTriggerDesc onTriggerDesc, ExprNodeSubselectDeclaredDotVisitor visitor)
        {
            if (onTriggerDesc is OnTriggerWindowUpdateDesc)
            {
                OnTriggerWindowUpdateDesc updates = (OnTriggerWindowUpdateDesc)onTriggerDesc;
                foreach (OnTriggerSetAssignment assignment in updates.Assignments)
                {
                    assignment.Expression.Accept(visitor);
                }
            }
            else if (onTriggerDesc is OnTriggerSetDesc)
            {
                OnTriggerSetDesc sets = (OnTriggerSetDesc)onTriggerDesc;
                foreach (OnTriggerSetAssignment assignment in sets.Assignments)
                {
                    assignment.Expression.Accept(visitor);
                }
            }
            else if (onTriggerDesc is OnTriggerSplitStreamDesc)
            {
                OnTriggerSplitStreamDesc splits = (OnTriggerSplitStreamDesc)onTriggerDesc;
                foreach (OnTriggerSplitStream split in splits.SplitStreams)
                {
                    if (split.WhereClause != null)
                    {
                        split.WhereClause.Accept(visitor);
                    }
                    if (split.SelectClause.SelectExprList != null)
                    {
                        foreach (SelectClauseElementRaw element in split.SelectClause.SelectExprList)
                        {
                            if (element is SelectClauseExprRawSpec)
                            {
                                SelectClauseExprRawSpec selectExpr = (SelectClauseExprRawSpec)element;
                                selectExpr.SelectExpression.Accept(visitor);
                            }
                        }
                    }
                }
            }
            else if (onTriggerDesc is OnTriggerMergeDesc)
            {
                OnTriggerMergeDesc merge = (OnTriggerMergeDesc)onTriggerDesc;
                foreach (OnTriggerMergeMatched matched in merge.Items)
                {
                    if (matched.OptionalMatchCond != null)
                    {
                        matched.OptionalMatchCond.Accept(visitor);
                    }
                    foreach (OnTriggerMergeAction action in matched.Actions)
                    {
                        if (action.OptionalWhereClause != null)
                        {
                            action.OptionalWhereClause.Accept(visitor);
                        }

                        if (action is OnTriggerMergeActionUpdate)
                        {
                            OnTriggerMergeActionUpdate update = (OnTriggerMergeActionUpdate)action;
                            foreach (OnTriggerSetAssignment assignment in update.Assignments)
                            {
                                assignment.Expression.Accept(visitor);
                            }
                        }
                        if (action is OnTriggerMergeActionInsert)
                        {
                            OnTriggerMergeActionInsert insert = (OnTriggerMergeActionInsert)action;
                            foreach (SelectClauseElementRaw element in insert.SelectClause)
                            {
                                if (element is SelectClauseExprRawSpec)
                                {
                                    SelectClauseExprRawSpec selectExpr = (SelectClauseExprRawSpec)element;
                                    selectExpr.SelectExpression.Accept(visitor);
                                }
                            }
                        }
                    }
                }
            }
        }