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); }