use of io.siddhi.core.partition.executor.PartitionExecutor in project siddhi by wso2.
the class StreamPartitioner method createSingleInputStreamExecutors.
private void createSingleInputStreamExecutors(SingleInputStream inputStream, Partition partition, MetaStreamEvent metaEvent, List<VariableExpressionExecutor> executors, Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
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, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext)));
}
} 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, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext), rangePartitionProperty.getPartitionKey()));
}
}
}
}
}
}
use of io.siddhi.core.partition.executor.PartitionExecutor in project siddhi by wso2.
the class PartitionStreamReceiver method receive.
@Override
public void receive(long timestamp, Object[] data) {
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertData(timestamp, data, newEvent);
if (partitionExecutors.size() == 0) {
send(newEvent);
} else {
for (PartitionExecutor partitionExecutor : partitionExecutors) {
String key = partitionExecutor.execute(newEvent);
send(key, newEvent);
}
}
}
use of io.siddhi.core.partition.executor.PartitionExecutor in project siddhi by wso2.
the class PartitionStreamReceiver method receive.
@Override
public void receive(Event event) {
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertEvent(event, newEvent);
for (PartitionExecutor partitionExecutor : partitionExecutors) {
String key = partitionExecutor.execute(newEvent);
send(key, newEvent);
}
if (partitionExecutors.size() == 0) {
send(newEvent);
}
}
use of io.siddhi.core.partition.executor.PartitionExecutor in project siddhi by wso2.
the class PartitionStreamReceiver method receive.
@Override
public void receive(List<Event> events) {
if (partitionExecutors.size() == 0) {
StreamEvent firstEvent = null;
StreamEvent currentEvent = null;
for (Event event : events) {
StreamEvent nextEvent = streamEventFactory.newInstance();
streamEventConverter.convertEvent(event, nextEvent);
if (firstEvent == null) {
firstEvent = nextEvent;
} else {
currentEvent.setNext(nextEvent);
}
currentEvent = nextEvent;
}
send(firstEvent);
} else {
String key = null;
StreamEvent firstEvent = null;
StreamEvent currentEvent = null;
for (Event event : events) {
StreamEvent nextEvent = streamEventFactory.newInstance();
streamEventConverter.convertEvent(event, nextEvent);
for (PartitionExecutor partitionExecutor : partitionExecutors) {
String currentKey = partitionExecutor.execute(nextEvent);
if (currentKey != null) {
if (key == null) {
key = currentKey;
firstEvent = nextEvent;
} else if (!currentKey.equals(key)) {
send(key, firstEvent);
key = currentKey;
firstEvent = nextEvent;
} else {
currentEvent.setNext(nextEvent);
}
currentEvent = nextEvent;
}
}
}
send(key, firstEvent);
}
}
use of io.siddhi.core.partition.executor.PartitionExecutor in project siddhi by wso2.
the class PartitionStreamReceiver method receive.
@Override
public void receive(ComplexEvent complexEvent) {
if (partitionExecutors.size() == 0) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<ComplexEvent>();
ComplexEvent aComplexEvent = complexEvent;
while (aComplexEvent != null) {
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertComplexEvent(aComplexEvent, newEvent);
outputEventChunk.add(newEvent);
aComplexEvent = aComplexEvent.getNext();
}
send(outputEventChunk.getFirst());
} else {
if (complexEvent.getNext() == null) {
for (PartitionExecutor partitionExecutor : partitionExecutors) {
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertComplexEvent(complexEvent, newEvent);
String key = partitionExecutor.execute(newEvent);
send(key, newEvent);
}
} else {
ComplexEventChunk<ComplexEvent> complexEventChunk = new ComplexEventChunk<ComplexEvent>();
complexEventChunk.add(complexEvent);
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<ComplexEvent>();
String currentKey = null;
while (complexEventChunk.hasNext()) {
ComplexEvent aEvent = complexEventChunk.next();
complexEventChunk.remove();
StreamEvent newEvent = streamEventFactory.newInstance();
streamEventConverter.convertComplexEvent(aEvent, newEvent);
boolean currentEventMatchedPrevPartitionExecutor = false;
for (PartitionExecutor partitionExecutor : partitionExecutors) {
String key = partitionExecutor.execute(newEvent);
if (key != null) {
if (currentKey == null) {
currentKey = key;
} else if (!currentKey.equals(key)) {
if (!currentEventMatchedPrevPartitionExecutor) {
ComplexEvent firstEvent = outputEventChunk.getFirst();
send(currentKey, firstEvent);
currentKey = key;
outputEventChunk.clear();
} else {
ComplexEvent firstEvent = outputEventChunk.getFirst();
send(currentKey, firstEvent);
currentKey = key;
outputEventChunk.clear();
StreamEvent cloneEvent = streamEventFactory.newInstance();
streamEventConverter.convertComplexEvent(aEvent, cloneEvent);
outputEventChunk.add(cloneEvent);
}
}
if (!currentEventMatchedPrevPartitionExecutor) {
outputEventChunk.add(newEvent);
}
currentEventMatchedPrevPartitionExecutor = true;
}
}
}
send(currentKey, outputEventChunk.getFirst());
outputEventChunk.clear();
}
}
}
Aggregations