use of org.ballerinalang.siddhi.query.api.execution.partition.ValuePartitionType in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitPartition_with_stream.
/**
* {@inheritDoc}
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*
* @param ctx
*/
@Override
public PartitionType visitPartition_with_stream(@NotNull SiddhiQLParser.Partition_with_streamContext ctx) {
String streamId = (String) visit(ctx.stream_id());
activeStreams.add(streamId);
try {
if (ctx.condition_ranges() != null) {
PartitionType partitionType = new RangePartitionType(streamId, (RangePartitionType.RangePartitionProperty[]) visit(ctx.condition_ranges()));
populateQueryContext(partitionType, ctx);
return partitionType;
} else if (ctx.attribute() != null) {
PartitionType partitionType = new ValuePartitionType(streamId, (Expression) visit(ctx.attribute()));
populateQueryContext(partitionType, ctx);
return partitionType;
} else {
throw newSiddhiParserException(ctx);
}
} finally {
activeStreams.clear();
}
}
use of org.ballerinalang.siddhi.query.api.execution.partition.ValuePartitionType in project ballerina by ballerina-lang.
the class StreamPartitioner method createSingleInputStreamExecutors.
private void createSingleInputStreamExecutors(SingleInputStream inputStream, Partition partition, MetaStreamEvent metaEvent, List<VariableExpressionExecutor> executors, Map<String, Table> tableMap, SiddhiAppContext siddhiAppContext, String queryName) {
List<PartitionExecutor> executorList = new ArrayList<PartitionExecutor>();
partitionExecutorLists.add(executorList);
if (!inputStream.isInnerStream()) {
for (PartitionType partitionType : partition.getPartitionTypeMap().values()) {
if (partitionType instanceof ValuePartitionType) {
if (partitionType.getStreamId().equals(inputStream.getStreamId())) {
executorList.add(new ValuePartitionExecutor(ExpressionParser.parseExpression(((ValuePartitionType) partitionType).getExpression(), metaEvent, SiddhiConstants.UNKNOWN_STATE, tableMap, executors, siddhiAppContext, false, 0, queryName)));
}
} else {
for (RangePartitionType.RangePartitionProperty rangePartitionProperty : ((RangePartitionType) partitionType).getRangePartitionProperties()) {
if (partitionType.getStreamId().equals(inputStream.getStreamId())) {
executorList.add(new RangePartitionExecutor((ConditionExpressionExecutor) ExpressionParser.parseExpression(rangePartitionProperty.getCondition(), metaEvent, SiddhiConstants.UNKNOWN_STATE, tableMap, executors, siddhiAppContext, false, 0, queryName), rangePartitionProperty.getPartitionKey()));
}
}
}
}
}
}
Aggregations