use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.
the class PartitionRuntime method addPartitionReceiver.
public void addPartitionReceiver(QueryRuntime queryRuntime, List<VariableExpressionExecutor> executors, MetaStateEvent metaEvent) {
Query query = queryRuntime.getQuery();
List<List<PartitionExecutor>> partitionExecutors = new StreamPartitioner(query.getInputStream(), partition, metaEvent, executors, siddhiAppContext, null).getPartitionExecutorLists();
if (queryRuntime.getStreamRuntime() instanceof SingleStreamRuntime) {
SingleInputStream singleInputStream = (SingleInputStream) query.getInputStream();
addPartitionReceiver(singleInputStream.getStreamId(), singleInputStream.isInnerStream(), metaEvent.getMetaStreamEvent(0), partitionExecutors.get(0));
} else if (queryRuntime.getStreamRuntime() instanceof JoinStreamRuntime) {
SingleInputStream leftSingleInputStream = (SingleInputStream) ((JoinInputStream) query.getInputStream()).getLeftInputStream();
addPartitionReceiver(leftSingleInputStream.getStreamId(), leftSingleInputStream.isInnerStream(), metaEvent.getMetaStreamEvent(0), partitionExecutors.get(0));
SingleInputStream rightSingleInputStream = (SingleInputStream) ((JoinInputStream) query.getInputStream()).getRightInputStream();
addPartitionReceiver(rightSingleInputStream.getStreamId(), rightSingleInputStream.isInnerStream(), metaEvent.getMetaStreamEvent(1), partitionExecutors.get(1));
} else if (queryRuntime.getStreamRuntime() instanceof StateStreamRuntime) {
StateElement stateElement = ((StateInputStream) query.getInputStream()).getStateElement();
addPartitionReceiverForStateElement(stateElement, metaEvent, partitionExecutors, 0);
}
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitEvery_sequence_source_chain.
@Override
public Object visitEvery_sequence_source_chain(SiddhiQLParser.Every_sequence_source_chainContext ctx) {
// every_sequence_source_chain
// : EVERY? sequence_source within_time? ',' sequence_source_chain
// ;
StateElement stateElement1;
if (ctx.EVERY() != null) {
stateElement1 = new EveryStateElement((StateElement) visit(ctx.sequence_source()));
} else {
stateElement1 = (StateElement) visit(ctx.sequence_source());
}
if (ctx.within_time() != null) {
stateElement1.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(stateElement1, ctx);
NextStateElement nextStateElement = new NextStateElement(stateElement1, ((StateElement) visit(ctx.sequence_source_chain())));
populateQueryContext(nextStateElement, ctx);
StateInputStream stateInputStream = new StateInputStream(StateInputStream.Type.SEQUENCE, nextStateElement);
populateQueryContext(stateInputStream, ctx);
return stateInputStream;
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitEvery_pattern_source_chain.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public Object visitEvery_pattern_source_chain(@NotNull SiddhiQLParser.Every_pattern_source_chainContext ctx) {
if (ctx.every_pattern_source_chain().size() == 1) {
// '('every_pattern_source_chain')' within_time?
StateElement stateElement = ((StateElement) visit(ctx.every_pattern_source_chain(0)));
if (ctx.within_time() != null) {
stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(stateElement, ctx);
return stateElement;
} else if (ctx.every_pattern_source_chain().size() == 2) {
// every_pattern_source_chain '->'
// every_pattern_source_chain
NextStateElement nextStateElement = new NextStateElement(((StateElement) visit(ctx.every_pattern_source_chain(0))), ((StateElement) visit(ctx.every_pattern_source_chain(1))));
populateQueryContext(nextStateElement, ctx);
return nextStateElement;
} else if (ctx.EVERY() != null) {
if (ctx.pattern_source_chain() != null) {
// EVERY '('pattern_source_chain ')' within_time?
EveryStateElement everyStateElement = new EveryStateElement((StateElement) visit(ctx.pattern_source_chain()));
if (ctx.within_time() != null) {
everyStateElement.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(everyStateElement, ctx);
return everyStateElement;
} else if (ctx.pattern_source() != null) {
// EVERY pattern_source within_time?
EveryStateElement everyStateElement = new EveryStateElement((StateElement) visit(ctx.pattern_source()));
if (ctx.within_time() != null) {
everyStateElement.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(everyStateElement, ctx);
return everyStateElement;
} else {
throw newSiddhiParserException(ctx);
}
} else if (ctx.pattern_source_chain() != null) {
// pattern_source_chain
StateElement stateElement = ((StateElement) visit(ctx.pattern_source_chain()));
if (ctx.within_time() != null) {
stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(stateElement, ctx);
return stateElement;
} else {
throw newSiddhiParserException(ctx);
}
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitSequence_source_chain.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public StateElement visitSequence_source_chain(@NotNull SiddhiQLParser.Sequence_source_chainContext ctx) {
if (ctx.sequence_source_chain().size() == 1) {
StateElement stateElement = ((StateElement) visit(ctx.sequence_source_chain(0)));
if (ctx.within_time() != null) {
stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(stateElement, ctx);
return stateElement;
} else if (ctx.sequence_source_chain().size() == 2) {
NextStateElement nextStateElement = new NextStateElement(((StateElement) visit(ctx.sequence_source_chain(0))), ((StateElement) visit(ctx.sequence_source_chain(1))));
populateQueryContext(nextStateElement, ctx);
return nextStateElement;
} else if (ctx.sequence_source() != null) {
StateElement stateElement = ((StateElement) visit(ctx.sequence_source()));
if (ctx.within_time() != null) {
stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(stateElement, ctx);
return stateElement;
} else {
throw newSiddhiParserException(ctx);
}
}
use of org.ballerinalang.siddhi.query.api.execution.query.input.state.StateElement in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitLeft_absent_pattern_source.
@Override
public Object visitLeft_absent_pattern_source(SiddhiQLParser.Left_absent_pattern_sourceContext ctx) {
if (ctx.left_absent_pattern_source().size() == 1 && ctx.every_absent_pattern_source() == null && ctx.every_pattern_source_chain() == null) {
// EVERY? '('left_absent_pattern_source')' within_time?
StateElement stateElement = (StateElement) visit(ctx.left_absent_pattern_source(0));
if (ctx.EVERY() != null) {
stateElement = new EveryStateElement(stateElement);
}
if (ctx.within_time() != null) {
stateElement.setWithin((TimeConstant) visit(ctx.within_time()));
}
populateQueryContext(stateElement, ctx);
return stateElement;
} else {
NextStateElement nextStateElement = new NextStateElement((StateElement) visit(ctx.getChild(0)), (StateElement) visit(ctx.getChild(2)));
populateQueryContext(nextStateElement, ctx);
return nextStateElement;
}
}
Aggregations