use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class SnapshotOutputRateLimiter method sendToCallBacks.
protected void sendToCallBacks(List<ComplexEventChunk> outputEventChunks) {
if (!outputEventChunks.isEmpty()) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<>();
for (ComplexEventChunk eventChunk : outputEventChunks) {
outputEventChunk.addAll(eventChunk);
}
wrappedSnapshotOutputRateLimiter.passToCallBacks(outputEventChunk);
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class FirstGroupByPerTimeOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<>();
complexEventChunk.reset();
RateLimiterState state = stateHolder.getState();
try {
synchronized (state) {
long currentTime = siddhiQueryContext.getSiddhiAppContext().getTimestampGenerator().currentTime();
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
complexEventChunk.remove();
GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
Long outputTime = state.groupByOutputTime.get(groupedComplexEvent.getGroupKey());
if (outputTime == null || outputTime + value <= currentTime) {
state.groupByOutputTime.put(groupedComplexEvent.getGroupKey(), currentTime);
outputEventChunk.add(groupedComplexEvent);
}
}
}
} finally {
stateHolder.returnState(state);
}
outputEventChunk.reset();
if (outputEventChunk.hasNext()) {
sendToCallBacks(outputEventChunk);
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class FilterProcessor method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
Object result = conditionExecutor.execute(complexEvent);
if (result == null || !(Boolean) result) {
complexEventChunk.remove();
}
}
if (complexEventChunk.getFirst() != null) {
this.next.process(complexEventChunk);
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class QuerySelector method executePassThrough.
private ComplexEventChunk executePassThrough(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (((event.getType() != StreamEvent.Type.CURRENT || !currentOn) && (event.getType() != StreamEvent.Type.EXPIRED || !expiredOn))) {
complexEventChunk.remove();
}
}
}
complexEventChunk.reset();
if (complexEventChunk.hasNext()) {
return complexEventChunk;
}
return null;
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class QuerySelector method offsetEventChunk.
private void offsetEventChunk(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
int offsetCount = 0;
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == StreamEvent.Type.CURRENT || event.getType() == StreamEvent.Type.EXPIRED) {
if (offset > offsetCount) {
if ((event.getType() == StreamEvent.Type.CURRENT && currentOn) || (event.getType() == StreamEvent.Type.EXPIRED && expiredOn)) {
offsetCount++;
}
complexEventChunk.remove();
} else {
break;
}
}
}
}
Aggregations