Search in sources :

Example 1 with FindOnDemandQueryRuntime

use of io.siddhi.core.query.FindOnDemandQueryRuntime in project siddhi by wso2.

the class OnDemandQueryParser method constructOnDemandQueryRuntime.

private static OnDemandQueryRuntime constructOnDemandQueryRuntime(Window window, OnDemandQuery onDemandQuery, Map<String, Table> tableMap, Map<String, Window> windowMap, int metaPosition, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors, LockWrapper lockWrapper, SiddhiQueryContext siddhiQueryContext) {
    metaStreamEvent.setEventType(EventType.WINDOW);
    initMetaStreamEvent(metaStreamEvent, window.getWindowDefinition());
    MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, window.getWindowDefinition());
    CompiledCondition compiledCondition = window.compileCondition(onCondition, generateMatchingMetaInfoHolder(metaStreamEvent, window.getWindowDefinition()), variableExpressionExecutors, tableMap, siddhiQueryContext);
    FindOnDemandQueryRuntime findOnDemandQueryRuntime = new FindOnDemandQueryRuntime(window, compiledCondition, siddhiQueryContext.getName(), metaStreamEvent);
    populateFindOnDemandQueryRuntime(findOnDemandQueryRuntime, metaStreamInfoHolder, onDemandQuery.getSelector(), variableExpressionExecutors, tableMap, windowMap, metaPosition, !onDemandQuery.getSelector().getGroupByList().isEmpty(), lockWrapper, siddhiQueryContext);
    return findOnDemandQueryRuntime;
}
Also used : CompiledCondition(io.siddhi.core.util.collection.operator.CompiledCondition) FindOnDemandQueryRuntime(io.siddhi.core.query.FindOnDemandQueryRuntime) MatchingMetaInfoHolder(io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)

Example 2 with FindOnDemandQueryRuntime

use of io.siddhi.core.query.FindOnDemandQueryRuntime in project siddhi by wso2.

the class OnDemandQueryParser method constructOnDemandQueryRuntime.

private static OnDemandQueryRuntime constructOnDemandQueryRuntime(AggregationRuntime aggregation, OnDemandQuery onDemandQuery, Map<String, Table> tableMap, Map<String, Window> windowMap, Within within, Expression per, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors, LockWrapper lockWrapper, SiddhiQueryContext siddhiQueryContext) {
    int metaPosition;
    metaStreamEvent.setEventType(EventType.AGGREGATE);
    initMetaStreamEvent(metaStreamEvent, aggregation.getAggregationDefinition());
    MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, aggregation.getAggregationDefinition());
    CompiledCondition compiledCondition = aggregation.compileExpression(onCondition, within, per, onDemandQuery.getSelector().getGroupByList(), metaStreamInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);
    ((IncrementalAggregateCompileCondition) compiledCondition).init();
    metaStreamInfoHolder = ((IncrementalAggregateCompileCondition) compiledCondition).getAlteredMatchingMetaInfoHolder();
    FindOnDemandQueryRuntime findOnDemandQueryRuntime = new FindOnDemandQueryRuntime(aggregation, compiledCondition, siddhiQueryContext.getName(), metaStreamEvent, siddhiQueryContext);
    metaPosition = 1;
    populateFindOnDemandQueryRuntime(findOnDemandQueryRuntime, metaStreamInfoHolder, onDemandQuery.getSelector(), variableExpressionExecutors, tableMap, windowMap, metaPosition, !onDemandQuery.getSelector().getGroupByList().isEmpty(), lockWrapper, siddhiQueryContext);
    ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0), 0, ((IncrementalAggregateCompileCondition) compiledCondition).getAdditionalAttributes());
    ((IncrementalAggregateCompileCondition) compiledCondition).setComplexEventPopulater(complexEventPopulater);
    return findOnDemandQueryRuntime;
}
Also used : CompiledCondition(io.siddhi.core.util.collection.operator.CompiledCondition) FindOnDemandQueryRuntime(io.siddhi.core.query.FindOnDemandQueryRuntime) MatchingMetaInfoHolder(io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) IncrementalAggregateCompileCondition(io.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition) ComplexEventPopulater(io.siddhi.core.event.stream.populater.ComplexEventPopulater)

Example 3 with FindOnDemandQueryRuntime

use of io.siddhi.core.query.FindOnDemandQueryRuntime in project siddhi by wso2.

the class OnDemandQueryParser method constructRegularOnDemandQueryRuntime.

private static OnDemandQueryRuntime constructRegularOnDemandQueryRuntime(Table table, OnDemandQuery onDemandQuery, Map<String, Table> tableMap, Map<String, Window> windowMap, int metaPosition, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors, LockWrapper lockWrapper, SiddhiQueryContext siddhiQueryContext) {
    MatchingMetaInfoHolder matchingMetaInfoHolder;
    AbstractDefinition inputDefinition;
    QuerySelector querySelector;
    switch(onDemandQuery.getType()) {
        case FIND:
            initMetaStreamEvent(metaStreamEvent, table.getTableDefinition());
            matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, table.getTableDefinition());
            CompiledCondition compiledCondition = table.compileCondition(onCondition, matchingMetaInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);
            FindOnDemandQueryRuntime findOnDemandQueryRuntime = new FindOnDemandQueryRuntime(table, compiledCondition, siddhiQueryContext.getName(), metaStreamEvent);
            populateFindOnDemandQueryRuntime(findOnDemandQueryRuntime, matchingMetaInfoHolder, onDemandQuery.getSelector(), variableExpressionExecutors, tableMap, windowMap, metaPosition, !onDemandQuery.getSelector().getGroupByList().isEmpty(), lockWrapper, siddhiQueryContext);
            return findOnDemandQueryRuntime;
        case INSERT:
            initMetaStreamEvent(metaStreamEvent, getInputDefinition(onDemandQuery, table));
            matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, table.getTableDefinition());
            querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors, tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);
            InsertOnDemandQueryRuntime insertOnDemandQueryRuntime = new InsertOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
            insertOnDemandQueryRuntime.setStateEventFactory(new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
            insertOnDemandQueryRuntime.setSelector(querySelector);
            insertOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent().getOutputStreamDefinition().getAttributeList());
            return insertOnDemandQueryRuntime;
        case DELETE:
            inputDefinition = getInputDefinition(onDemandQuery, table);
            initMetaStreamEvent(metaStreamEvent, inputDefinition);
            matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, inputDefinition, table.getTableDefinition());
            querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors, tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);
            DeleteOnDemandQueryRuntime deleteOnDemandQueryRuntime = new DeleteOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
            deleteOnDemandQueryRuntime.setStateEventFactory(new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
            deleteOnDemandQueryRuntime.setSelector(querySelector);
            deleteOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent().getOutputStreamDefinition().getAttributeList());
            return deleteOnDemandQueryRuntime;
        case UPDATE:
            inputDefinition = getInputDefinition(onDemandQuery, table);
            initMetaStreamEvent(metaStreamEvent, inputDefinition);
            matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, inputDefinition, table.getTableDefinition());
            querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors, tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);
            UpdateOnDemandQueryRuntime updateOnDemandQueryRuntime = new UpdateOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
            updateOnDemandQueryRuntime.setStateEventFactory(new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
            updateOnDemandQueryRuntime.setSelector(querySelector);
            updateOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent().getOutputStreamDefinition().getAttributeList());
            return updateOnDemandQueryRuntime;
        case UPDATE_OR_INSERT:
            inputDefinition = getInputDefinition(onDemandQuery, table);
            initMetaStreamEvent(metaStreamEvent, inputDefinition);
            matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, inputDefinition, table.getTableDefinition());
            querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors, tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);
            UpdateOrInsertOnDemandQueryRuntime updateOrInsertIntoOnDemandQueryRuntime = new UpdateOrInsertOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
            updateOrInsertIntoOnDemandQueryRuntime.setStateEventFactory(new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
            updateOrInsertIntoOnDemandQueryRuntime.setSelector(querySelector);
            updateOrInsertIntoOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent().getOutputStreamDefinition().getAttributeList());
            return updateOrInsertIntoOnDemandQueryRuntime;
        default:
            return null;
    }
}
Also used : CompiledCondition(io.siddhi.core.util.collection.operator.CompiledCondition) FindOnDemandQueryRuntime(io.siddhi.core.query.FindOnDemandQueryRuntime) UpdateOrInsertOnDemandQueryRuntime(io.siddhi.core.query.UpdateOrInsertOnDemandQueryRuntime) InsertOnDemandQueryRuntime(io.siddhi.core.query.InsertOnDemandQueryRuntime) DeleteOnDemandQueryRuntime(io.siddhi.core.query.DeleteOnDemandQueryRuntime) MatchingMetaInfoHolder(io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) StateEventFactory(io.siddhi.core.event.state.StateEventFactory) AbstractDefinition(io.siddhi.query.api.definition.AbstractDefinition) QuerySelector(io.siddhi.core.query.selector.QuerySelector) UpdateOnDemandQueryRuntime(io.siddhi.core.query.UpdateOnDemandQueryRuntime) UpdateOrInsertOnDemandQueryRuntime(io.siddhi.core.query.UpdateOrInsertOnDemandQueryRuntime)

Aggregations

FindOnDemandQueryRuntime (io.siddhi.core.query.FindOnDemandQueryRuntime)3 CompiledCondition (io.siddhi.core.util.collection.operator.CompiledCondition)3 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)3 StateEventFactory (io.siddhi.core.event.state.StateEventFactory)1 ComplexEventPopulater (io.siddhi.core.event.stream.populater.ComplexEventPopulater)1 DeleteOnDemandQueryRuntime (io.siddhi.core.query.DeleteOnDemandQueryRuntime)1 InsertOnDemandQueryRuntime (io.siddhi.core.query.InsertOnDemandQueryRuntime)1 UpdateOnDemandQueryRuntime (io.siddhi.core.query.UpdateOnDemandQueryRuntime)1 UpdateOrInsertOnDemandQueryRuntime (io.siddhi.core.query.UpdateOrInsertOnDemandQueryRuntime)1 QuerySelector (io.siddhi.core.query.selector.QuerySelector)1 IncrementalAggregateCompileCondition (io.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition)1 AbstractDefinition (io.siddhi.query.api.definition.AbstractDefinition)1