Search in sources :

Example 1 with LengthWindowProcessor

use of org.ballerinalang.siddhi.core.query.processor.stream.window.LengthWindowProcessor in project ballerina by ballerina-lang.

the class JoinInputStreamParser method insertJoinProcessorsAndGetFindable.

private static FindableProcessor insertJoinProcessorsAndGetFindable(JoinProcessor preJoinProcessor, JoinProcessor postJoinProcessor, SingleStreamRuntime streamRuntime, SiddhiAppContext siddhiAppContext, boolean outputExpectsExpiredEvents, String queryName, InputStream inputStream) {
    Processor lastProcessor = streamRuntime.getProcessorChain();
    Processor prevLastProcessor = null;
    if (lastProcessor != null) {
        while (lastProcessor.getNextProcessor() != null) {
            prevLastProcessor = lastProcessor;
            lastProcessor = lastProcessor.getNextProcessor();
        }
    }
    if (lastProcessor == null) {
        try {
            WindowProcessor windowProcessor = new LengthWindowProcessor();
            ExpressionExecutor[] expressionExecutors = new ExpressionExecutor[1];
            expressionExecutors[0] = new ConstantExpressionExecutor(0, Attribute.Type.INT);
            ConfigReader configReader = siddhiAppContext.getSiddhiContext().getConfigManager().generateConfigReader("", "length");
            windowProcessor.initProcessor(((MetaStreamEvent) streamRuntime.getMetaComplexEvent()).getLastInputDefinition(), expressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents, queryName, inputStream);
            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(org.ballerinalang.siddhi.core.exception.OperationNotSupportedException) LengthWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.LengthWindowProcessor) FindableProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.FindableProcessor) Processor(org.ballerinalang.siddhi.core.query.processor.Processor) LengthWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.LengthWindowProcessor) AggregateWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.AggregateWindowProcessor) JoinProcessor(org.ballerinalang.siddhi.core.query.input.stream.join.JoinProcessor) FindableProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.FindableProcessor) WindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.WindowProcessor) TableWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.TableWindowProcessor) WindowWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.WindowWindowProcessor) ConstantExpressionExecutor(org.ballerinalang.siddhi.core.executor.ConstantExpressionExecutor) ExpressionExecutor(org.ballerinalang.siddhi.core.executor.ExpressionExecutor) VariableExpressionExecutor(org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor) SiddhiAppCreationException(org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException) ConfigReader(org.ballerinalang.siddhi.core.util.config.ConfigReader) LengthWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.LengthWindowProcessor) AggregateWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.AggregateWindowProcessor) WindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.WindowProcessor) TableWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.TableWindowProcessor) WindowWindowProcessor(org.ballerinalang.siddhi.core.query.processor.stream.window.WindowWindowProcessor) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) ConstantExpressionExecutor(org.ballerinalang.siddhi.core.executor.ConstantExpressionExecutor)

Aggregations

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