if (processorInstance != null) {
EventBean[] rows = executor.execute(processorInstance);
if (rows.length > 0) {
dispatch();
}
return new EPPreparedQueryResult(processor.getNamedWindowType(), rows);
}
}
// context partition runtime query
Collection<Integer> agentInstanceIds = EPPreparedExecuteMethodHelper.getAgentInstanceIds(processor, optionalSingleSelector, services.getContextManagementService(), processor.getContextName());
// collect events and agent instances
if (agentInstanceIds.isEmpty()) {
return new EPPreparedQueryResult(processor.getNamedWindowType(), CollectionUtil.EVENT_PER_STREAM_EMPTY);
}
if (agentInstanceIds.size() == 1) {
int agentInstanceId = agentInstanceIds.iterator().next();
NamedWindowProcessorInstance processorInstance = processor.getProcessorInstance(agentInstanceId);
EventBean[] rows = executor.execute(processorInstance);
if (rows.length > 0) {
dispatch();
}
return new EPPreparedQueryResult(processor.getNamedWindowType(), rows);
}
ArrayDeque<EventBean> allRows = new ArrayDeque<EventBean>();
for (int agentInstanceId : agentInstanceIds) {
NamedWindowProcessorInstance processorInstance = processor.getProcessorInstance(agentInstanceId);
if (processorInstance != null) {
EventBean[] rows = executor.execute(processorInstance);
allRows.addAll(Arrays.asList(rows));
}
}
if (allRows.size() > 0) {
dispatch();
}
return new EPPreparedQueryResult(processor.getNamedWindowType(), allRows.toArray(new EventBean[allRows.size()]));
}