Package com.espertech.esper.view

Examples of com.espertech.esper.view.View


    public StatementAgentInstanceFactoryOnTriggerResult newContext(final AgentInstanceContext agentInstanceContext, boolean isRecoveringResilient)
    {
        final List<StopCallback> stopCallbacks = new ArrayList<StopCallback>();

        View onExprView;
        Map<ExprSubselectNode, SubSelectStrategyHolder> subselectStrategies;
        AggregationService aggregationService = null;
        EvalRootState optPatternRoot;

        try {
            if (services.getSchedulableAgentInstanceDirectory() != null) {
                services.getSchedulableAgentInstanceDirectory().add(agentInstanceContext.getEpStatementAgentInstanceHandle());
            }
            OnTriggerDesc onTriggerDesc = statementSpec.getOnTriggerDesc();

            // Start: for on-delete and on-select and on-update triggers
            if (onTriggerDesc instanceof OnTriggerWindowDesc)
            {
                OnTriggerWindowDesc onTriggerWindowDesc = (OnTriggerWindowDesc) onTriggerDesc;

                // get result set processor and aggregation services
                Pair<ResultSetProcessor, AggregationService> pair = EPStatementStartMethodHelperUtil.startResultSetAndAggregation(resultSetProcessorPrototype, agentInstanceContext);
                aggregationService = pair.getSecond();

                // get named window processor instance
                NamedWindowProcessor processor = services.getNamedWindowService().getProcessor(onTriggerWindowDesc.getWindowName());
                NamedWindowProcessorInstance processorInstance = processor.getProcessorInstance(agentInstanceContext);

                // obtain on-expr view
                NamedWindowOnExprBaseView onExprBaseView = processorInstance.getRootViewInstance().addOnExpr(onExprFactory, agentInstanceContext, validatedJoin, activatorResultEventType, pair.getFirst(), onTriggerWindowDesc.getOptionalAsName(), excludePlanHint, indexHint);
                onExprView = onExprBaseView;
                stopCallbacks.add(onExprBaseView);
            }
            // variable assignments
            else if (statementSpec.getOnTriggerDesc() instanceof OnTriggerSetDesc)
            {
                onExprView = onSetVariableViewFactory.instantiate(agentInstanceContext);
            }
            // split-stream use case
            else
            {
                ResultSetProcessor[] processors = new ResultSetProcessor[splitDesc.getProcessorFactories().length];
                for (int i = 0; i < processors.length; i++) {
                    ResultSetProcessorFactoryDesc factory = splitDesc.getProcessorFactories()[i];
                    ResultSetProcessor processor = factory.getResultSetProcessorFactory().instantiate(null, null, agentInstanceContext);
                    processors[i] = processor;
                }

                OnTriggerSplitStreamDesc desc = (OnTriggerSplitStreamDesc) statementSpec.getOnTriggerDesc();
                onExprView = new RouteResultView(desc.isFirst(), activatorResultEventType, statementContext.getEpStatementHandle(), services.getInternalEventRouter(), splitDesc.getNamedWindowInsert(), processors, splitDesc.getWhereClauses(), agentInstanceContext);
            }

            // attach stream to view
            final ViewableActivationResult activationResult = activator.activate(agentInstanceContext, false, isRecoveringResilient);
            activationResult.getViewable().addView(onExprView);
            stopCallbacks.add(activationResult.getStopCallback());
            optPatternRoot = activationResult.getOptionalPatternRoot();

            // start subselects
            subselectStrategies = EPStatementStartMethodHelperSubselect.startSubselects(services, subSelectStrategyCollection, agentInstanceContext, stopCallbacks);

            // attach view to output: for on-delete, create an output processor that passes on as a wildcard the underlying event
            if ((statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_DELETE) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_SET) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_UPDATE) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_MERGE))
            {
                ResultSetProcessor outputResultSetProcessor = outputResultSetProcessorPrototype.getResultSetProcessorFactory().instantiate(null, null, agentInstanceContext);

                // Attach output view
                View outputView = outputProcessViewFactory.makeView(outputResultSetProcessor, agentInstanceContext);
                onExprView.addView(outputView);
                onExprView = outputView;
            }
        }
        catch (RuntimeException ex) {
View Full Code Here


    public StatementAgentInstanceFactoryOnTriggerResult newContext(final AgentInstanceContext agentInstanceContext, boolean isRecoveringResilient)
    {
        final List<StopCallback> stopCallbacks = new ArrayList<StopCallback>();

        View onExprView;
        Map<ExprSubselectNode, SubSelectStrategyHolder> subselectStrategies;
        AggregationService aggregationService = null;
        EvalRootState optPatternRoot;

        try {
            if (services.getSchedulableAgentInstanceDirectory() != null) {
                services.getSchedulableAgentInstanceDirectory().add(agentInstanceContext.getEpStatementAgentInstanceHandle());
            }
            OnTriggerDesc onTriggerDesc = statementSpec.getOnTriggerDesc();

            // Start: for on-delete and on-select and on-update triggers
            if (onTriggerDesc instanceof OnTriggerWindowDesc)
            {
                OnTriggerWindowDesc onTriggerWindowDesc = (OnTriggerWindowDesc) onTriggerDesc;

                // get result set processor and aggregation services
                Pair<ResultSetProcessor, AggregationService> pair = EPStatementStartMethodHelperUtil.startResultSetAndAggregation(resultSetProcessorPrototype, agentInstanceContext);
                aggregationService = pair.getSecond();

                // get named window processor instance
                NamedWindowProcessor processor = services.getNamedWindowService().getProcessor(onTriggerWindowDesc.getWindowName());
                NamedWindowProcessorInstance processorInstance = processor.getProcessorInstance(agentInstanceContext);

                // obtain on-expr view
                NamedWindowOnExprBaseView onExprBaseView = processorInstance.getRootViewInstance().addOnExpr(onExprFactory, agentInstanceContext, validatedJoin, activatorResultEventType, pair.getFirst());
                onExprView = onExprBaseView;
                stopCallbacks.add(onExprBaseView);
            }
            // variable assignments
            else if (statementSpec.getOnTriggerDesc() instanceof OnTriggerSetDesc)
            {
                onExprView = onSetVariableViewFactory.instantiate(agentInstanceContext);
            }
            // split-stream use case
            else
            {
                ResultSetProcessor[] processors = new ResultSetProcessor[splitDesc.getProcessorFactories().length];
                for (int i = 0; i < processors.length; i++) {
                    ResultSetProcessorFactoryDesc factory = splitDesc.getProcessorFactories()[i];
                    ResultSetProcessor processor = factory.getResultSetProcessorFactory().instantiate(null, null, agentInstanceContext);
                    processors[i] = processor;
                }

                OnTriggerSplitStreamDesc desc = (OnTriggerSplitStreamDesc) statementSpec.getOnTriggerDesc();
                onExprView = new RouteResultView(desc.isFirst(), activatorResultEventType, statementContext.getEpStatementHandle(), services.getInternalEventRouter(), splitDesc.getNamedWindowInsert(), processors, splitDesc.getWhereClauses(), agentInstanceContext);
            }

            // attach stream to view
            final ViewableActivationResult activationResult = activator.activate(agentInstanceContext, false, isRecoveringResilient);
            activationResult.getViewable().addView(onExprView);
            stopCallbacks.add(activationResult.getStopCallback());
            optPatternRoot = activationResult.getOptionalPatternRoot();

            // start subselects
            subselectStrategies = EPStatementStartMethodHelperSubselect.startSubselects(services, subSelectStrategyCollection, agentInstanceContext, stopCallbacks);

            // attach view to output: for on-delete, create an output processor that passes on as a wildcard the underlying event
            if ((statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_DELETE) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_SET) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_UPDATE) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_MERGE))
            {
                ResultSetProcessor outputResultSetProcessor = outputResultSetProcessorPrototype.getResultSetProcessorFactory().instantiate(null, null, agentInstanceContext);

                // Attach output view
                View outputView = outputProcessViewFactory.makeView(outputResultSetProcessor, agentInstanceContext);
                onExprView.addView(outputView);
                onExprView = outputView;
            }
        }
        catch (RuntimeException ex) {
View Full Code Here

        else {
            // For each child node
            ArrayList<View> subViewList = new ArrayList<View>(4);
            subviewHolder = subViewList;
            for (View originalChildView : groupView.getViews()) {
                View copyChildView = copyChildView(groupView, propertyNames, groupByValues, agentInstanceContext, originalChildView);
                subViewList.add(copyChildView);
            }
        }

        return subviewHolder;
View Full Code Here

            throw new EPException("Unexpected error copying subview " + originalChildView.getClass().getName());
        }
        CloneableView cloneableView = (CloneableView) originalChildView;

        // Copy child node
        View copyChildView = cloneableView.cloneView();
        copyChildView.setParent(groupView);

        // Make the sub views for child copying from the original to the child
        copySubViews(groupView.getCriteriaExpressions(), propertyNames, groupByValues, originalChildView, copyChildView,
                agentInstanceContext);
View Full Code Here

            if (!(subView instanceof CloneableView))
            {
                throw new EPException("Unexpected error copying subview");
            }
            CloneableView cloneableView = (CloneableView) subView;
            View copiedChild = cloneableView.cloneView();
            copyView.addView(copiedChild);

            // Make the sub views for child
            copySubViews(criteriaExpressions, propertyNames, groupByValues, subView, copiedChild, agentInstanceContext);
        }
View Full Code Here

            public void stop() {
                StatementAgentInstanceUtil.stopSafe(agentInstanceContext.getTerminationCallbacks(), stopCallbacks, statementContext);
            }
        };

        View onExprView;
        Map<ExprSubselectNode, SubSelectStrategyHolder> subselectStrategies;
        AggregationService aggregationService = null;
        EvalRootState optPatternRoot;

        try {
            if (services.getSchedulableAgentInstanceDirectory() != null) {
                services.getSchedulableAgentInstanceDirectory().add(agentInstanceContext.getEpStatementAgentInstanceHandle());
            }
            OnTriggerDesc onTriggerDesc = statementSpec.getOnTriggerDesc();

            // Start: for on-delete and on-select and on-update triggers
            if (onTriggerDesc instanceof OnTriggerWindowDesc)
            {
                OnTriggerWindowDesc onTriggerWindowDesc = (OnTriggerWindowDesc) onTriggerDesc;

                // get result set processor and aggregation services
                Pair<ResultSetProcessor, AggregationService> pair = EPStatementStartMethodHelperUtil.startResultSetAndAggregation(resultSetProcessorPrototype, agentInstanceContext);
                aggregationService = pair.getSecond();

                // get named window processor instance
                NamedWindowProcessor processor = services.getNamedWindowService().getProcessor(onTriggerWindowDesc.getWindowName());
                NamedWindowProcessorInstance processorInstance = processor.getProcessorInstance(agentInstanceContext);

                // obtain on-expr view
                NamedWindowOnExprBaseView onExprBaseView = processorInstance.getRootViewInstance().addOnExpr(onExprFactory, agentInstanceContext, validatedJoin, activatorResultEventType, pair.getFirst());
                onExprView = onExprBaseView;
                stopCallbacks.add(onExprBaseView);
            }
            // variable assignments
            else if (statementSpec.getOnTriggerDesc() instanceof OnTriggerSetDesc)
            {
                onExprView = onSetVariableViewFactory.instantiate(agentInstanceContext);
            }
            // split-stream use case
            else
            {
                ResultSetProcessor[] processors = new ResultSetProcessor[splitDesc.getProcessorFactories().length];
                for (int i = 0; i < processors.length; i++) {
                    ResultSetProcessorFactoryDesc factory = splitDesc.getProcessorFactories()[i];
                    ResultSetProcessor processor = factory.getResultSetProcessorFactory().instantiate(null, null, agentInstanceContext);
                    processors[i] = processor;
                }

                OnTriggerSplitStreamDesc desc = (OnTriggerSplitStreamDesc) statementSpec.getOnTriggerDesc();
                onExprView = new RouteResultView(desc.isFirst(), activatorResultEventType, statementContext.getEpStatementHandle(), services.getInternalEventRouter(), splitDesc.getNamedWindowInsert(), processors, splitDesc.getWhereClauses(), statementContext);
            }

            // attach stream to view
            final ViewableActivationResult activationResult = activator.activate(agentInstanceContext, false, isRecoveringResilient);
            activationResult.getViewable().addView(onExprView);
            stopCallbacks.add(activationResult.getStopCallback());
            optPatternRoot = activationResult.getOptionalPatternRoot();

            // start subselects
            subselectStrategies = EPStatementStartMethodHelperSubselect.startSubselects(services, subSelectStrategyCollection, agentInstanceContext, stopCallbacks);

            // attach view to output: for on-delete, create an output processor that passes on as a wildcard the underlying event
            if ((statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_DELETE) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_SET) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_UPDATE) ||
                (statementSpec.getOnTriggerDesc().getOnTriggerType() == OnTriggerType.ON_MERGE))
            {
                ResultSetProcessor outputResultSetProcessor = outputResultSetProcessorPrototype.getResultSetProcessorFactory().instantiate(null, null, agentInstanceContext);

                // Attach output view
                View outputView = outputProcessViewFactory.makeView(outputResultSetProcessor, agentInstanceContext);
                onExprView.addView(outputView);
                onExprView = outputView;
            }
        }
        catch (RuntimeException ex) {
View Full Code Here

TOP

Related Classes of com.espertech.esper.view.View

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.