use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class FirstGroupByPerTimeOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
ArrayList<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
complexEventChunk.reset();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
if (event.getTimestamp() >= scheduledTime) {
if (allComplexEventChunk.getFirst() != null) {
ComplexEventChunk<ComplexEvent> eventChunk = new ComplexEventChunk<ComplexEvent>(complexEventChunk.isBatch());
eventChunk.add(allComplexEventChunk.getFirst());
allComplexEventChunk.clear();
groupByKeys.clear();
outputEventChunks.add(eventChunk);
} else {
groupByKeys.clear();
}
scheduledTime = scheduledTime + value;
scheduler.notifyAt(scheduledTime);
}
} else if (event.getType() == ComplexEvent.Type.CURRENT || event.getType() == ComplexEvent.Type.EXPIRED) {
GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
if (!groupByKeys.contains(groupedComplexEvent.getGroupKey())) {
complexEventChunk.remove();
groupByKeys.add(groupedComplexEvent.getGroupKey());
allComplexEventChunk.add(groupedComplexEvent.getComplexEvent());
}
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class FirstPerTimeOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
ArrayList<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
complexEventChunk.reset();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
if (event.getTimestamp() >= scheduledTime) {
if (firstEvent != null) {
firstEvent = null;
}
scheduledTime += value;
scheduler.notifyAt(scheduledTime);
}
} else if (event.getType() == ComplexEvent.Type.CURRENT || event.getType() == ComplexEvent.Type.EXPIRED) {
if (firstEvent == null) {
complexEventChunk.remove();
firstEvent = event;
ComplexEventChunk<ComplexEvent> firstPerEventChunk = new ComplexEventChunk<ComplexEvent>(complexEventChunk.isBatch());
firstPerEventChunk.add(event);
outputEventChunks.add(firstPerEventChunk);
}
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class LastPerTimeOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
ArrayList<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
complexEventChunk.reset();
synchronized (this) {
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
if (event.getTimestamp() >= scheduledTime) {
if (lastEvent != null) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<ComplexEvent>(complexEventChunk.isBatch());
outputEventChunk.add(lastEvent);
lastEvent = null;
outputEventChunks.add(outputEventChunk);
}
scheduledTime = scheduledTime + value;
scheduler.notifyAt(scheduledTime);
}
} else if (event.getType() == ComplexEvent.Type.CURRENT || event.getType() == ComplexEvent.Type.EXPIRED) {
complexEventChunk.remove();
lastEvent = event;
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class InsertIntoStreamCallback method send.
@Override
public void send(ComplexEventChunk complexEventChunk, int noOfEvents) {
if (getSiddhiDebugger() != null) {
getSiddhiDebugger().checkBreakPoint(getQueryName(), SiddhiDebugger.QueryTerminal.OUT, complexEventChunk.getFirst());
}
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
if (complexEvent.getType() == ComplexEvent.Type.EXPIRED) {
complexEvent.setType(ComplexEvent.Type.CURRENT);
}
}
publisher.send(complexEventChunk.getFirst());
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class InsertIntoTableCallback method send.
@Override
public void send(ComplexEventChunk complexEventChunk, int noOfEvents) {
if (getSiddhiDebugger() != null) {
getSiddhiDebugger().checkBreakPoint(getQueryName(), SiddhiDebugger.QueryTerminal.OUT, complexEventChunk.getFirst());
}
if (convertToStreamEvent) {
ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<StreamEvent>(complexEventChunk.isBatch());
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
StreamEvent borrowEvent = streamEventPool.borrowEvent();
streamEventConverter.convertData(complexEvent.getTimestamp(), complexEvent.getOutputData(), complexEvent.getType(), borrowEvent);
streamEventChunk.add(borrowEvent);
}
table.addEvents(streamEventChunk, noOfEvents);
} else {
table.addEvents((ComplexEventChunk<StreamEvent>) complexEventChunk, noOfEvents);
}
}
Aggregations