Esempio n. 1
0
        public EPPreparedQueryResult Execute(
            FAFQueryMethodSelect select,
            ContextPartitionSelector[] contextPartitionSelectors,
            FAFQueryMethodAssignerSetter assignerSetter,
            ContextManagementService contextManagementService)
        {
            FireAndForgetProcessor processor = select.Processors[0];
            FireAndForgetInstance processorInstance = processor.ProcessorInstanceNoContext;

            ICollection<EventBean> events;
            AgentInstanceContext agentInstanceContext = null;
            if (processorInstance == null) {
                events = EmptyList<EventBean>.Instance;
            }
            else {
                agentInstanceContext = processorInstance.AgentInstanceContext;
                events = Snapshot(select.ConsumerFilters[0], processorInstance, select.QueryGraph, select.Annotations);
            }

            // get RSP
            ResultSetProcessor resultSetProcessor = ProcessorWithAssign(
                select.ResultSetProcessorFactoryProvider,
                agentInstanceContext,
                assignerSetter,
                select.TableAccesses,
                select.Subselects);

            if (select.WhereClause != null) {
                events = Filtered(events, select.WhereClause, agentInstanceContext);
            }

            return ProcessedNonJoin(resultSetProcessor, events, select.DistinctKeyGetter);
        }
Esempio n. 2
0
 public EPPreparedQueryResult Execute(
     FAFQueryMethodSelect select,
     ContextPartitionSelector[] contextPartitionSelectors,
     FAFQueryMethodAssignerSetter assignerSetter,
     ContextManagementService contextManagementService)
 {
     throw new UnsupportedOperationException("Context with join is not supported");
 }
Esempio n. 3
0
        public EPPreparedQueryResult Execute(
            FAFQueryMethodSelect select,
            ContextPartitionSelector[] contextPartitionSelectors,
            FAFQueryMethodAssignerSetter assignerSetter,
            ContextManagementService contextManagementService)
        {
            var processor = select.Processors[0];

            var singleSelector = contextPartitionSelectors != null && contextPartitionSelectors.Length > 0
                ? contextPartitionSelectors[0]
                : null;
            var agentInstanceIds = AgentInstanceIds(processor, singleSelector, contextManagementService);

            IList<ContextPartitionResult> contextPartitionResults = new List<ContextPartitionResult>();
            foreach (var agentInstanceId in agentInstanceIds) {
                var processorInstance = processor.GetProcessorInstanceContextById(agentInstanceId);
                if (processorInstance != null) {
                    var coll = processorInstance.SnapshotBestEffort(select.QueryGraph, select.Annotations);
                    contextPartitionResults.Add(
                        new ContextPartitionResult(coll, processorInstance.AgentInstanceContext));
                }
            }

            // process context partitions
            var events = new ArrayDeque<EventBean[]>();
            ResultSetProcessor resultSetProcessor = null;
            foreach (var contextPartitionResult in contextPartitionResults) {
                if (resultSetProcessor == null) {
                    resultSetProcessor = ProcessorWithAssign(
                        select.ResultSetProcessorFactoryProvider,
                        contextPartitionResult.Context,
                        assignerSetter,
                        select.TableAccesses);
                }

                var snapshot = contextPartitionResult.Events;
                if (select.WhereClause != null) {
                    snapshot = Filtered(
                        snapshot,
                        select.WhereClause,
                        contextPartitionResult.Context);
                }

                var rows = snapshot.ToArray();
                resultSetProcessor.SetAgentInstanceContext(contextPartitionResult.Context);
                var results = resultSetProcessor.ProcessViewResult(rows, null, true);
                if (results != null && results.First != null && results.First.Length > 0) {
                    events.Add(results.First);
                }
            }

            var distinct = EventBeanUtility.GetDistinctByProp(
                EventBeanUtility.Flatten(events),
                select.EventBeanReaderDistinct);
            return new EPPreparedQueryResult(select.EventType, distinct);
        }
Esempio n. 4
0
        public EPPreparedQueryResult Execute(
            FAFQueryMethodSelect select,
            ContextPartitionSelector[] contextPartitionSelectors,
            FAFQueryMethodAssignerSetter assignerSetter,
            ContextManagementService contextManagementService)
        {
            FireAndForgetProcessor processor = select.Processors[0];

            ContextPartitionSelector singleSelector =
                contextPartitionSelectors != null && contextPartitionSelectors.Length > 0
                    ? contextPartitionSelectors[0]
                    : null;
            ICollection<int> agentInstanceIds = AgentInstanceIds(processor, singleSelector, contextManagementService);

            ICollection<EventBean> events = new ArrayDeque<EventBean>();
            AgentInstanceContext agentInstanceContext = null;
            foreach (int agentInstanceId in agentInstanceIds) {
                FireAndForgetInstance processorInstance = processor.GetProcessorInstanceContextById(agentInstanceId);
                if (processorInstance != null) {
                    agentInstanceContext = processorInstance.AgentInstanceContext;
                    ICollection<EventBean> coll = processorInstance.SnapshotBestEffort(
                        select.QueryGraph,
                        select.Annotations);
                    events.AddAll(coll);
                }
            }

            // get RSP
            ResultSetProcessor resultSetProcessor = ProcessorWithAssign(
                select.ResultSetProcessorFactoryProvider,
                agentInstanceContext,
                assignerSetter,
                select.TableAccesses,
                select.Subselects);

            if (select.WhereClause != null) {
                events = Filtered(events, select.WhereClause, agentInstanceContext);
            }

            return ProcessedNonJoin(resultSetProcessor, events, select.DistinctKeyGetter);
        }
        public EPPreparedQueryResult Execute(
            FAFQueryMethodSelect select,
            ContextPartitionSelector[] contextPartitionSelectors,
            FAFQueryMethodAssignerSetter assignerSetter,
            ContextManagementService contextManagementService)
        {
            int numStreams = select.Processors.Length;
            ICollection<EventBean>[] snapshots = new ICollection<EventBean>[numStreams];

            AgentInstanceContext agentInstanceContext = null;
            Viewable[] viewablePerStream = new Viewable[numStreams];

            for (int i = 0; i < numStreams; i++) {
                FireAndForgetProcessor processor = select.Processors[i];
                FireAndForgetInstance processorInstance = processor.ProcessorInstanceNoContext;
                snapshots[i] = Snapshot(
                    select.ConsumerFilters[i],
                    processorInstance,
                    select.QueryGraph,
                    select.Annotations);
                agentInstanceContext = processorInstance.AgentInstanceContext;
                viewablePerStream[i] = processorInstance.TailViewInstance;
            }

            // get RSP
            ResultSetProcessor resultSetProcessor = ProcessorWithAssign(
                select.ResultSetProcessorFactoryProvider,
                agentInstanceContext,
                assignerSetter,
                select.TableAccesses,
                select.Subselects);

            // determine join
            JoinSetComposerDesc joinSetComposerDesc = select.JoinSetComposerPrototype.Create(
                viewablePerStream,
                true,
                agentInstanceContext,
                false);
            JoinSetComposer joinComposer = joinSetComposerDesc.JoinSetComposer;

            EventBean[][] oldDataPerStream = new EventBean[numStreams][];
            EventBean[][] newDataPerStream = new EventBean[numStreams][];
            for (int i = 0; i < numStreams; i++) {
                newDataPerStream[i] = snapshots[i].ToArray();
            }

            UniformPair<ISet<MultiKeyArrayOfKeys<EventBean>>> result = joinComposer.Join(
                newDataPerStream,
                oldDataPerStream,
                agentInstanceContext);
            if (joinSetComposerDesc.PostJoinFilterEvaluator != null) {
                JoinSetComposerUtil.Filter(
                    joinSetComposerDesc.PostJoinFilterEvaluator,
                    result.First,
                    true,
                    agentInstanceContext);
            }

            UniformPair<EventBean[]> results = resultSetProcessor.ProcessJoinResult(result.First, null, true);

            EventBean[] distinct = EventBeanUtility.GetDistinctByProp(results.First, select.DistinctKeyGetter);

            return new EPPreparedQueryResult(resultSetProcessor.ResultEventType, distinct);
        }