use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class InsertIntoWindowCallback method send.
/**
* Add the event into the {@link Window}
*
* @param complexEventChunk the event to add
* @param noOfEvents number of events
*/
@Override
public void send(ComplexEventChunk complexEventChunk, int noOfEvents) {
if (getSiddhiDebugger() != null) {
getSiddhiDebugger().checkBreakPoint(getQueryName(), SiddhiDebugger.QueryTerminal.OUT, complexEventChunk.getFirst());
}
// If events are inserted directly from another window, expired events can arrive
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
if (complexEvent.getType() == ComplexEvent.Type.EXPIRED) {
complexEvent.setType(ComplexEvent.Type.CURRENT);
}
}
window.add(complexEventChunk);
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class OutputCallback method constructMatchingStateEventChunk.
protected ComplexEventChunk<StateEvent> constructMatchingStateEventChunk(ComplexEventChunk matchingComplexEventChunk, boolean convertToStreamEvent, StateEventPool stateEventPool, int matchingStreamIndex, StreamEventPool streamEventPool, StreamEventConverter streamEventConverter) {
ComplexEventChunk<StateEvent> stateEventChunk = new ComplexEventChunk<StateEvent>(matchingComplexEventChunk.isBatch());
while (matchingComplexEventChunk.hasNext()) {
ComplexEvent matchingComplexEvent = matchingComplexEventChunk.next();
matchingComplexEventChunk.remove();
StateEvent stateEvent = stateEventPool.borrowEvent();
if (convertToStreamEvent) {
StreamEvent borrowEvent = streamEventPool.borrowEvent();
streamEventConverter.convertData(matchingComplexEvent.getTimestamp(), matchingComplexEvent.getOutputData(), matchingComplexEvent.getType() == ComplexEvent.Type.EXPIRED ? ComplexEvent.Type.CURRENT : matchingComplexEvent.getType(), borrowEvent);
stateEvent.addEvent(matchingStreamIndex, borrowEvent);
} else {
stateEvent.addEvent(matchingStreamIndex, (StreamEvent) matchingComplexEvent);
}
stateEventChunk.add(stateEvent);
}
return stateEventChunk;
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class QueryCallback method receiveStreamEvent.
public void receiveStreamEvent(ComplexEventChunk complexEventChunk) {
Event[] currentEvents = null;
Event[] expiredEvents = null;
long timestamp = -1;
List<Event> currentEventBuffer = new ArrayList<Event>();
List<Event> expiredEventBuffer = new ArrayList<Event>();
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent streamEvent = complexEventChunk.next();
if (streamEvent.getType() == StreamEvent.Type.EXPIRED) {
bufferEvent(streamEvent, expiredEventBuffer);
} else if (streamEvent.getType() == StreamEvent.Type.CURRENT) {
bufferEvent(streamEvent, currentEventBuffer);
}
timestamp = streamEvent.getTimestamp();
}
if (!currentEventBuffer.isEmpty()) {
currentEvents = currentEventBuffer.toArray(new Event[currentEventBuffer.size()]);
currentEventBuffer.clear();
}
if (!expiredEventBuffer.isEmpty()) {
expiredEvents = expiredEventBuffer.toArray(new Event[expiredEventBuffer.size()]);
expiredEventBuffer.clear();
}
send(timestamp, currentEvents, expiredEvents);
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class IndexEventHolder 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);
add(streamEvent);
}
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class AbstractRecordTable method find.
@Override
public StreamEvent find(CompiledCondition compiledCondition, StateEvent matchingEvent) throws ConnectionUnavailableException {
RecordStoreCompiledCondition recordStoreCompiledCondition = ((RecordStoreCompiledCondition) compiledCondition);
Map<String, Object> findConditionParameterMap = new HashMap<>();
for (Map.Entry<String, ExpressionExecutor> entry : recordStoreCompiledCondition.variableExpressionExecutorMap.entrySet()) {
findConditionParameterMap.put(entry.getKey(), entry.getValue().execute(matchingEvent));
}
Iterator<Object[]> records;
if (recordTableHandler != null) {
records = recordTableHandler.find(matchingEvent.getTimestamp(), findConditionParameterMap, recordStoreCompiledCondition.compiledCondition);
} else {
records = find(findConditionParameterMap, recordStoreCompiledCondition.compiledCondition);
}
ComplexEventChunk<StreamEvent> streamEventComplexEventChunk = new ComplexEventChunk<>(true);
if (records != null) {
while (records.hasNext()) {
Object[] record = records.next();
StreamEvent streamEvent = storeEventPool.borrowEvent();
System.arraycopy(record, 0, streamEvent.getOutputData(), 0, record.length);
streamEventComplexEventChunk.add(streamEvent);
}
}
return streamEventComplexEventChunk.getFirst();
}
Aggregations