NamedWindowProcessor processor = services.getNamedWindowService().getProcessor(namedSpec.getWindowName());
NamedWindowProcessorInstance processorInstance = processor.getProcessorInstance(agentInstanceContext);
if (processorInstance != null) {
final NamedWindowTailViewInstance consumerView = processorInstance.getTailViewInstance();
namedWindowTailViews[i] = consumerView;
final NamedWindowConsumerView view = (NamedWindowConsumerView) viewableActivationResult[i].getViewable();
// determine preload/postload filter for index access
if (!namedSpec.getFilterExpressions().isEmpty()) {
namedWindowFilters[streamNum] = namedSpec.getFilterExpressions();
try {
StreamTypeServiceImpl types = new StreamTypeServiceImpl(consumerView.getEventType(), consumerView.getEventType().getName(), false, services.getEngineURI());
LinkedHashMap<String, Pair<EventType, String>> tagged = new LinkedHashMap<String, Pair<EventType, String>>();
namedWindowPostloadFilters[i] = FilterSpecCompiler.makeFilterSpec(types.getEventTypes()[0], types.getStreamNames()[0],
namedSpec.getFilterExpressions(), null, tagged, tagged, types, null, statementContext, Collections.singleton(0));
}
catch (Exception ex) {
log.warn("Unexpected exception analyzing filter paths: " + ex.getMessage(), ex);
}
}
// preload view for stream unless the expiry policy is batch window
Iterator<EventBean> consumerViewIterator = consumerView.iterator();
boolean preload = !consumerView.getTailView().isParentBatchWindow() && consumerViewIterator.hasNext();
if (preload) {
if (isRecoveringResilient && numStreams < 2) {
preload = false;
}
}
if (preload) {
final boolean yesRecoveringResilient = isRecoveringResilient;
final FilterSpecCompiled preloadFilterSpec = namedWindowPostloadFilters[i];
preloadList.add(new StatementAgentInstancePreload() {
public void executePreload() {
Collection<EventBean> snapshot = consumerView.snapshotNoLock(preloadFilterSpec, statementContext.getAnnotations());
List<EventBean> eventsInWindow = new ArrayList<EventBean>(snapshot.size());
ExprNodeUtility.applyFilterExpressionsIterable(snapshot, namedSpec.getFilterExpressions(), agentInstanceContext, eventsInWindow);
EventBean[] newEvents = eventsInWindow.toArray(new EventBean[eventsInWindow.size()]);
view.update(newEvents, null);
if (!yesRecoveringResilient && joinPreloadMethod != null && !joinPreloadMethod.isPreloading() && agentInstanceContext.getEpStatementAgentInstanceHandle().getOptionalDispatchable() != null) {
agentInstanceContext.getEpStatementAgentInstanceHandle().getOptionalDispatchable().execute(agentInstanceContext);
}
}
});