}
// create factory chain context to hold callbacks specific to "prior" and "prev"
AgentInstanceViewFactoryChainContext viewFactoryChainContext = AgentInstanceViewFactoryChainContext.create(viewFactoryChain, agentInstanceContext, viewResourceDelegate.getPerStream()[0]);
Viewable subselectView = services.getViewService().createViews(viewableRoot, viewFactoryChain, viewFactoryChainContext, false);
// create index/holder table
EventTable index = pair.getFirst().makeEventTable();
stopCallbackList.add(new SubqueryStopCallback(index));
// create strategy
SubordTableLookupStrategy strategy = pair.getSecond().makeStrategy(index);
SubselectAggregationPreprocessor subselectAggregationPreprocessor = null;
// handle "prior" nodes and their strategies
Map<ExprPriorNode, ExprPriorEvalStrategy> priorNodeStrategies = EPStatementStartMethodHelperPrior.compilePriorNodeStrategies(viewResourceDelegate, new AgentInstanceViewFactoryChainContext[]{viewFactoryChainContext});
// handle "previous" nodes and their strategies
Map<ExprPreviousNode, ExprPreviousEvalStrategy> previousNodeStrategies = EPStatementStartMethodHelperPrevious.compilePreviousNodeStrategies(viewResourceDelegate, new AgentInstanceViewFactoryChainContext[]{viewFactoryChainContext});
AggregationService aggregationService = null;
if (aggregationServiceFactory != null) {
aggregationService = aggregationServiceFactory.getAggregationServiceFactory().makeService(agentInstanceContext, agentInstanceContext.getStatementContext().getMethodResolutionService());
if (!correlatedSubquery) {
SubselectAggregatorView aggregatorView = new SubselectAggregatorView(aggregationService, filterExprEval, agentInstanceContext);
subselectView.addView(aggregatorView);
preload(services, null, aggregatorView, agentInstanceContext);
return new SubSelectStrategyRealization(NULL_ROW_STRATEGY, null, aggregationService, priorNodeStrategies, previousNodeStrategies);
}
else {
subselectAggregationPreprocessor = new SubselectAggregationPreprocessor(aggregationService, filterExprEval);
}
}
// preload
preload(services, index, subselectView, agentInstanceContext);
BufferView bufferView = new BufferView(subSelectHolder.getStreamNumber());
bufferView.setObserver(new SubselectBufferObserver(index));
subselectView.addView(bufferView);
return new SubSelectStrategyRealization(strategy, subselectAggregationPreprocessor, aggregationService, priorNodeStrategies, previousNodeStrategies);
}