}
namesPerStream[i] = streamName;
processors[i] = services.getNamedWindowService().getProcessor(namedSpec.getWindowName());
if (processors[i] == null) {
throw new ExprValidationException("A named window by name '" + namedSpec.getWindowName() + "' does not exist");
}
typesPerStream[i] = processors[i].getTailView().getEventType();
}
// compile filter to optimize access to named window
filters = new FilterSpecCompiled[numStreams];
if (statementSpec.getFilterRootNode() != null) {
LinkedHashMap<String, Pair<EventType, String>> tagged = new LinkedHashMap<String, Pair<EventType, String>>();
for (int i = 0; i < numStreams; i++) {
try {
StreamTypeServiceImpl types = new StreamTypeServiceImpl(typesPerStream, namesPerStream, new boolean[numStreams], services.getEngineURI(), false);
filters[i] = FilterSpecCompiler.makeFilterSpec(typesPerStream[i], namesPerStream[i],
Collections.singletonList(statementSpec.getFilterRootNode()), null,
tagged, tagged, types,
null, statementContext, Collections.singleton(i));
}
catch (Exception ex) {
log.warn("Unexpected exception analyzing filter paths: " + ex.getMessage(), ex);
}
}
}
// obtain result set processor
boolean[] isIStreamOnly = new boolean[namesPerStream.length];
Arrays.fill(isIStreamOnly, true);
StreamTypeService typeService = new StreamTypeServiceImpl(typesPerStream, namesPerStream, isIStreamOnly, services.getEngineURI(), true);
EPStatementStartMethodHelperValidate.validateNodes(statementSpec, statementContext, typeService, null);
ResultSetProcessorFactoryDesc resultSetProcessorPrototype = ResultSetProcessorFactoryFactory.getProcessorPrototype(statementSpec, statementContext, typeService, null, new boolean[0], true, ContextPropertyRegistryImpl.EMPTY_REGISTRY, null);
resultSetProcessor = EPStatementStartMethodHelperAssignExpr.getAssignResultSetProcessor(agentInstanceContext, resultSetProcessorPrototype);
if (statementSpec.getSelectClauseSpec().isDistinct())
{
if (resultSetProcessor.getResultEventType() instanceof EventTypeSPI)
{
eventBeanReader = ((EventTypeSPI) resultSetProcessor.getResultEventType()).getReader();
}
if (eventBeanReader == null)
{
eventBeanReader = new EventBeanReaderDefaultImpl(resultSetProcessor.getResultEventType());
}
}
// plan joins or simple queries
if (numStreams > 1)
{
StreamJoinAnalysisResult streamJoinAnalysisResult = new StreamJoinAnalysisResult(numStreams);
Arrays.fill(streamJoinAnalysisResult.getNamedWindow(), true);
for (int i = 0; i < numStreams; i++) {
NamedWindowProcessorInstance processorInstance = processors[i].getProcessorInstance(agentInstanceContext);
if (processors[i].isVirtualDataWindow()) {
streamJoinAnalysisResult.getViewExternal()[i] = processorInstance.getRootViewInstance().getVirtualDataWindow();
}
}
joinSetComposerPrototype = JoinSetComposerPrototypeFactory.makeComposerPrototype(null, null,
statementSpec.getOuterJoinDescList(), statementSpec.getFilterRootNode(), typesPerStream, namesPerStream,
streamJoinAnalysisResult, queryPlanLogging, null, new HistoricalViewableDesc(numStreams), agentInstanceContext);
}
// check context partition use
if (statementSpec.getOptionalContextName() != null) {
if (numStreams > 1) {
throw new ExprValidationException("Joins in runtime queries for context partitions are not supported");
}
}
}