use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class ListEventHolder method add.
@Override
public void add(ComplexEventChunk<StreamEvent> addingEventChunk) {
addingEventChunk.reset();
while (addingEventChunk.hasNext()) {
size++;
ComplexEvent complexEvent = addingEventChunk.next();
StreamEvent streamEvent = tableStreamEventFactory.newInstance();
eventConverter.convertComplexEvent(complexEvent, streamEvent);
this.add(streamEvent);
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class OnDemandQueryRuntimeUtil method executeSelectorAndReturnStreamEvent.
public static StreamEvent executeSelectorAndReturnStreamEvent(StateEventFactory stateEventFactory, StreamEvent streamEvent, StreamEvent storeEvents, int storeEventIndex, QuerySelector selector) {
ComplexEventChunk outputComplexEventChunk = executeSelectorAndReturnChunk(stateEventFactory, streamEvent, storeEvents, storeEventIndex, selector);
if (outputComplexEventChunk != null) {
outputComplexEventChunk.reset();
ComplexEvent firstComplexEvent = outputComplexEventChunk.next();
StreamEvent firstEvent = new StreamEvent(0, 0, firstComplexEvent.getOutputData().length);
firstEvent.setOutputData(firstComplexEvent.getOutputData());
StreamEvent eventPointer = firstEvent;
while (outputComplexEventChunk.hasNext()) {
ComplexEvent complexEvent = outputComplexEventChunk.next();
StreamEvent resultEvent = new StreamEvent(0, 0, complexEvent.getOutputData().length);
resultEvent.setOutputData(complexEvent.getOutputData());
eventPointer.setNext(resultEvent);
eventPointer = resultEvent;
}
return firstEvent;
} else {
return null;
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class PersistedAggregationResultsProcessor method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
if (complexEventChunk != null) {
ComplexEvent complexEvent = complexEventChunk.getFirst();
Object[] outputData = complexEvent.getOutputData();
if (outputData.length == 3) {
Date fromTime = new Date((Long) outputData[0]);
Date toTime = new Date((Long) outputData[1]);
log.debug("Aggregation executed for duration " + duration + " from " + fromTime + " to " + toTime + " and " + outputData[2] + " records has been successfully updated ");
}
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class QuerySelector method processInBatchNoGroupBy.
private ComplexEventChunk processInBatchNoGroupBy(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
ComplexEvent lastEvent = null;
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
switch(event.getType()) {
case CURRENT:
case EXPIRED:
eventPopulator.populateStateEvent(event);
for (AttributeProcessor attributeProcessor : attributeProcessorList) {
attributeProcessor.process(event);
}
if (!(havingConditionExecutor != null && !havingConditionExecutor.execute(event))) {
if ((event.getType() == StreamEvent.Type.CURRENT && currentOn) || (event.getType() == StreamEvent.Type.EXPIRED && expiredOn)) {
complexEventChunk.remove();
lastEvent = event;
}
}
break;
case TIMER:
break;
case RESET:
for (AttributeProcessor attributeProcessor : attributeProcessorList) {
attributeProcessor.process(event);
}
break;
}
}
}
if (lastEvent != null) {
complexEventChunk.clear();
if ((offset == SiddhiConstants.UNKNOWN_STATE || offset == 0) && (limit == SiddhiConstants.UNKNOWN_STATE || limit > 0)) {
complexEventChunk.add(lastEvent);
}
return complexEventChunk;
}
return null;
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class QuerySelector method limitEventChunk.
private void limitEventChunk(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
int limitCount = 0;
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == StreamEvent.Type.CURRENT || event.getType() == StreamEvent.Type.EXPIRED) {
if ((limit > limitCount) && (event.getType() == StreamEvent.Type.CURRENT && currentOn) || (event.getType() == StreamEvent.Type.EXPIRED && expiredOn)) {
limitCount++;
} else {
complexEventChunk.remove();
}
}
}
}
Aggregations