Search in sources :

Example 6 with UpdateSet

use of io.siddhi.query.api.execution.query.output.stream.UpdateSet 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(io.siddhi.query.compiler.SiddhiQLParser) Variable(io.siddhi.query.api.expression.Variable) UpdateSet(io.siddhi.query.api.execution.query.output.stream.UpdateSet)

Example 7 with UpdateSet

use of io.siddhi.query.api.execution.query.output.stream.UpdateSet in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitStore_query_output.

/**
 * {@inheritDoc}
 * <p>
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 */
@Override
public OutputStream visitStore_query_output(@NotNull SiddhiQLParser.Store_query_outputContext ctx) {
    if (ctx.DELETE() != null) {
        Source source = (Source) visit(ctx.target());
        if (source.isInnerStream || source.isFaultStream) {
            throw newSiddhiParserException(ctx, "DELETE can be only used with Tables!");
        }
        Expression expression = null;
        if (ctx.expression() != null) {
            expression = (Expression) visit(ctx.expression());
        }
        OutputStream outputStream = new DeleteStream(source.streamId, expression);
        populateQueryContext(outputStream, ctx);
        return outputStream;
    } else if (ctx.UPDATE() != null) {
        Source source = (Source) visit(ctx.target());
        if (source.isInnerStream || source.isFaultStream) {
            throw newSiddhiParserException(ctx, "DELETE can be only used with Tables!");
        }
        if (ctx.set_clause() != null) {
            OutputStream outputStream = new UpdateStream(source.streamId, (UpdateSet) visit(ctx.set_clause()), (Expression) visit(ctx.expression()));
            populateQueryContext(outputStream, ctx);
            return outputStream;
        } else {
            OutputStream outputStream = new UpdateStream(source.streamId, (Expression) visit(ctx.expression()));
            populateQueryContext(outputStream, ctx);
            return outputStream;
        }
    } else {
        throw newSiddhiParserException(ctx);
    }
}
Also used : Expression(io.siddhi.query.api.expression.Expression) DeleteStream(io.siddhi.query.api.execution.query.output.stream.DeleteStream) OutputStream(io.siddhi.query.api.execution.query.output.stream.OutputStream) UpdateStream(io.siddhi.query.api.execution.query.output.stream.UpdateStream) UpdateSet(io.siddhi.query.api.execution.query.output.stream.UpdateSet)

Aggregations

UpdateSet (io.siddhi.query.api.execution.query.output.stream.UpdateSet)7 CompiledUpdateSet (io.siddhi.core.table.CompiledUpdateSet)4 Variable (io.siddhi.query.api.expression.Variable)4 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)3 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)3 Attribute (io.siddhi.query.api.definition.Attribute)3 TableDefinition (io.siddhi.query.api.definition.TableDefinition)3 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)2 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)2 DeleteStream (io.siddhi.query.api.execution.query.output.stream.DeleteStream)2 UpdateStream (io.siddhi.query.api.execution.query.output.stream.UpdateStream)2 HashMap (java.util.HashMap)2 StateEventFactory (io.siddhi.core.event.state.StateEventFactory)1 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)1 StreamEventConverter (io.siddhi.core.event.stream.converter.StreamEventConverter)1 ZeroStreamEventConverter (io.siddhi.core.event.stream.converter.ZeroStreamEventConverter)1 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)1 DeleteTableCallback (io.siddhi.core.query.output.callback.DeleteTableCallback)1 InsertIntoStreamCallback (io.siddhi.core.query.output.callback.InsertIntoStreamCallback)1 InsertIntoStreamEndPartitionCallback (io.siddhi.core.query.output.callback.InsertIntoStreamEndPartitionCallback)1