use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class AggregationGroupByWindowedPerSnapshotOutputRateLimiter method constructOutputChunk.
private void constructOutputChunk(List<ComplexEventChunk<ComplexEvent>> outputEventChunks) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<ComplexEvent>(false);
for (GroupedComplexEvent originalComplexEvent : eventList) {
String currentGroupByKey = originalComplexEvent.getGroupKey();
Map<Integer, Object> currentAggregateAttributeValueMap = groupByAggregateAttributeValueMap.get(currentGroupByKey);
ComplexEvent eventCopy = cloneComplexEvent(originalComplexEvent.getComplexEvent());
for (Integer position : aggregateAttributePositionList) {
eventCopy.getOutputData()[position] = currentAggregateAttributeValueMap.get(position);
}
outputEventChunk.add(eventCopy);
}
outputEventChunks.add(outputEventChunk);
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class AggregationWindowedPerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
ArrayList<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event);
} else {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event);
if (event.getType() == ComplexEvent.Type.CURRENT) {
eventList.add(event);
for (Integer position : aggregateAttributePositionList) {
aggregateAttributeValueMap.put(position, event.getOutputData()[position]);
}
} else if (event.getType() == ComplexEvent.Type.EXPIRED) {
for (Iterator<ComplexEvent> iterator = eventList.iterator(); iterator.hasNext(); ) {
ComplexEvent complexEvent = iterator.next();
if (comparator.compare(event, complexEvent) == 0) {
iterator.remove();
for (Integer position : aggregateAttributePositionList) {
aggregateAttributeValueMap.put(position, event.getOutputData()[position]);
}
break;
}
}
} else if (event.getType() == ComplexEvent.Type.RESET) {
eventList.clear();
aggregateAttributeValueMap.clear();
}
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class AggregationWindowedPerSnapshotOutputRateLimiter method tryFlushEvents.
private void tryFlushEvents(ArrayList<ComplexEventChunk<ComplexEvent>> outputEventChunks, ComplexEvent event) {
if (event.getTimestamp() >= scheduledTime) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<ComplexEvent>(false);
for (ComplexEvent originalComplexEvent : eventList) {
ComplexEvent eventCopy = cloneComplexEvent(originalComplexEvent);
for (Integer position : aggregateAttributePositionList) {
eventCopy.getOutputData()[position] = aggregateAttributeValueMap.get(position);
}
outputEventChunk.add(eventCopy);
}
outputEventChunks.add(outputEventChunk);
scheduledTime += value;
scheduler.notifyAt(scheduledTime);
}
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class GroupByPerSnapshotOutputRateLimiter method tryFlushEvents.
private void tryFlushEvents(List<ComplexEventChunk<ComplexEvent>> outputEventChunks, ComplexEvent event) {
if (event.getTimestamp() >= scheduledTime) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<ComplexEvent>(false);
for (ComplexEvent complexEvent : groupByKeyEvents.values()) {
outputEventChunk.add(cloneComplexEvent(complexEvent));
}
outputEventChunks.add(outputEventChunk);
scheduledTime += value;
scheduler.notifyAt(scheduledTime);
}
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class ListEventHolder method add.
@Override
public void add(ComplexEventChunk<StreamEvent> addingEventChunk) {
addingEventChunk.reset();
while (addingEventChunk.hasNext()) {
ComplexEvent complexEvent = addingEventChunk.next();
StreamEvent streamEvent = tableStreamEventPool.borrowEvent();
eventConverter.convertComplexEvent(complexEvent, streamEvent);
this.add(streamEvent);
}
}
Aggregations