public UniformPair <EventBean[]> ProcessOutputLimitedView(IList <UniformPair <EventBean[]> > viewEventsList, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
        {
            if (outputLimitLimitType == OutputLimitLimitType.LAST)
            {
                // For last, if there are no events:
                //   As insert stream, return the current value, if matching the having clause
                //   As remove stream, return the current value, if matching the having clause
                // For last, if there are events in the batch:
                //   As insert stream, return the newest value that is matching the having clause
                //   As remove stream, return the oldest value that is matching the having clause

                EventBean   lastOldEvent    = null;
                EventBean   lastNewEvent    = null;
                EventBean[] eventsPerStream = new EventBean[1];

                // if empty (nothing to post)
                if (viewEventsList.IsEmpty())
                {
                    if (Prototype.IsSelectRStream)
                    {
                        lastOldEvent = GetSelectListEvent(false, generateSynthetic, false);
                        lastNewEvent = lastOldEvent;
                    }
                    else
                    {
                        lastNewEvent = GetSelectListEvent(false, generateSynthetic, false);
                    }
                }

                foreach (UniformPair <EventBean[]> pair in viewEventsList)
                {
                    EventBean[] newData = pair.First;
                    EventBean[] oldData = pair.Second;

                    if ((lastOldEvent == null) && (Prototype.IsSelectRStream))
                    {
                        lastOldEvent = GetSelectListEvent(false, generateSynthetic, false);
                    }

                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (EventBean aNewData in newData)
                        {
                            eventsPerStream[0] = aNewData;
                            AggregationService.ApplyEnter(eventsPerStream, null, ExprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (EventBean anOldData in oldData)
                        {
                            eventsPerStream[0] = anOldData;
                            AggregationService.ApplyLeave(eventsPerStream, null, ExprEvaluatorContext);
                        }
                    }

                    lastNewEvent = GetSelectListEvent(false, generateSynthetic, false);
                }

                EventBean[] lastNew = (lastNewEvent != null) ? new EventBean[] { lastNewEvent } : null;
                EventBean[] lastOld = (lastOldEvent != null) ? new EventBean[] { lastOldEvent } : null;

                if ((lastNew == null) && (lastOld == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(lastNew, lastOld));
            }
            else
            {
                ICollection <EventBean> newEvents = new List <EventBean>();
                ICollection <EventBean> oldEvents = null;
                if (Prototype.IsSelectRStream)
                {
                    oldEvents = new LinkedList <EventBean>();
                }

                ICollection <Object> newEventsSortKey = null;
                ICollection <Object> oldEventsSortKey = null;
                if (_orderByProcessor != null)
                {
                    newEventsSortKey = new LinkedList <Object>();
                    if (Prototype.IsSelectRStream)
                    {
                        oldEventsSortKey = new LinkedList <Object>();
                    }
                }

                foreach (UniformPair <EventBean[]> pair in viewEventsList)
                {
                    EventBean[] newData = pair.First;
                    EventBean[] oldData = pair.Second;

                    if (Prototype.IsSelectRStream)
                    {
                        GetSelectListEvent(false, generateSynthetic, oldEvents, false);
                    }

                    EventBean[] eventsPerStream = new EventBean[1];
                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (EventBean aNewData in newData)
                        {
                            eventsPerStream[0] = aNewData;
                            AggregationService.ApplyEnter(eventsPerStream, null, ExprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (EventBean anOldData in oldData)
                        {
                            eventsPerStream[0] = anOldData;
                            AggregationService.ApplyLeave(eventsPerStream, null, ExprEvaluatorContext);
                        }
                    }

                    GetSelectListEvent(true, generateSynthetic, newEvents, false);
                }

                EventBean[] newEventsArr = (newEvents.IsEmpty()) ? null : newEvents.ToArray();
                EventBean[] oldEventsArr = null;
                if (Prototype.IsSelectRStream)
                {
                    oldEventsArr = (oldEvents.IsEmpty()) ? null : oldEvents.ToArray();
                }
                if (_orderByProcessor != null)
                {
                    Object[] sortKeysNew = (newEventsSortKey.IsEmpty()) ? null : newEventsSortKey.ToArray();
                    newEventsArr = _orderByProcessor.Sort(newEventsArr, sortKeysNew, ExprEvaluatorContext);
                    if (Prototype.IsSelectRStream)
                    {
                        Object[] sortKeysOld = (oldEventsSortKey.IsEmpty()) ? null : oldEventsSortKey.ToArray();
                        oldEventsArr = _orderByProcessor.Sort(oldEventsArr, sortKeysOld, ExprEvaluatorContext);
                    }
                }

                if (viewEventsList.IsEmpty())
                {
                    if (Prototype.IsSelectRStream)
                    {
                        oldEventsArr = GetSelectListEvents(false, generateSynthetic, false);
                    }
                    newEventsArr = GetSelectListEvents(true, generateSynthetic, false);
                }

                if ((newEventsArr == null) && (oldEventsArr == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(newEventsArr, oldEventsArr));
            }
        }
 public UniformPair <EventBean[]> ProcessOutputLimitedJoin(IList <UniformPair <ISet <MultiKey <EventBean> > > > joinEventsSet, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
 {
     if (outputLimitLimitType == OutputLimitLimitType.LAST)
     {
         return(ProcessOutputLimitedJoinLast(joinEventsSet, generateSynthetic));
     }
     else
     {
         return(ProcessOutputLimitedJoinDefault(joinEventsSet, generateSynthetic));
     }
 }
 public UniformPair <EventBean[]> ProcessOutputLimitedView(IList <UniformPair <EventBean[]> > viewEventsList, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
 {
     if (outputLimitLimitType == OutputLimitLimitType.LAST)
     {
         return(ProcessOutputLimitedViewLast(viewEventsList, generateSynthetic));
     }
     else
     {
         return(ProcessOutputLimitedViewDefault(viewEventsList, generateSynthetic));
     }
 }
        public UniformPair <EventBean[]> ProcessOutputLimitedJoin(IList <UniformPair <ISet <MultiKey <EventBean> > > > joinEventsSet, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
        {
            if (outputLimitLimitType == OutputLimitLimitType.LAST)
            {
                EventBean lastOldEvent = null;
                EventBean lastNewEvent = null;

                // if empty (nothing to post)
                if (joinEventsSet.IsEmpty())
                {
                    if (Prototype.IsSelectRStream)
                    {
                        lastOldEvent = GetSelectListEvent(false, generateSynthetic, true);
                        lastNewEvent = lastOldEvent;
                    }
                    else
                    {
                        lastNewEvent = GetSelectListEvent(false, generateSynthetic, true);
                    }
                }

                foreach (UniformPair <ISet <MultiKey <EventBean> > > pair in joinEventsSet)
                {
                    if (Prototype.IsUnidirectional)
                    {
                        Clear();
                    }

                    ICollection <MultiKey <EventBean> > newData = pair.First;
                    ICollection <MultiKey <EventBean> > oldData = pair.Second;

                    if ((lastOldEvent == null) && (Prototype.IsSelectRStream))
                    {
                        lastOldEvent = GetSelectListEvent(false, generateSynthetic, true);
                    }

                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (MultiKey <EventBean> eventsPerStream in newData)
                        {
                            AggregationService.ApplyEnter(eventsPerStream.Array, null, ExprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (MultiKey <EventBean> eventsPerStream in oldData)
                        {
                            AggregationService.ApplyLeave(eventsPerStream.Array, null, ExprEvaluatorContext);
                        }
                    }

                    lastNewEvent = GetSelectListEvent(true, generateSynthetic, true);
                }

                EventBean[] lastNew = (lastNewEvent != null) ? new EventBean[] { lastNewEvent } : null;
                EventBean[] lastOld = (lastOldEvent != null) ? new EventBean[] { lastOldEvent } : null;

                if ((lastNew == null) && (lastOld == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(lastNew, lastOld));
            }
            else
            {
                ICollection <EventBean> newEvents = new List <EventBean>();
                ICollection <EventBean> oldEvents = null;
                if (Prototype.IsSelectRStream)
                {
                    oldEvents = new LinkedList <EventBean>();
                }

                ICollection <Object> newEventsSortKey = null;
                ICollection <Object> oldEventsSortKey = null;
                if (_orderByProcessor != null)
                {
                    newEventsSortKey = new LinkedList <Object>();
                    if (Prototype.IsSelectRStream)
                    {
                        oldEventsSortKey = new LinkedList <Object>();
                    }
                }

                foreach (UniformPair <ISet <MultiKey <EventBean> > > pair in joinEventsSet)
                {
                    if (Prototype.IsUnidirectional)
                    {
                        Clear();
                    }

                    ICollection <MultiKey <EventBean> > newData = pair.First;
                    ICollection <MultiKey <EventBean> > oldData = pair.Second;

                    if (Prototype.IsSelectRStream)
                    {
                        GetSelectListEvent(false, generateSynthetic, oldEvents, true);
                    }

                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (MultiKey <EventBean> row in newData)
                        {
                            AggregationService.ApplyEnter(row.Array, null, ExprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (MultiKey <EventBean> row in oldData)
                        {
                            AggregationService.ApplyLeave(row.Array, null, ExprEvaluatorContext);
                        }
                    }

                    GetSelectListEvent(false, generateSynthetic, newEvents, true);
                }

                EventBean[] newEventsArr = (newEvents.IsEmpty()) ? null : newEvents.ToArray();
                EventBean[] oldEventsArr = null;
                if (Prototype.IsSelectRStream)
                {
                    oldEventsArr = (oldEvents.IsEmpty()) ? null : oldEvents.ToArray();
                }

                if (_orderByProcessor != null)
                {
                    Object[] sortKeysNew = (newEventsSortKey.IsEmpty()) ? null : newEventsSortKey.ToArray();
                    newEventsArr = _orderByProcessor.Sort(newEventsArr, sortKeysNew, ExprEvaluatorContext);
                    if (Prototype.IsSelectRStream)
                    {
                        Object[] sortKeysOld = (oldEventsSortKey.IsEmpty()) ? null : oldEventsSortKey.ToArray();
                        oldEventsArr = _orderByProcessor.Sort(oldEventsArr, sortKeysOld, ExprEvaluatorContext);
                    }
                }

                if (joinEventsSet.IsEmpty())
                {
                    if (Prototype.IsSelectRStream)
                    {
                        oldEventsArr = GetSelectListEvents(false, generateSynthetic, true);
                    }
                    newEventsArr = GetSelectListEvents(true, generateSynthetic, true);
                }

                if ((newEventsArr == null) && (oldEventsArr == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(newEventsArr, oldEventsArr));
            }
        }
Exemplo n.º 5
0
        public UniformPair <EventBean[]> ProcessOutputLimitedView(IList <UniformPair <EventBean[]> > viewEventsList, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
        {
            if (outputLimitLimitType == OutputLimitLimitType.LAST)
            {
                EventBean   lastOldEvent    = null;
                EventBean   lastNewEvent    = null;
                EventBean[] eventsPerStream = new EventBean[1];

                foreach (UniformPair <EventBean[]> pair in viewEventsList)
                {
                    EventBean[] newData = pair.First;
                    EventBean[] oldData = pair.Second;

                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (EventBean aNewData in newData)
                        {
                            eventsPerStream[0] = aNewData;
                            _aggregationService.ApplyEnter(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (EventBean anOldData in oldData)
                        {
                            eventsPerStream[0] = anOldData;
                            _aggregationService.ApplyLeave(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }

                    EventBean[] selectOldEvents;
                    if (_prototype.IsSelectRStream)
                    {
                        if (_prototype.OptionalHavingNode == null)
                        {
                            selectOldEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, _exprEvaluatorContext);
                        }
                        else
                        {
                            selectOldEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, _exprEvaluatorContext);
                        }
                        if ((selectOldEvents != null) && (selectOldEvents.Length > 0))
                        {
                            lastOldEvent = selectOldEvents[selectOldEvents.Length - 1];
                        }
                    }

                    // generate new events using select expressions
                    EventBean[] selectNewEvents;
                    if (_prototype.OptionalHavingNode == null)
                    {
                        selectNewEvents = ResultSetProcessorUtil.GetSelectEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, _exprEvaluatorContext);
                    }
                    else
                    {
                        selectNewEvents = ResultSetProcessorUtil.GetSelectEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, _exprEvaluatorContext);
                    }
                    if ((selectNewEvents != null) && (selectNewEvents.Length > 0))
                    {
                        lastNewEvent = selectNewEvents[selectNewEvents.Length - 1];
                    }
                }

                EventBean[] lastNew = (lastNewEvent != null) ? new EventBean[] { lastNewEvent } : null;
                EventBean[] lastOld = (lastOldEvent != null) ? new EventBean[] { lastOldEvent } : null;

                if ((lastNew == null) && (lastOld == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(lastNew, lastOld));
            }
            else
            {
                ICollection <EventBean> newEvents = new List <EventBean>();
                ICollection <EventBean> oldEvents = null;
                if (_prototype.IsSelectRStream)
                {
                    oldEvents = new LinkedList <EventBean>();
                }
                ICollection <Object> newEventsSortKey = null;
                ICollection <Object> oldEventsSortKey = null;
                if (_orderByProcessor != null)
                {
                    newEventsSortKey = new LinkedList <Object>();
                    if (_prototype.IsSelectRStream)
                    {
                        oldEventsSortKey = new LinkedList <Object>();
                    }
                }

                foreach (UniformPair <EventBean[]> pair in viewEventsList)
                {
                    EventBean[] newData = pair.First;
                    EventBean[] oldData = pair.Second;

                    EventBean[] eventsPerStream = new EventBean[1];
                    if (newData != null)
                    {
                        // apply new data to aggregates
                        foreach (EventBean aNewData in newData)
                        {
                            eventsPerStream[0] = aNewData;
                            _aggregationService.ApplyEnter(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }
                    if (oldData != null)
                    {
                        // apply old data to aggregates
                        foreach (EventBean anOldData in oldData)
                        {
                            eventsPerStream[0] = anOldData;
                            _aggregationService.ApplyLeave(eventsPerStream, null, _exprEvaluatorContext);
                        }
                    }

                    // generate old events using select expressions
                    if (_prototype.IsSelectRStream)
                    {
                        if (_prototype.OptionalHavingNode == null)
                        {
                            if (_orderByProcessor == null)
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsNoHaving(_selectExprProcessor, oldData, false, generateSynthetic, oldEvents, _exprEvaluatorContext);
                            }
                            else
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, false, generateSynthetic, oldEvents, oldEventsSortKey, _exprEvaluatorContext);
                            }
                        }
                        // generate old events using having then select
                        else
                        {
                            if (_orderByProcessor == null)
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsHaving(_selectExprProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, oldEvents, _exprEvaluatorContext);
                            }
                            else
                            {
                                ResultSetProcessorUtil.PopulateSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, oldData, _prototype.OptionalHavingNode, false, generateSynthetic, oldEvents, oldEventsSortKey, _exprEvaluatorContext);
                            }
                        }
                    }

                    // generate new events using select expressions
                    if (_prototype.OptionalHavingNode == null)
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsNoHaving(_selectExprProcessor, newData, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsNoHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, true, generateSynthetic, newEvents, newEventsSortKey, _exprEvaluatorContext);
                        }
                    }
                    else
                    {
                        if (_orderByProcessor == null)
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsHaving(_selectExprProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, newEvents, _exprEvaluatorContext);
                        }
                        else
                        {
                            ResultSetProcessorUtil.PopulateSelectEventsHavingWithOrderBy(_selectExprProcessor, _orderByProcessor, newData, _prototype.OptionalHavingNode, true, generateSynthetic, newEvents, newEventsSortKey, _exprEvaluatorContext);
                        }
                    }
                }

                EventBean[] newEventsArr = (newEvents.IsEmpty()) ? null : newEvents.ToArray();
                EventBean[] oldEventsArr = null;
                if (_prototype.IsSelectRStream)
                {
                    oldEventsArr = (oldEvents.IsEmpty()) ? null : oldEvents.ToArray();
                }
                if (_orderByProcessor != null)
                {
                    Object[] sortKeysNew = (newEventsSortKey.IsEmpty()) ? null : newEventsSortKey.ToArray();
                    newEventsArr = _orderByProcessor.Sort(newEventsArr, sortKeysNew, _exprEvaluatorContext);

                    if (_prototype.IsSelectRStream)
                    {
                        Object[] sortKeysOld = (oldEventsSortKey.IsEmpty()) ? null : oldEventsSortKey.ToArray();
                        oldEventsArr = _orderByProcessor.Sort(oldEventsArr, sortKeysOld, _exprEvaluatorContext);
                    }
                }

                if ((newEventsArr == null) && (oldEventsArr == null))
                {
                    return(null);
                }
                return(new UniformPair <EventBean[]>(newEventsArr, oldEventsArr));
            }
        }
Exemplo n.º 6
0
 public OutputLimitSpec(OutputLimitLimitType displayLimit, OutputLimitRateType rateType)
     : this(null, null, rateType, displayLimit, null, null, null, null, null, null, false, null, null)
 {
 }
        /// <summary>Processes batched events in case of output-rate limiting.</summary>
        /// <param name="joinEventsSet">the join results</param>
        /// <param name="generateSynthetic">flag to indicate whether synthetic events must be generated</param>
        /// <param name="outputLimitLimitType">the type of output rate limiting</param>
        /// <returns>results for dispatch</returns>
        public virtual UniformPair <EventBean[]> ProcessOutputLimitedJoin(IList <UniformPair <ISet <MultiKey <EventBean> > > > joinEventsSet, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
        {
            if (outputLimitLimitType != OutputLimitLimitType.LAST)
            {
                var flattened = EventBeanUtility.FlattenBatchJoin(joinEventsSet);
                return(ProcessJoinResult(flattened.First, flattened.Second, generateSynthetic));
            }

            throw new IllegalStateException("Output last is provided by " + typeof(OutputProcessViewConditionLastAllUnord).Name);
        }
Exemplo n.º 8
0
 public UniformPair <EventBean[]> ProcessOutputLimitedView(IList <UniformPair <EventBean[]> > viewEventsList, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
 {
     return(null);
 }
Exemplo n.º 9
0
 public UniformPair <EventBean[]> ProcessOutputLimitedJoin(IList <UniformPair <ISet <MultiKey <EventBean> > > > joinEventsSet, bool generateSynthetic, OutputLimitLimitType outputLimitLimitType)
 {
     return(null);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Build an output limit spec from the AST node supplied.
        /// </summary>
        /// <param name="astExprNodeMap">is the map of current AST tree nodes to their respective expression root node</param>
        /// <param name="engineURI">the engine uri</param>
        /// <param name="timeProvider">provides time</param>
        /// <param name="variableService">provides variable resolution</param>
        /// <param name="exprEvaluatorContext">context for expression evaluatiom</param>
        /// <returns>output limit spec</returns>
        public static OutputLimitSpec BuildOutputLimitSpec(
            CommonTokenStream tokenStream,
            EsperEPL2GrammarParser.OutputLimitContext ctx,
            IDictionary <ITree, ExprNode> astExprNodeMap,
            VariableService variableService,
            String engineURI,
            TimeProvider timeProvider,
            ExprEvaluatorContext exprEvaluatorContext)
        {
            OutputLimitLimitType displayLimit = OutputLimitLimitType.DEFAULT;

            if (ctx.k != null)
            {
                switch (ctx.k.Type)
                {
                case EsperEPL2GrammarParser.FIRST: displayLimit = OutputLimitLimitType.FIRST; break;

                case EsperEPL2GrammarParser.LAST: displayLimit = OutputLimitLimitType.LAST; break;

                case EsperEPL2GrammarParser.SNAPSHOT: displayLimit = OutputLimitLimitType.SNAPSHOT; break;

                case EsperEPL2GrammarParser.ALL: displayLimit = OutputLimitLimitType.ALL; break;

                default: throw ASTWalkException.From("Encountered unrecognized token " + ctx.k.Text, tokenStream, ctx);
                }
            }

            // next is a variable, or time period, or number
            String           variableName                  = null;
            double?          rate                          = null;
            ExprNode         whenExpression                = null;
            IList <ExprNode> crontabScheduleSpec           = null;
            IList <OnTriggerSetAssignment> thenExpressions = null;
            ExprTimePeriod                 timePeriodExpr  = null;
            OutputLimitRateType            rateType;
            ExprNode                       andAfterTerminateExpr           = null;
            IList <OnTriggerSetAssignment> andAfterTerminateSetExpressions = null;

            if (ctx.t != null)
            {
                rateType = OutputLimitRateType.TERM;
                if (ctx.expression() != null)
                {
                    andAfterTerminateExpr = ASTExprHelper.ExprCollectSubNodes(ctx.expression(), 0, astExprNodeMap)[0];
                }
                if (ctx.onSetExpr() != null)
                {
                    andAfterTerminateSetExpressions = ASTExprHelper.GetOnTriggerSetAssignments(ctx.onSetExpr().onSetAssignmentList(), astExprNodeMap);
                }
            }
            else if (ctx.wh != null)
            {
                rateType       = OutputLimitRateType.WHEN_EXPRESSION;
                whenExpression = ASTExprHelper.ExprCollectSubNodes(ctx.expression(), 0, astExprNodeMap)[0];
                if (ctx.onSetExpr() != null)
                {
                    thenExpressions = ASTExprHelper.GetOnTriggerSetAssignments(ctx.onSetExpr().onSetAssignmentList(), astExprNodeMap);
                }
            }
            else if (ctx.at != null)
            {
                rateType            = OutputLimitRateType.CRONTAB;
                crontabScheduleSpec = ASTExprHelper.ExprCollectSubNodes(ctx.crontabLimitParameterSet(), 0, astExprNodeMap);
            }
            else
            {
                if (ctx.ev != null)
                {
                    rateType = ctx.e != null ? OutputLimitRateType.EVENTS : OutputLimitRateType.TIME_PERIOD;
                    if (ctx.i != null)
                    {
                        variableName = ctx.i.Text;
                    }
                    else if (ctx.timePeriod() != null)
                    {
                        timePeriodExpr = (ExprTimePeriod)ASTExprHelper.ExprCollectSubNodes(ctx.timePeriod(), 0, astExprNodeMap)[0];
                    }
                    else
                    {
                        ASTExprHelper.ExprCollectSubNodes(ctx.number(), 0, astExprNodeMap);  // remove
                        rate = Double.Parse(ctx.number().GetText());
                    }
                }
                else
                {
                    rateType = OutputLimitRateType.AFTER;
                }
            }

            // get the AFTER time period
            ExprTimePeriod afterTimePeriodExpr = null;
            int?           afterNumberOfEvents = null;

            if (ctx.outputLimitAfter() != null)
            {
                if (ctx.outputLimitAfter().timePeriod() != null)
                {
                    ExprNode expression = ASTExprHelper.ExprCollectSubNodes(ctx.outputLimitAfter(), 0, astExprNodeMap)[0];
                    afterTimePeriodExpr = (ExprTimePeriod)expression;
                }
                else
                {
                    Object constant = ASTConstantHelper.Parse(ctx.outputLimitAfter().number());
                    afterNumberOfEvents = constant.AsInt();
                }
            }

            bool andAfterTerminate = false;

            if (ctx.outputLimitAndTerm() != null)
            {
                andAfterTerminate = true;
                if (ctx.outputLimitAndTerm().expression() != null)
                {
                    andAfterTerminateExpr = ASTExprHelper.ExprCollectSubNodes(ctx.outputLimitAndTerm().expression(), 0, astExprNodeMap)[0];
                }
                if (ctx.outputLimitAndTerm().onSetExpr() != null)
                {
                    andAfterTerminateSetExpressions = ASTExprHelper.GetOnTriggerSetAssignments(ctx.outputLimitAndTerm().onSetExpr().onSetAssignmentList(), astExprNodeMap);
                }
            }

            return(new OutputLimitSpec(rate, variableName, rateType, displayLimit, whenExpression, thenExpressions, crontabScheduleSpec, timePeriodExpr, afterTimePeriodExpr, afterNumberOfEvents, andAfterTerminate, andAfterTerminateExpr, andAfterTerminateSetExpressions));
        }
Exemplo n.º 11
0
 public OutputProcessViewConditionFactory(StatementContext statementContext, OutputStrategyPostProcessFactory postProcessFactory, bool distinct, ExprTimePeriod afterTimePeriod, int?afterConditionNumberOfEvents, EventType resultEventType, OutputConditionFactory outputConditionFactory, int streamCount, ConditionType conditionType, OutputLimitLimitType outputLimitLimitType, bool terminable, bool hasAfter, bool isUnaggregatedUngrouped, SelectClauseStreamSelectorEnum selectClauseStreamSelectorEnum, ResultSetProcessorHelperFactory resultSetProcessorHelperFactory)
     : base(statementContext, postProcessFactory, resultSetProcessorHelperFactory, distinct, afterTimePeriod, afterConditionNumberOfEvents, resultEventType)
 {
     OutputConditionFactory = outputConditionFactory;
     StreamCount            = streamCount;
     _conditionType         = conditionType;
     OutputLimitLimitType   = outputLimitLimitType;
     IsTerminable           = terminable;
     HasAfter = hasAfter;
     IsUnaggregatedUngrouped          = isUnaggregatedUngrouped;
     SelectClauseStreamSelectorEnum   = selectClauseStreamSelectorEnum;
     _resultSetProcessorHelperFactory = resultSetProcessorHelperFactory;
 }