Collection<Integer> agentInstanceIds;
if (contextPartitionSelectors == null || contextPartitionSelectors[0] instanceof ContextPartitionSelectorAll) {
agentInstanceIds = processors[0].getProcessorInstancesAll();
}
else {
ContextManager contextManager = services.getContextManagementService().getContextManager(statementSpec.getOptionalContextName());
agentInstanceIds = contextManager.getAgentInstanceIds(contextPartitionSelectors[0]);
}
// collect events and agent instances
for (int agentInstanceId : agentInstanceIds) {
NamedWindowProcessorInstance processorInstance = processors[0].getProcessorInstance(agentInstanceId);