Search in sources :

Example 1 with EmptyWindowProcessor

use of io.siddhi.core.query.processor.stream.window.EmptyWindowProcessor in project siddhi by wso2.

the class JoinInputStreamParser method insertJoinProcessorsAndGetFindable.

private static FindableProcessor insertJoinProcessorsAndGetFindable(JoinProcessor preJoinProcessor, JoinProcessor postJoinProcessor, SingleStreamRuntime streamRuntime, boolean outputExpectsExpiredEvents, InputStream inputStream, SiddhiQueryContext siddhiQueryContext) {
    Processor lastProcessor = streamRuntime.getProcessorChain();
    Processor prevLastProcessor = null;
    boolean containFindable = false;
    if (lastProcessor != null) {
        containFindable = lastProcessor instanceof FindableProcessor;
        while (lastProcessor.getNextProcessor() != null) {
            prevLastProcessor = lastProcessor;
            lastProcessor = lastProcessor.getNextProcessor();
            if (!containFindable) {
                containFindable = lastProcessor instanceof FindableProcessor;
            }
        }
    }
    if (!containFindable) {
        try {
            WindowProcessor windowProcessor = new EmptyWindowProcessor();
            ExpressionExecutor[] expressionExecutors = new ExpressionExecutor[1];
            expressionExecutors[0] = new ConstantExpressionExecutor(0, Attribute.Type.INT);
            ConfigReader configReader = siddhiQueryContext.getSiddhiContext().getConfigManager().generateConfigReader("", "lengthBatch");
            windowProcessor.initProcessor(((MetaStreamEvent) streamRuntime.getMetaComplexEvent()), expressionExecutors, configReader, outputExpectsExpiredEvents, true, false, inputStream, siddhiQueryContext);
            if (lastProcessor != null) {
                prevLastProcessor = lastProcessor;
                prevLastProcessor.setNextProcessor(windowProcessor);
                lastProcessor = windowProcessor;
            } else {
                lastProcessor = windowProcessor;
            }
        } catch (Throwable t) {
            throw new SiddhiAppCreationException(t);
        }
    }
    if (lastProcessor instanceof FindableProcessor) {
        if (prevLastProcessor != null) {
            prevLastProcessor.setNextProcessor(preJoinProcessor);
        } else {
            streamRuntime.setProcessorChain(preJoinProcessor);
        }
        preJoinProcessor.setNextProcessor(lastProcessor);
        lastProcessor.setNextProcessor(postJoinProcessor);
        return (FindableProcessor) lastProcessor;
    } else {
        throw new OperationNotSupportedException("Stream " + ((MetaStreamEvent) streamRuntime.getMetaComplexEvent()).getLastInputDefinition().getId() + "'s last processor " + lastProcessor.getClass().getCanonicalName() + " is not an instance of " + FindableProcessor.class.getCanonicalName() + " hence join cannot be proceed");
    }
}
Also used : OperationNotSupportedException(io.siddhi.core.exception.OperationNotSupportedException) FindableProcessor(io.siddhi.core.query.processor.stream.window.FindableProcessor) QueryableProcessor(io.siddhi.core.query.processor.stream.window.QueryableProcessor) EmptyWindowProcessor(io.siddhi.core.query.processor.stream.window.EmptyWindowProcessor) FindableProcessor(io.siddhi.core.query.processor.stream.window.FindableProcessor) Processor(io.siddhi.core.query.processor.Processor) JoinProcessor(io.siddhi.core.query.input.stream.join.JoinProcessor) TableWindowProcessor(io.siddhi.core.query.processor.stream.window.TableWindowProcessor) WindowProcessor(io.siddhi.core.query.processor.stream.window.WindowProcessor) WindowWindowProcessor(io.siddhi.core.query.processor.stream.window.WindowWindowProcessor) AggregateWindowProcessor(io.siddhi.core.query.processor.stream.window.AggregateWindowProcessor) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) ExpressionExecutor(io.siddhi.core.executor.ExpressionExecutor) ConstantExpressionExecutor(io.siddhi.core.executor.ConstantExpressionExecutor) SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) ConfigReader(io.siddhi.core.util.config.ConfigReader) ConstantExpressionExecutor(io.siddhi.core.executor.ConstantExpressionExecutor) EmptyWindowProcessor(io.siddhi.core.query.processor.stream.window.EmptyWindowProcessor) EmptyWindowProcessor(io.siddhi.core.query.processor.stream.window.EmptyWindowProcessor) TableWindowProcessor(io.siddhi.core.query.processor.stream.window.TableWindowProcessor) WindowProcessor(io.siddhi.core.query.processor.stream.window.WindowProcessor) WindowWindowProcessor(io.siddhi.core.query.processor.stream.window.WindowWindowProcessor) AggregateWindowProcessor(io.siddhi.core.query.processor.stream.window.AggregateWindowProcessor) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Aggregations

MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)1 OperationNotSupportedException (io.siddhi.core.exception.OperationNotSupportedException)1 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)1 ConstantExpressionExecutor (io.siddhi.core.executor.ConstantExpressionExecutor)1 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)1 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)1 JoinProcessor (io.siddhi.core.query.input.stream.join.JoinProcessor)1 Processor (io.siddhi.core.query.processor.Processor)1 AggregateWindowProcessor (io.siddhi.core.query.processor.stream.window.AggregateWindowProcessor)1 EmptyWindowProcessor (io.siddhi.core.query.processor.stream.window.EmptyWindowProcessor)1 FindableProcessor (io.siddhi.core.query.processor.stream.window.FindableProcessor)1 QueryableProcessor (io.siddhi.core.query.processor.stream.window.QueryableProcessor)1 TableWindowProcessor (io.siddhi.core.query.processor.stream.window.TableWindowProcessor)1 WindowProcessor (io.siddhi.core.query.processor.stream.window.WindowProcessor)1 WindowWindowProcessor (io.siddhi.core.query.processor.stream.window.WindowWindowProcessor)1 ConfigReader (io.siddhi.core.util.config.ConfigReader)1