Search in sources :

Example 31 with VariableExpressionExecutor

use of org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor in project ballerina by ballerina-lang.

the class ExpressionBuilder method buildStreamVariableExecutor.

private void buildStreamVariableExecutor(Variable variable, int streamEventChainIndex, ExpressionVisitor expressionVisitor, Attribute.Type type) {
    String id = variable.getAttributeName();
    if (variable.getStreamId() != null) {
        id = variable.getStreamId() + "." + id;
    }
    expressionVisitor.beginVisitStreamVariable(id, variable.getStreamId(), variable.getAttributeName(), type);
    if (!variableExpressionExecutorMap.containsKey(id)) {
        ExpressionExecutor variableExpressionExecutor = ExpressionParser.parseExpression(variable, matchingMetaInfoHolder.getMetaStateEvent(), streamEventChainIndex, tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, queryName);
        variableExpressionExecutorMap.put(id, variableExpressionExecutor);
    }
    expressionVisitor.endVisitStreamVariable(id, variable.getStreamId(), variable.getAttributeName(), type);
}
Also used : ExpressionExecutor(org.ballerinalang.siddhi.core.executor.ExpressionExecutor) VariableExpressionExecutor(org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor)

Example 32 with VariableExpressionExecutor

use of org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor in project ballerina by ballerina-lang.

the class InMemoryTable method compileUpdateSet.

@Override
public CompiledUpdateSet compileUpdateSet(UpdateSet updateSet, MatchingMetaInfoHolder matchingMetaInfoHolder, SiddhiAppContext siddhiAppContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, String queryName) {
    Map<Integer, ExpressionExecutor> expressionExecutorMap = new HashMap<>();
    for (UpdateSet.SetAttribute setAttribute : updateSet.getSetAttributeList()) {
        ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(setAttribute.getAssignmentExpression(), matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, queryName);
        int attributePosition = tableDefinition.getAttributePosition(setAttribute.getTableVariable().getAttributeName());
        expressionExecutorMap.put(attributePosition, expressionExecutor);
    }
    return new InMemoryCompiledUpdateSet(expressionExecutorMap);
}
Also used : ExpressionExecutor(org.ballerinalang.siddhi.core.executor.ExpressionExecutor) VariableExpressionExecutor(org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor) HashMap(java.util.HashMap) UpdateSet(org.ballerinalang.siddhi.query.api.execution.query.output.stream.UpdateSet)

Aggregations

VariableExpressionExecutor (org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor)32 ExpressionExecutor (org.ballerinalang.siddhi.core.executor.ExpressionExecutor)23 MetaStreamEvent (org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)15 Attribute (org.ballerinalang.siddhi.query.api.definition.Attribute)15 ConstantExpressionExecutor (org.ballerinalang.siddhi.core.executor.ConstantExpressionExecutor)13 ArrayList (java.util.ArrayList)10 MetaStateEvent (org.ballerinalang.siddhi.core.event.state.MetaStateEvent)10 Expression (org.ballerinalang.siddhi.query.api.expression.Expression)9 SiddhiAppCreationException (org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException)8 Variable (org.ballerinalang.siddhi.query.api.expression.Variable)8 AbstractDefinition (org.ballerinalang.siddhi.query.api.definition.AbstractDefinition)7 HashMap (java.util.HashMap)6 AndConditionExpressionExecutor (org.ballerinalang.siddhi.core.executor.condition.AndConditionExpressionExecutor)5 OutputAttribute (org.ballerinalang.siddhi.query.api.execution.query.selection.OutputAttribute)5 Map (java.util.Map)4 ConditionExpressionExecutor (org.ballerinalang.siddhi.core.executor.condition.ConditionExpressionExecutor)4 Table (org.ballerinalang.siddhi.core.table.Table)4 Test (org.testng.annotations.Test)4 AggregationRuntime (org.ballerinalang.siddhi.core.aggregation.AggregationRuntime)3 SingleStreamRuntime (org.ballerinalang.siddhi.core.query.input.stream.single.SingleStreamRuntime)3