Search in sources :

Example 1 with LengthWindowProcessor

use of org.wso2.siddhi.core.query.processor.stream.window.LengthWindowProcessor in project siddhi by wso2.

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.wso2.siddhi.core.exception.OperationNotSupportedException) LengthWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.LengthWindowProcessor) FindableProcessor(org.wso2.siddhi.core.query.processor.stream.window.FindableProcessor) FindableProcessor(org.wso2.siddhi.core.query.processor.stream.window.FindableProcessor) WindowWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.WindowWindowProcessor) AggregateWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.AggregateWindowProcessor) TableWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.TableWindowProcessor) Processor(org.wso2.siddhi.core.query.processor.Processor) WindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor) LengthWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.LengthWindowProcessor) JoinProcessor(org.wso2.siddhi.core.query.input.stream.join.JoinProcessor) VariableExpressionExecutor(org.wso2.siddhi.core.executor.VariableExpressionExecutor) ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) ConstantExpressionExecutor(org.wso2.siddhi.core.executor.ConstantExpressionExecutor) SiddhiAppCreationException(org.wso2.siddhi.core.exception.SiddhiAppCreationException) ConfigReader(org.wso2.siddhi.core.util.config.ConfigReader) WindowWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.WindowWindowProcessor) AggregateWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.AggregateWindowProcessor) TableWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.TableWindowProcessor) WindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor) LengthWindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.LengthWindowProcessor) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent) ConstantExpressionExecutor(org.wso2.siddhi.core.executor.ConstantExpressionExecutor)

Aggregations

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