use of io.siddhi.core.exception.OperationNotSupportedException in project siddhi by wso2.
the class StdDevAttributeAggregatorExecutor method init.
/**
* The initialization method for FunctionExecutor
*
* @param attributeExpressionExecutors are the executors of each attributes in the function
* @param processingMode query processing mode
* @param outputExpectsExpiredEvents is expired events sent as output
* @param configReader this hold the {@link StdDevAttributeAggregatorExecutor} configuration reader.
* @param siddhiQueryContext Siddhi query runtime context
*/
@Override
protected StateFactory<AggregatorState> init(ExpressionExecutor[] attributeExpressionExecutors, ProcessingMode processingMode, boolean outputExpectsExpiredEvents, ConfigReader configReader, SiddhiQueryContext siddhiQueryContext) {
if (attributeExpressionExecutors.length != 1) {
throw new OperationNotSupportedException("stdDev aggregator has to have exactly 1 parameter, currently " + attributeExpressionExecutors.length + " parameters provided");
}
returnType = Attribute.Type.DOUBLE;
Attribute.Type type = attributeExpressionExecutors[0].getReturnType();
return () -> {
switch(type) {
case INT:
return new StdDevAttributeAggregatorStateInt();
case LONG:
return new StdDevAttributeAggregatorStateLong();
case FLOAT:
return new StdDevAttributeAggregatorStateFloat();
case DOUBLE:
return new StdDevAttributeAggregatorStateDouble();
default:
throw new OperationNotSupportedException("stdDev not supported for " + returnType);
}
};
}
use of io.siddhi.core.exception.OperationNotSupportedException in project siddhi by wso2.
the class SingleInputStreamParser method parseInputStream.
/**
* Parse single InputStream and return SingleStreamRuntime
*
* @param inputStream single input stream to be parsed
* @param variableExpressionExecutors List to hold VariableExpressionExecutors to update after query parsing
* @param streamDefinitionMap Stream Definition Map
* @param tableDefinitionMap Table Definition Map
* @param windowDefinitionMap window definition map
* @param aggregationDefinitionMap aggregation definition map
* @param tableMap Table Map
* @param metaComplexEvent MetaComplexEvent
* @param processStreamReceiver ProcessStreamReceiver
* @param supportsBatchProcessing supports batch processing
* @param outputExpectsExpiredEvents is expired events sent as output
* @param findToBeExecuted find will be executed in the steam stores
* @param multiValue event has the possibility to produce multiple values
* @param siddhiQueryContext @return SingleStreamRuntime
*/
public static SingleStreamRuntime parseInputStream(SingleInputStream inputStream, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, AbstractDefinition> streamDefinitionMap, Map<String, AbstractDefinition> tableDefinitionMap, Map<String, AbstractDefinition> windowDefinitionMap, Map<String, AbstractDefinition> aggregationDefinitionMap, Map<String, Table> tableMap, MetaComplexEvent metaComplexEvent, ProcessStreamReceiver processStreamReceiver, boolean supportsBatchProcessing, boolean outputExpectsExpiredEvents, boolean findToBeExecuted, boolean multiValue, SiddhiQueryContext siddhiQueryContext) {
Processor processor = null;
EntryValveProcessor entryValveProcessor = null;
ProcessingMode processingMode = ProcessingMode.BATCH;
boolean first = true;
MetaStreamEvent metaStreamEvent;
if (metaComplexEvent instanceof MetaStateEvent) {
metaStreamEvent = new MetaStreamEvent();
((MetaStateEvent) metaComplexEvent).addEvent(metaStreamEvent);
initMetaStreamEvent(inputStream, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, multiValue, metaStreamEvent);
} else {
metaStreamEvent = (MetaStreamEvent) metaComplexEvent;
initMetaStreamEvent(inputStream, streamDefinitionMap, tableDefinitionMap, windowDefinitionMap, aggregationDefinitionMap, multiValue, metaStreamEvent);
}
// A window cannot be defined for a window stream
if (!inputStream.getStreamHandlers().isEmpty() && windowDefinitionMap != null && windowDefinitionMap.containsKey(inputStream.getStreamId())) {
for (StreamHandler handler : inputStream.getStreamHandlers()) {
if (handler instanceof Window) {
throw new OperationNotSupportedException("Cannot create " + ((Window) handler).getName() + " " + "window for the window stream " + inputStream.getStreamId());
}
}
}
if (!inputStream.getStreamHandlers().isEmpty()) {
for (StreamHandler handler : inputStream.getStreamHandlers()) {
Processor currentProcessor = generateProcessor(handler, metaComplexEvent, variableExpressionExecutors, tableMap, supportsBatchProcessing, outputExpectsExpiredEvents, findToBeExecuted, siddhiQueryContext);
if (currentProcessor instanceof SchedulingProcessor) {
if (entryValveProcessor == null) {
entryValveProcessor = new EntryValveProcessor(siddhiQueryContext.getSiddhiAppContext());
if (first) {
processor = entryValveProcessor;
first = false;
} else {
processor.setToLast(entryValveProcessor);
}
}
Scheduler scheduler = SchedulerParser.parse(entryValveProcessor, siddhiQueryContext);
((SchedulingProcessor) currentProcessor).setScheduler(scheduler);
}
if (currentProcessor instanceof AbstractStreamProcessor) {
processingMode = ProcessingMode.findUpdatedProcessingMode(processingMode, ((AbstractStreamProcessor) currentProcessor).getProcessingMode());
}
if (first) {
processor = currentProcessor;
first = false;
} else {
processor.setToLast(currentProcessor);
}
}
}
metaStreamEvent.initializeOnAfterWindowData();
return new SingleStreamRuntime(processStreamReceiver, processor, processingMode, metaComplexEvent);
}
Aggregations