Search in sources :

Example 31 with Expression

use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitSet_clause.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public UpdateSet visitSet_clause(@NotNull SiddhiQLParser.Set_clauseContext ctx) {
    UpdateSet updateSet = new UpdateSet();
    for (SiddhiQLParser.Set_assignmentContext setAssignmentContext : ctx.set_assignment()) {
        updateSet.set(((Variable) visit(setAssignmentContext.attribute_reference())), (Expression) visit(setAssignmentContext.expression()));
    }
    populateQueryContext(updateSet, ctx);
    return updateSet;
}
Also used : SiddhiQLParser(org.wso2.siddhi.query.compiler.SiddhiQLParser) Variable(org.wso2.siddhi.query.api.expression.Variable) UpdateSet(org.wso2.siddhi.query.api.execution.query.output.stream.UpdateSet)

Example 32 with Expression

use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitStore_input.

@Override
public Object visitStore_input(SiddhiQLParser.Store_inputContext ctx) {
    String sourceId = (String) visit(ctx.source_id());
    String alias = null;
    if (ctx.alias() != null) {
        alias = (String) visit(ctx.source_id());
    }
    Store store = InputStore.store(alias, sourceId);
    Expression expression = null;
    if (ctx.expression() != null) {
        expression = (Expression) visit(ctx.expression());
    }
    populateQueryContext(store, ctx);
    if (ctx.per() != null) {
        return store.on(expression, (Within) visit(ctx.within_time_range()), (Expression) visit(ctx.per()));
    } else if (expression != null) {
        return store.on(expression);
    } else {
        return store;
    }
}
Also used : Expression(org.wso2.siddhi.query.api.expression.Expression) Store(org.wso2.siddhi.query.api.execution.query.input.store.Store) InputStore(org.wso2.siddhi.query.api.execution.query.input.store.InputStore)

Example 33 with Expression

use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitFilter.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Filter visitFilter(@NotNull SiddhiQLParser.FilterContext ctx) {
    Filter filter = new Filter((Expression) visit(ctx.expression()));
    populateQueryContext(filter, ctx);
    return filter;
}
Also used : Filter(org.wso2.siddhi.query.api.execution.query.input.handler.Filter)

Example 34 with Expression

use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitFunction_operation.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Object visitFunction_operation(@NotNull SiddhiQLParser.Function_operationContext ctx) {
    Expression expression;
    if (ctx.function_namespace() != null) {
        if (ctx.attribute_list() != null) {
            expression = Expression.function((String) visit(ctx.function_namespace()), (String) visit(ctx.function_id()), (Expression[]) visit(ctx.attribute_list()));
        } else {
            expression = Expression.function((String) visit(ctx.function_namespace()), (String) visit(ctx.function_id()), null);
        }
    } else {
        if (ctx.attribute_list() != null) {
            expression = Expression.function((String) visit(ctx.function_id()), (Expression[]) visit(ctx.attribute_list()));
        } else {
            expression = Expression.function((String) visit(ctx.function_id()), null);
        }
    }
    populateQueryContext(expression, ctx);
    return expression;
}
Also used : Expression(org.wso2.siddhi.query.api.expression.Expression)

Example 35 with Expression

use of org.wso2.siddhi.query.api.expression.Expression in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitAnd_math_operation.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Expression visitAnd_math_operation(@NotNull SiddhiQLParser.And_math_operationContext ctx) {
    if (ctx.AND() != null) {
        Expression expression = Expression.and((Expression) visit(ctx.math_operation(0)), (Expression) visit(ctx.math_operation(1)));
        populateQueryContext(expression, ctx);
        return expression;
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : Expression(org.wso2.siddhi.query.api.expression.Expression)

Aggregations

Expression (org.wso2.siddhi.query.api.expression.Expression)32 ArrayList (java.util.ArrayList)20 Attribute (org.wso2.siddhi.query.api.definition.Attribute)16 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)15 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)15 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)13 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)13 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)13 Variable (org.wso2.siddhi.query.api.expression.Variable)11 Test (org.testng.annotations.Test)10 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)10 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)10 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)10 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)9 OutputAttribute (org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute)8 CompiledCondition (org.wso2.siddhi.core.util.collection.operator.CompiledCondition)7 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)6 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)6 MatchingMetaInfoHolder (org.wso2.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)6 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)6