use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class IncrementalAggregationProcessor method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<>();
try {
int noOfEvents = 0;
if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
latencyTrackerInsert.markIn();
}
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
if (!isFirstEventArrived) {
aggregationRuntime.initialiseExecutors(true);
isFirstEventArrived = true;
}
StreamEvent newEvent = streamEventFactory.newInstance();
for (int i = 0; i < incomingExpressionExecutors.size(); i++) {
ExpressionExecutor expressionExecutor = incomingExpressionExecutors.get(i);
Object outputData = expressionExecutor.execute(complexEvent);
if (expressionExecutor instanceof IncrementalUnixTimeFunctionExecutor && outputData == null) {
throw new SiddhiAppRuntimeException("Cannot retrieve the timestamp of event");
}
newEvent.setOutputData(outputData, i);
}
streamEventChunk.add(newEvent);
noOfEvents++;
}
aggregationRuntime.processEvents(streamEventChunk);
if (throughputTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
throughputTrackerInsert.eventsIn(noOfEvents);
}
} finally {
if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
latencyTrackerInsert.markOut();
}
}
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class IncrementalDataPurger method createStreamEvent.
/**
* creating stream event method
*/
private StateEvent createStreamEvent(Object[] values, Long timestamp) {
StreamEvent streamEvent = streamEventFactory.newInstance();
streamEvent.setTimestamp(timestamp);
streamEvent.setOutputData(values);
StateEvent stateEvent = new StateEvent(2, 1);
stateEvent.addEvent(0, streamEvent);
return stateEvent;
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class ErrorHandlerUtils method constructAddErrorRecordString.
public static String constructAddErrorRecordString(ComplexEventChunk<StreamEvent> eventChunk, boolean isObjectColumnPresent, TableDefinition tableDefinition, Exception e) {
JsonObject payloadJson = new JsonObject();
payloadJson.addProperty("isEditable", !(isObjectColumnPresent || e instanceof ConnectionUnavailableException));
JsonArray attributes = new JsonArray();
JsonArray records = new JsonArray();
for (Attribute attribute : tableDefinition.getAttributeList()) {
JsonObject attributeJson = new JsonObject();
attributeJson.add("name", new JsonPrimitive(attribute.getName()));
attributeJson.add("type", new JsonPrimitive(String.valueOf(attribute.getType())));
attributes.add(attributeJson);
}
payloadJson.add("attributes", attributes);
while (eventChunk.hasNext()) {
StreamEvent streamEvent = eventChunk.next();
JsonArray record = new JsonArray();
for (Object item : streamEvent.getOutputData()) {
if (item == null) {
record.add(JsonNull.INSTANCE);
} else {
record.add(String.valueOf(item));
}
}
records.add(record);
}
payloadJson.add("records", records);
return payloadJson.toString();
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class SnapshotableEventQueueOperator method delete.
@Override
public void delete(ComplexEventChunk<StateEvent> deletingEventChunk, Object storeEvents) {
SnapshotableStreamEventQueue storeEventQueue = (SnapshotableStreamEventQueue) storeEvents;
deletingEventChunk.reset();
while (deletingEventChunk.hasNext()) {
StateEvent deletingEvent = deletingEventChunk.next();
try {
storeEventQueue.reset();
while (storeEventQueue.hasNext()) {
StreamEvent storeEvent = storeEventQueue.next();
deletingEvent.setEvent(storeEventPosition, storeEvent);
if ((Boolean) expressionExecutor.execute(deletingEvent)) {
storeEventQueue.remove();
}
}
} finally {
deletingEvent.setEvent(storeEventPosition, null);
}
}
}
use of io.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class TestStoreContainingInMemoryTable method query.
@Override
protected RecordIterator<Object[]> query(Map<String, Object> parameterMap, CompiledCondition compiledCondition, CompiledSelection compiledSelection, Attribute[] outputAttributes) {
StreamEvent outEvent = inMemoryTable.find(compiledCondition, findMatchingEvent);
List<Object[]> objects = new LinkedList<>();
CompiledSelectionWithCache compiledSelectionWithCache = null;
if (outEvent != null) {
compiledSelectionWithCache = (CompiledSelectionWithCache) compiledSelection;
StateEventFactory stateEventFactory = new StateEventFactory(compiledSelectionWithCache.getMetaStateEvent());
Event[] cacheResultsAfterSelection = executeSelector(stateEventFactory, null, outEvent, compiledSelectionWithCache.getStoreEventIndex(), compiledSelectionWithCache.getQuerySelector());
if (compiledSelectionWithCache.getQuerySelector() != null & compiledSelectionWithCache.getQuerySelector().getAttributeProcessorList().size() != 0) {
compiledSelectionWithCache.getQuerySelector().process(generateResetComplexEventChunk(outEvent.getOutputData().length, stateEventFactory));
}
if (cacheResultsAfterSelection != null) {
for (Event event : cacheResultsAfterSelection) {
objects.add(event.getData());
}
}
}
return new TestStoreWithCacheIterator(objects.iterator());
}
Aggregations