use of org.wso2.siddhi.core.query.processor.stream.StreamProcessor in project siddhi by wso2.
the class AggregateWindowProcessor method cloneProcessor.
@Override
public Processor cloneProcessor(String key) {
try {
AggregateWindowProcessor streamProcessor = new AggregateWindowProcessor(aggregationRuntime, within, per);
streamProcessor.inputDefinition = inputDefinition;
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
for (int i = 0; i < attributeExpressionLength; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
}
streamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
streamProcessor.attributeExpressionLength = attributeExpressionLength;
streamProcessor.additionalAttributes = additionalAttributes;
streamProcessor.complexEventPopulater = complexEventPopulater;
streamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
streamProcessor.start();
return streamProcessor;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
use of org.wso2.siddhi.core.query.processor.stream.StreamProcessor in project siddhi by wso2.
the class SingleInputStreamParser method generateProcessor.
public static Processor generateProcessor(StreamHandler streamHandler, MetaComplexEvent metaEvent, List<VariableExpressionExecutor> variableExpressionExecutors, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, boolean supportsBatchProcessing, boolean outputExpectsExpiredEvents, String queryName) {
Expression[] parameters = streamHandler.getParameters();
MetaStreamEvent metaStreamEvent;
int stateIndex = SiddhiConstants.UNKNOWN_STATE;
if (metaEvent instanceof MetaStateEvent) {
stateIndex = ((MetaStateEvent) metaEvent).getStreamEventCount() - 1;
metaStreamEvent = ((MetaStateEvent) metaEvent).getMetaStreamEvent(stateIndex);
} else {
metaStreamEvent = (MetaStreamEvent) metaEvent;
}
ExpressionExecutor[] attributeExpressionExecutors;
if (parameters != null) {
if (parameters.length > 0) {
attributeExpressionExecutors = new ExpressionExecutor[parameters.length];
for (int i = 0, parametersLength = parameters.length; i < parametersLength; i++) {
attributeExpressionExecutors[i] = ExpressionParser.parseExpression(parameters[i], metaEvent, stateIndex, tableMap, variableExpressionExecutors, siddhiAppContext, false, SiddhiConstants.CURRENT, queryName);
}
} else {
List<Attribute> attributeList = metaStreamEvent.getLastInputDefinition().getAttributeList();
int parameterSize = attributeList.size();
attributeExpressionExecutors = new ExpressionExecutor[parameterSize];
for (int i = 0; i < parameterSize; i++) {
attributeExpressionExecutors[i] = ExpressionParser.parseExpression(new Variable(attributeList.get(i).getName()), metaEvent, stateIndex, tableMap, variableExpressionExecutors, siddhiAppContext, false, SiddhiConstants.CURRENT, queryName);
}
}
} else {
attributeExpressionExecutors = new ExpressionExecutor[0];
}
ConfigReader configReader;
if (streamHandler instanceof Filter) {
return new FilterProcessor(attributeExpressionExecutors[0]);
} else if (streamHandler instanceof Window) {
WindowProcessor windowProcessor = (WindowProcessor) SiddhiClassLoader.loadExtensionImplementation((Extension) streamHandler, WindowProcessorExtensionHolder.getInstance(siddhiAppContext));
configReader = siddhiAppContext.getSiddhiContext().getConfigManager().generateConfigReader(((Window) streamHandler).getNamespace(), ((Window) streamHandler).getName());
windowProcessor.initProcessor(metaStreamEvent.getLastInputDefinition(), attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents, queryName, streamHandler);
return windowProcessor;
} else if (streamHandler instanceof StreamFunction) {
AbstractStreamProcessor abstractStreamProcessor;
configReader = siddhiAppContext.getSiddhiContext().getConfigManager().generateConfigReader(((StreamFunction) streamHandler).getNamespace(), ((StreamFunction) streamHandler).getName());
if (supportsBatchProcessing) {
try {
abstractStreamProcessor = (StreamProcessor) SiddhiClassLoader.loadExtensionImplementation((Extension) streamHandler, StreamProcessorExtensionHolder.getInstance(siddhiAppContext));
metaStreamEvent.addInputDefinition(abstractStreamProcessor.initProcessor(metaStreamEvent.getLastInputDefinition(), attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents, queryName, streamHandler));
return abstractStreamProcessor;
} catch (SiddhiAppCreationException e) {
if (!e.isClassLoadingIssue()) {
ExceptionUtil.populateQueryContext(e, streamHandler, siddhiAppContext);
throw e;
}
}
}
abstractStreamProcessor = (StreamFunctionProcessor) SiddhiClassLoader.loadExtensionImplementation((Extension) streamHandler, StreamFunctionProcessorExtensionHolder.getInstance(siddhiAppContext));
metaStreamEvent.addInputDefinition(abstractStreamProcessor.initProcessor(metaStreamEvent.getLastInputDefinition(), attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents, queryName, streamHandler));
return abstractStreamProcessor;
} else {
throw new SiddhiAppCreationException(streamHandler.getClass().getName() + " is not supported", streamHandler.getQueryContextStartIndex(), streamHandler.getQueryContextEndIndex());
}
}
use of org.wso2.siddhi.core.query.processor.stream.StreamProcessor in project siddhi by wso2.
the class TableWindowProcessor method cloneProcessor.
@Override
public Processor cloneProcessor(String key) {
try {
TableWindowProcessor streamProcessor = new TableWindowProcessor(table);
streamProcessor.inputDefinition = inputDefinition;
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
for (int i = 0; i < attributeExpressionLength; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
}
streamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
streamProcessor.attributeExpressionLength = attributeExpressionLength;
streamProcessor.additionalAttributes = additionalAttributes;
streamProcessor.complexEventPopulater = complexEventPopulater;
streamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
streamProcessor.start();
return streamProcessor;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
use of org.wso2.siddhi.core.query.processor.stream.StreamProcessor in project siddhi by wso2.
the class WindowWindowProcessor method cloneProcessor.
@Override
public Processor cloneProcessor(String key) {
try {
WindowWindowProcessor streamProcessor = new WindowWindowProcessor(window);
streamProcessor.inputDefinition = inputDefinition;
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
for (int i = 0; i < attributeExpressionLength; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
}
streamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
streamProcessor.attributeExpressionLength = attributeExpressionLength;
streamProcessor.additionalAttributes = additionalAttributes;
streamProcessor.complexEventPopulater = complexEventPopulater;
streamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
streamProcessor.start();
return streamProcessor;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
Aggregations