public EPStatementStartMethodCreateIndex(StatementSpecCompiled statementSpec, EPServicesContext services, StatementContext statementContext) {
super(statementSpec, services, statementContext);
}
public EPStatementStartResult startInternal(boolean isNewStatement, boolean isRecoveringStatement, boolean isRecoveringResilient) throws ExprValidationException, ViewProcessingException {
final CreateIndexDesc spec = statementSpec.getCreateIndexDesc();
final NamedWindowProcessor processor = services.getNamedWindowService().getProcessor(spec.getWindowName());
if (processor == null) {
throw new ExprValidationException("A named window by name '" + spec.getWindowName() + "' does not exist");
}
final NamedWindowProcessorInstance processorInstance = processor.getProcessorInstance(getDefaultAgentInstanceContext());
EPStatementStopMethod stopMethod;
if (processor.isVirtualDataWindow()) {
final VirtualDWView virtualDWView = processorInstance.getRootViewInstance().getVirtualDataWindow();
virtualDWView.handleStartIndex(spec);
stopMethod = new EPStatementStopMethod() {
public void stop() {
virtualDWView.handleStopIndex(spec);
}
};
}
else {
processorInstance.getRootViewInstance().addExplicitIndex(spec.getWindowName(), spec.getIndexName(), spec.getColumns());
stopMethod = new EPStatementStopMethod() {
public void stop()
{
processorInstance.getRootViewInstance().removeExplicitIndex(spec.getIndexName());
}
};
}
Viewable viewable = new ViewableDefaultImpl(processor.getNamedWindowType());