Search in sources :

Example 6 with QuerySelector

use of io.siddhi.core.query.selector.QuerySelector in project siddhi by wso2.

the class TestStoreContainingInMemoryTable method compileSelection.

@Override
protected CompiledSelection compileSelection(List<SelectAttributeBuilder> selectAttributeBuilders, List<ExpressionBuilder> groupByExpressionBuilder, ExpressionBuilder havingExpressionBuilder, List<OrderByAttributeBuilder> orderByAttributeBuilders, Long limit, Long offset) {
    selectAttributeBuilders.forEach((selectAttributeBuilder -> {
        TestStoreConditionVisitor testStoreConditionVisitor = new TestStoreConditionVisitor("");
        selectAttributeBuilder.getExpressionBuilder().build(testStoreConditionVisitor);
        if (testStoreConditionVisitor.getStreamVarCount() > 0) {
            throw new SiddhiAppCreationException("testStoreContainingInMemoryTable does not support " + "lookup with stream variables");
        }
    }));
    CompiledSelectionWithCache compiledSelectionWithCache;
    MetaStateEvent metaStateEvent = matchingMetaInfoHolderForTestOnDemandQuery.getMetaStateEvent().clone();
    ReturnStream returnStream = new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS);
    int metaPosition = SiddhiConstants.UNKNOWN_STATE;
    List<VariableExpressionExecutor> variableExpressionExecutorsForQuerySelector = new ArrayList<>();
    if (metaStateEvent.getOutputDataAttributes().size() == 0) {
        // MetaStateEvent metaStateEventWithOutputData = new MetaStateEvent(metaStateEvent.getStreamEventCount());
        for (Attribute outputAttribute : metaStateEvent.getMetaStreamEvents()[0].getOnAfterWindowData()) {
            metaStateEvent.getMetaStreamEvents()[0].addOutputData(outputAttribute);
        }
    }
    if (metaStateEvent.getOutputDataAttributes().size() > 0) {
        while (metaStateEvent.getMetaStreamEvent(0).getOutputData().size() > 0) {
            metaStateEvent.getMetaStreamEvent(0).getOutputData().remove(0);
        }
    }
    QuerySelector querySelector = SelectorParser.parse(selectorForTestOnDemandQuery, returnStream, metaStateEvent, tableMap, variableExpressionExecutorsForQuerySelector, metaPosition, ProcessingMode.BATCH, false, siddhiQueryContextForTestOnDemandQuery);
    QueryParserHelper.updateVariablePosition(metaStateEvent, variableExpressionExecutorsForQuerySelector);
    querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(metaStateEvent));
    compiledSelectionWithCache = new CompiledSelectionWithCache(null, querySelector, metaStateEvent, 0, null);
    return compiledSelectionWithCache;
}
Also used : MatchingMetaInfoHolder(io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) Extension(io.siddhi.annotation.Extension) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) Variable(io.siddhi.query.api.expression.Variable) AddingStreamEventExtractor(io.siddhi.core.util.collection.AddingStreamEventExtractor) SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) StreamEventCloner(io.siddhi.core.event.stream.StreamEventCloner) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) SiddhiConstants(io.siddhi.core.util.SiddhiConstants) CompiledSelection(io.siddhi.core.util.collection.operator.CompiledSelection) Annotation(io.siddhi.query.api.annotation.Annotation) QuerySelector(io.siddhi.core.query.selector.QuerySelector) StreamEvent(io.siddhi.core.event.stream.StreamEvent) ArrayList(java.util.ArrayList) RecordIterator(io.siddhi.core.table.record.RecordIterator) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ExpressionBuilder(io.siddhi.core.table.record.ExpressionBuilder) Map(java.util.Map) InMemoryTable(io.siddhi.core.table.InMemoryTable) SelectorParser(io.siddhi.core.util.parser.SelectorParser) TableDefinition(io.siddhi.query.api.definition.TableDefinition) LinkedList(java.util.LinkedList) ProcessingMode(io.siddhi.core.query.processor.ProcessingMode) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) Event(io.siddhi.core.event.Event) CompiledUpdateSet(io.siddhi.core.table.CompiledUpdateSet) Example(io.siddhi.annotation.Example) ComplexEvent(io.siddhi.core.event.ComplexEvent) Attribute(io.siddhi.query.api.definition.Attribute) CompiledCondition(io.siddhi.core.util.collection.operator.CompiledCondition) OnDemandQueryRuntimeUtil.executeSelector(io.siddhi.core.util.OnDemandQueryRuntimeUtil.executeSelector) ConfigReader(io.siddhi.core.util.config.ConfigReader) StateEventFactory(io.siddhi.core.event.state.StateEventFactory) StateEventPopulatorFactory(io.siddhi.core.event.state.populater.StateEventPopulatorFactory) AbstractQueryableRecordTable(io.siddhi.core.table.record.AbstractQueryableRecordTable) List(java.util.List) CompiledExpression(io.siddhi.core.util.collection.operator.CompiledExpression) OutputStream(io.siddhi.query.api.execution.query.output.stream.OutputStream) MatcherParser(io.siddhi.core.util.parser.MatcherParser) ConnectionUnavailableException(io.siddhi.core.exception.ConnectionUnavailableException) StateEvent(io.siddhi.core.event.state.StateEvent) QueryParserHelper(io.siddhi.core.util.parser.helper.QueryParserHelper) UpdateSet(io.siddhi.query.api.execution.query.output.stream.UpdateSet) ReturnStream(io.siddhi.query.api.execution.query.output.stream.ReturnStream) Attribute(io.siddhi.query.api.definition.Attribute) SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) ArrayList(java.util.ArrayList) QuerySelector(io.siddhi.core.query.selector.QuerySelector) ReturnStream(io.siddhi.query.api.execution.query.output.stream.ReturnStream) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent)

Example 7 with QuerySelector

use of io.siddhi.core.query.selector.QuerySelector in project siddhi by wso2.

the class TestStoreForCacheMiss method compileSelection.

@Override
protected CompiledSelection compileSelection(List<SelectAttributeBuilder> selectAttributeBuilders, List<ExpressionBuilder> groupByExpressionBuilder, ExpressionBuilder havingExpressionBuilder, List<OrderByAttributeBuilder> orderByAttributeBuilders, Long limit, Long offset) {
    selectAttributeBuilders.forEach((selectAttributeBuilder -> {
        TestStoreConditionVisitor testStoreConditionVisitor = new TestStoreConditionVisitor("");
        selectAttributeBuilder.getExpressionBuilder().build(testStoreConditionVisitor);
        if (testStoreConditionVisitor.getStreamVarCount() > 0) {
            throw new SiddhiAppCreationException("testStoreContainingInMemoryTable does not support " + "lookup with stream variables");
        }
    }));
    CompiledSelectionWithCache compiledSelectionWithCache;
    MetaStateEvent metaStateEvent = matchingMetaInfoHolderForTestOnDemandQuery.getMetaStateEvent().clone();
    ReturnStream returnStream = new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS);
    int metaPosition = SiddhiConstants.UNKNOWN_STATE;
    List<VariableExpressionExecutor> variableExpressionExecutorsForQuerySelector = new ArrayList<>();
    if (metaStateEvent.getOutputDataAttributes().size() == 0) {
        for (Attribute outputAttribute : metaStateEvent.getMetaStreamEvents()[0].getOnAfterWindowData()) {
            metaStateEvent.getMetaStreamEvents()[0].addOutputData(outputAttribute);
        }
    }
    QuerySelector querySelector = SelectorParser.parse(selectorForTestOnDemandQuery, returnStream, metaStateEvent, tableMap, variableExpressionExecutorsForQuerySelector, metaPosition, ProcessingMode.BATCH, false, siddhiQueryContextForTestOnDemandQuery);
    QueryParserHelper.updateVariablePosition(metaStateEvent, variableExpressionExecutorsForQuerySelector);
    querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(metaStateEvent));
    compiledSelectionWithCache = new CompiledSelectionWithCache(null, querySelector, metaStateEvent, 0, null);
    return compiledSelectionWithCache;
}
Also used : Extension(io.siddhi.annotation.Extension) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) StreamEventCloner(io.siddhi.core.event.stream.StreamEventCloner) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) SiddhiConstants(io.siddhi.core.util.SiddhiConstants) CompiledSelection(io.siddhi.core.util.collection.operator.CompiledSelection) Annotation(io.siddhi.query.api.annotation.Annotation) QuerySelector(io.siddhi.core.query.selector.QuerySelector) StreamEvent(io.siddhi.core.event.stream.StreamEvent) ArrayList(java.util.ArrayList) RecordIterator(io.siddhi.core.table.record.RecordIterator) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) ExpressionBuilder(io.siddhi.core.table.record.ExpressionBuilder) Map(java.util.Map) InMemoryTable(io.siddhi.core.table.InMemoryTable) SelectorParser(io.siddhi.core.util.parser.SelectorParser) TableDefinition(io.siddhi.query.api.definition.TableDefinition) LinkedList(java.util.LinkedList) ProcessingMode(io.siddhi.core.query.processor.ProcessingMode) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) Event(io.siddhi.core.event.Event) Example(io.siddhi.annotation.Example) ComplexEvent(io.siddhi.core.event.ComplexEvent) Attribute(io.siddhi.query.api.definition.Attribute) CompiledCondition(io.siddhi.core.util.collection.operator.CompiledCondition) OnDemandQueryRuntimeUtil.executeSelector(io.siddhi.core.util.OnDemandQueryRuntimeUtil.executeSelector) ConfigReader(io.siddhi.core.util.config.ConfigReader) StateEventFactory(io.siddhi.core.event.state.StateEventFactory) StateEventPopulatorFactory(io.siddhi.core.event.state.populater.StateEventPopulatorFactory) AbstractQueryableRecordTable(io.siddhi.core.table.record.AbstractQueryableRecordTable) List(java.util.List) CompiledExpression(io.siddhi.core.util.collection.operator.CompiledExpression) OutputStream(io.siddhi.query.api.execution.query.output.stream.OutputStream) ConnectionUnavailableException(io.siddhi.core.exception.ConnectionUnavailableException) StateEvent(io.siddhi.core.event.state.StateEvent) QueryParserHelper(io.siddhi.core.util.parser.helper.QueryParserHelper) ReturnStream(io.siddhi.query.api.execution.query.output.stream.ReturnStream) Attribute(io.siddhi.query.api.definition.Attribute) SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) ArrayList(java.util.ArrayList) QuerySelector(io.siddhi.core.query.selector.QuerySelector) ReturnStream(io.siddhi.query.api.execution.query.output.stream.ReturnStream) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent)

Example 8 with QuerySelector

use of io.siddhi.core.query.selector.QuerySelector in project siddhi by wso2.

the class AbstractQueryableRecordTable method compileSelection.

public CompiledSelection compileSelection(Selector selector, List<Attribute> expectedOutputAttributes, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
    selectorForTestOnDemandQuery = selector;
    siddhiQueryContextForTestOnDemandQuery = siddhiQueryContext;
    matchingMetaInfoHolderForTestOnDemandQuery = matchingMetaInfoHolder;
    List<OutputAttribute> outputAttributes = selector.getSelectionList();
    if (outputAttributes.size() == 0) {
        MetaStreamEvent metaStreamEvent = matchingMetaInfoHolder.getMetaStateEvent().getMetaStreamEvent(matchingMetaInfoHolder.getStoreEventIndex());
        List<Attribute> attributeList = metaStreamEvent.getLastInputDefinition().getAttributeList();
        for (Attribute attribute : attributeList) {
            outputAttributes.add(new OutputAttribute(new Variable(attribute.getName())));
        }
    }
    List<SelectAttributeBuilder> selectAttributeBuilders = new ArrayList<>(outputAttributes.size());
    for (OutputAttribute outputAttribute : outputAttributes) {
        ExpressionBuilder expressionBuilder = new ExpressionBuilder(outputAttribute.getExpression(), matchingMetaInfoHolder, variableExpressionExecutors, tableMap, null, null, siddhiQueryContext);
        selectAttributeBuilders.add(new SelectAttributeBuilder(expressionBuilder, outputAttribute.getRename()));
    }
    MatchingMetaInfoHolder metaInfoHolderAfterSelect = new MatchingMetaInfoHolder(matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getMatchingStreamEventIndex(), matchingMetaInfoHolder.getStoreEventIndex(), matchingMetaInfoHolder.getMatchingStreamDefinition(), matchingMetaInfoHolder.getMatchingStreamDefinition(), matchingMetaInfoHolder.getCurrentState());
    List<ExpressionBuilder> groupByExpressionBuilders = null;
    if (selector.getGroupByList().size() != 0) {
        groupByExpressionBuilders = new ArrayList<>(outputAttributes.size());
        for (Variable variable : selector.getGroupByList()) {
            groupByExpressionBuilders.add(new ExpressionBuilder(variable, metaInfoHolderAfterSelect, variableExpressionExecutors, tableMap, null, null, siddhiQueryContext));
        }
    }
    ExpressionBuilder havingExpressionBuilder = null;
    if (selector.getHavingExpression() != null) {
        havingExpressionBuilder = new ExpressionBuilder(selector.getHavingExpression(), metaInfoHolderAfterSelect, variableExpressionExecutors, tableMap, null, null, siddhiQueryContext);
    }
    List<OrderByAttributeBuilder> orderByAttributeBuilders = null;
    if (selector.getOrderByList().size() != 0) {
        orderByAttributeBuilders = new ArrayList<>(selector.getOrderByList().size());
        for (OrderByAttribute orderByAttribute : selector.getOrderByList()) {
            ExpressionBuilder expressionBuilder = new ExpressionBuilder(orderByAttribute.getVariable(), metaInfoHolderAfterSelect, variableExpressionExecutors, tableMap, null, null, siddhiQueryContext);
            orderByAttributeBuilders.add(new OrderByAttributeBuilder(expressionBuilder, orderByAttribute.getOrder()));
        }
    }
    Long limit = null;
    Long offset = null;
    if (selector.getLimit() != null) {
        ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression((Expression) selector.getLimit(), metaInfoHolderAfterSelect.getMetaStateEvent(), SiddhiConstants.HAVING_STATE, tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
        limit = ((Number) (((ConstantExpressionExecutor) expressionExecutor).getValue())).longValue();
        if (limit < 0) {
            throw new SiddhiAppCreationException("'limit' cannot have negative value, but found '" + limit + "'", selector, siddhiQueryContext.getSiddhiAppContext());
        }
    }
    if (selector.getOffset() != null) {
        ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression((Expression) selector.getOffset(), metaInfoHolderAfterSelect.getMetaStateEvent(), SiddhiConstants.HAVING_STATE, tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
        offset = ((Number) (((ConstantExpressionExecutor) expressionExecutor).getValue())).longValue();
        if (offset < 0) {
            throw new SiddhiAppCreationException("'offset' cannot have negative value, but found '" + offset + "'", selector, siddhiQueryContext.getSiddhiAppContext());
        }
    }
    CompiledSelection compiledSelection = compileSelection(selectAttributeBuilders, groupByExpressionBuilders, havingExpressionBuilder, orderByAttributeBuilders, limit, offset);
    Map<String, ExpressionExecutor> expressionExecutorMap = new HashMap<>();
    if (selectAttributeBuilders.size() != 0) {
        for (SelectAttributeBuilder selectAttributeBuilder : selectAttributeBuilders) {
            expressionExecutorMap.putAll(selectAttributeBuilder.getExpressionBuilder().getVariableExpressionExecutorMap());
        }
    }
    if (groupByExpressionBuilders != null && groupByExpressionBuilders.size() != 0) {
        for (ExpressionBuilder groupByExpressionBuilder : groupByExpressionBuilders) {
            expressionExecutorMap.putAll(groupByExpressionBuilder.getVariableExpressionExecutorMap());
        }
    }
    if (havingExpressionBuilder != null) {
        expressionExecutorMap.putAll(havingExpressionBuilder.getVariableExpressionExecutorMap());
    }
    if (orderByAttributeBuilders != null && orderByAttributeBuilders.size() != 0) {
        for (OrderByAttributeBuilder orderByAttributeBuilder : orderByAttributeBuilders) {
            expressionExecutorMap.putAll(orderByAttributeBuilder.getExpressionBuilder().getVariableExpressionExecutorMap());
        }
    }
    if (cacheEnabled) {
        CompiledSelectionWithCache compiledSelectionWithCache;
        MetaStateEvent metaStateEventForCacheSelection = matchingMetaInfoHolder.getMetaStateEvent().clone();
        ReturnStream returnStream = new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS);
        int metaPosition = SiddhiConstants.UNKNOWN_STATE;
        List<VariableExpressionExecutor> variableExpressionExecutorsForQuerySelector = new ArrayList<>();
        QuerySelector querySelector = SelectorParser.parse(selector, returnStream, metaStateEventForCacheSelection, tableMap, variableExpressionExecutorsForQuerySelector, metaPosition, ProcessingMode.BATCH, false, siddhiQueryContext);
        if (matchingMetaInfoHolder.getMetaStateEvent().getOutputDataAttributes().size() == 0) {
            for (MetaStateEventAttribute outputDataAttribute : metaStateEventForCacheSelection.getOutputDataAttributes()) {
                matchingMetaInfoHolder.getMetaStateEvent().addOutputDataAllowingDuplicate(outputDataAttribute);
            }
        }
        QueryParserHelper.updateVariablePosition(metaStateEventForCacheSelection, variableExpressionExecutorsForQuerySelector);
        querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(metaStateEventForCacheSelection));
        RecordStoreCompiledSelection recordStoreCompiledSelection = new RecordStoreCompiledSelection(expressionExecutorMap, compiledSelection);
        compiledSelectionWithCache = new CompiledSelectionWithCache(recordStoreCompiledSelection, querySelector, metaStateEventForCacheSelection, matchingMetaInfoHolder.getStoreEventIndex(), variableExpressionExecutorsForQuerySelector);
        return compiledSelectionWithCache;
    } else {
        return new RecordStoreCompiledSelection(expressionExecutorMap, compiledSelection);
    }
}
Also used : Variable(io.siddhi.query.api.expression.Variable) MetaStateEventAttribute(io.siddhi.core.event.state.MetaStateEventAttribute) Attribute(io.siddhi.query.api.definition.Attribute) OrderByAttribute(io.siddhi.query.api.execution.query.selection.OrderByAttribute) OutputAttribute(io.siddhi.query.api.execution.query.selection.OutputAttribute) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) OutputAttribute(io.siddhi.query.api.execution.query.selection.OutputAttribute) MetaStateEventAttribute(io.siddhi.core.event.state.MetaStateEventAttribute) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) ExpressionExecutor(io.siddhi.core.executor.ExpressionExecutor) ConstantExpressionExecutor(io.siddhi.core.executor.ConstantExpressionExecutor) SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) QuerySelector(io.siddhi.core.query.selector.QuerySelector) ReturnStream(io.siddhi.query.api.execution.query.output.stream.ReturnStream) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent) MatchingMetaInfoHolder(io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) CompiledSelection(io.siddhi.core.util.collection.operator.CompiledSelection) OrderByAttribute(io.siddhi.query.api.execution.query.selection.OrderByAttribute) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent)

Example 9 with QuerySelector

use of io.siddhi.core.query.selector.QuerySelector in project siddhi by wso2.

the class OnDemandQueryParser method getQuerySelector.

private static QuerySelector getQuerySelector(MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, Map<String, Window> windowMap, int metaPosition, OnDemandQuery onDemandQuery, LockWrapper lockWrapper, SiddhiQueryContext siddhiQueryContext) {
    QuerySelector querySelector = SelectorParser.parse(onDemandQuery.getSelector(), onDemandQuery.getOutputStream(), matchingMetaInfoHolder.getMetaStateEvent(), tableMap, variableExpressionExecutors, metaPosition, ProcessingMode.BATCH, false, siddhiQueryContext);
    PassThroughOutputRateLimiter rateLimiter = new PassThroughOutputRateLimiter(siddhiQueryContext.getName());
    rateLimiter.init(lockWrapper, !onDemandQuery.getSelector().getGroupByList().isEmpty(), siddhiQueryContext);
    OutputCallback outputCallback = OutputParser.constructOutputCallback(onDemandQuery.getOutputStream(), matchingMetaInfoHolder.getMetaStateEvent().getOutputStreamDefinition(), tableMap, windowMap, true, siddhiQueryContext);
    rateLimiter.setOutputCallback(outputCallback);
    querySelector.setNextProcessor(rateLimiter);
    QueryParserHelper.reduceMetaComplexEvent(matchingMetaInfoHolder.getMetaStateEvent());
    QueryParserHelper.updateVariablePosition(matchingMetaInfoHolder.getMetaStateEvent(), variableExpressionExecutors);
    querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(matchingMetaInfoHolder.getMetaStateEvent()));
    return querySelector;
}
Also used : QuerySelector(io.siddhi.core.query.selector.QuerySelector) PassThroughOutputRateLimiter(io.siddhi.core.query.output.ratelimit.PassThroughOutputRateLimiter) OutputCallback(io.siddhi.core.query.output.callback.OutputCallback)

Example 10 with QuerySelector

use of io.siddhi.core.query.selector.QuerySelector in project siddhi by wso2.

the class TestStoreForCachePreLoading method compileSelection.

@Override
protected CompiledSelection compileSelection(List<SelectAttributeBuilder> selectAttributeBuilders, List<ExpressionBuilder> groupByExpressionBuilder, ExpressionBuilder havingExpressionBuilder, List<OrderByAttributeBuilder> orderByAttributeBuilders, Long limit, Long offset) {
    CompiledSelectionWithCache compiledSelectionWithCache;
    MetaStateEvent metaStateEvent = matchingMetaInfoHolderForTestOnDemandQuery.getMetaStateEvent().clone();
    ReturnStream returnStream = new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS);
    int metaPosition = SiddhiConstants.UNKNOWN_STATE;
    List<VariableExpressionExecutor> variableExpressionExecutorsForQuerySelector = new ArrayList<>();
    if (metaStateEvent.getOutputDataAttributes().size() == 0) {
        for (Attribute outputAttribute : metaStateEvent.getMetaStreamEvents()[0].getOnAfterWindowData()) {
            metaStateEvent.getMetaStreamEvents()[0].addOutputData(outputAttribute);
        }
    }
    QuerySelector querySelector = SelectorParser.parse(selectorForTestOnDemandQuery, returnStream, metaStateEvent, tableMap, variableExpressionExecutorsForQuerySelector, metaPosition, ProcessingMode.BATCH, false, siddhiQueryContextForTestOnDemandQuery);
    QueryParserHelper.updateVariablePosition(metaStateEvent, variableExpressionExecutorsForQuerySelector);
    querySelector.setEventPopulator(StateEventPopulatorFactory.constructEventPopulator(metaStateEvent));
    compiledSelectionWithCache = new CompiledSelectionWithCache(null, querySelector, metaStateEvent, 0, null);
    return compiledSelectionWithCache;
}
Also used : Attribute(io.siddhi.query.api.definition.Attribute) VariableExpressionExecutor(io.siddhi.core.executor.VariableExpressionExecutor) ArrayList(java.util.ArrayList) QuerySelector(io.siddhi.core.query.selector.QuerySelector) ReturnStream(io.siddhi.query.api.execution.query.output.stream.ReturnStream) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent)

Aggregations

QuerySelector (io.siddhi.core.query.selector.QuerySelector)10 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)7 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)7 ArrayList (java.util.ArrayList)7 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)6 Attribute (io.siddhi.query.api.definition.Attribute)6 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)5 CompiledSelection (io.siddhi.core.util.collection.operator.CompiledSelection)5 ReturnStream (io.siddhi.query.api.execution.query.output.stream.ReturnStream)5 StateEventFactory (io.siddhi.core.event.state.StateEventFactory)4 SiddhiConstants (io.siddhi.core.util.SiddhiConstants)4 CompiledCondition (io.siddhi.core.util.collection.operator.CompiledCondition)4 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)4 OutputStream (io.siddhi.query.api.execution.query.output.stream.OutputStream)4 List (java.util.List)4 Map (java.util.Map)4 StateEventPopulatorFactory (io.siddhi.core.event.state.populater.StateEventPopulatorFactory)3 OutputCallback (io.siddhi.core.query.output.callback.OutputCallback)3 ProcessingMode (io.siddhi.core.query.processor.ProcessingMode)3 AbstractQueryableRecordTable (io.siddhi.core.table.record.AbstractQueryableRecordTable)3