use of org.wso2.siddhi.core.executor.ExpressionExecutor in project siddhi by wso2.
the class IncrementalAggregationProcessor method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<>(complexEventChunk.isBatch());
try {
int noOfEvents = 0;
if (latencyTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
latencyTrackerInsert.markIn();
}
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
StreamEvent borrowedEvent = streamEventPool.borrowEvent();
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");
}
borrowedEvent.setOutputData(outputData, i);
}
streamEventChunk.add(borrowedEvent);
noOfEvents++;
}
incrementalExecutor.execute(streamEventChunk);
if (throughputTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
throughputTrackerInsert.eventsIn(noOfEvents);
}
} finally {
if (latencyTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
latencyTrackerInsert.markOut();
}
}
}
use of org.wso2.siddhi.core.executor.ExpressionExecutor in project siddhi by wso2.
the class IncrementalDataAggregator method process.
private void process(StreamEvent streamEvent, BaseIncrementalValueStore baseIncrementalValueStore) {
List<ExpressionExecutor> expressionExecutors = baseIncrementalValueStore.getExpressionExecutors();
for (int i = 0; i < expressionExecutors.size(); i++) {
// keeping timestamp value location as null
ExpressionExecutor expressionExecutor = expressionExecutors.get(i);
baseIncrementalValueStore.setValue(expressionExecutor.execute(streamEvent), i + 1);
}
baseIncrementalValueStore.setProcessed(true);
}
use of org.wso2.siddhi.core.executor.ExpressionExecutor in project siddhi by wso2.
the class IncrementalExecutor method cleanBaseIncrementalValueStore.
private void cleanBaseIncrementalValueStore(long startTimeOfNewAggregates, BaseIncrementalValueStore baseIncrementalValueStore) {
baseIncrementalValueStore.clearValues();
baseIncrementalValueStore.setTimestamp(startTimeOfNewAggregates);
baseIncrementalValueStore.setProcessed(false);
for (ExpressionExecutor expressionExecutor : baseIncrementalValueStore.getExpressionExecutors()) {
expressionExecutor.execute(resetEvent);
}
}
use of org.wso2.siddhi.core.executor.ExpressionExecutor in project siddhi by wso2.
the class IncrementalExecutor method process.
private void process(StreamEvent streamEvent, BaseIncrementalValueStore baseIncrementalValueStore) {
List<ExpressionExecutor> expressionExecutors = baseIncrementalValueStore.getExpressionExecutors();
for (int i = 0; i < expressionExecutors.size(); i++) {
// keeping timestamp value location as null
ExpressionExecutor expressionExecutor = expressionExecutors.get(i);
baseIncrementalValueStore.setValue(expressionExecutor.execute(streamEvent), i + 1);
}
baseIncrementalValueStore.setProcessed(true);
}
use of org.wso2.siddhi.core.executor.ExpressionExecutor in project siddhi by wso2.
the class AggregationParser method setTimeStampTimeZoneExecutors.
private static ExpressionExecutor[] setTimeStampTimeZoneExecutors(AggregationDefinition aggregationDefinition, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, List<VariableExpressionExecutor> variableExpressionExecutors, String aggregatorName, MetaStreamEvent metaStreamEvent) {
Expression timestampExpression = aggregationDefinition.getAggregateAttribute();
Expression timeZoneExpression;
ExpressionExecutor timestampExecutor;
ExpressionExecutor timeZoneExecutor;
boolean isSystemTimeBased = false;
// When execution is based on system time, the system's time zone would be used.
if (timestampExpression == null) {
isSystemTimeBased = true;
timestampExpression = AttributeFunction.function("currentTimeMillis", null);
}
timestampExecutor = ExpressionParser.parseExpression(timestampExpression, metaStreamEvent, 0, tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, aggregatorName);
if (timestampExecutor.getReturnType() == Attribute.Type.STRING) {
Expression expression = AttributeFunction.function("incrementalAggregator", "timestampInMilliseconds", timestampExpression);
timestampExecutor = ExpressionParser.parseExpression(expression, metaStreamEvent, 0, tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, aggregatorName);
timeZoneExpression = AttributeFunction.function("incrementalAggregator", "getTimeZone", timestampExpression);
timeZoneExecutor = ExpressionParser.parseExpression(timeZoneExpression, metaStreamEvent, 0, tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, aggregatorName);
} else if (timestampExecutor.getReturnType() == Attribute.Type.LONG) {
if (isSystemTimeBased) {
timeZoneExpression = AttributeFunction.function("incrementalAggregator", "getTimeZone", null);
timeZoneExecutor = ExpressionParser.parseExpression(timeZoneExpression, metaStreamEvent, 0, tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, aggregatorName);
} else {
// If long value is given, it's assumed that the
timeZoneExpression = Expression.value("+00:00");
// time zone is GMT
timeZoneExecutor = ExpressionParser.parseExpression(timeZoneExpression, metaStreamEvent, 0, tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, aggregatorName);
}
} else {
throw new SiddhiAppCreationException("AggregationDefinition '" + aggregationDefinition.getId() + "'s aggregateAttribute expects " + "long or string, but found " + timestampExecutor.getReturnType() + ". " + "Hence, can't create the siddhi app '" + siddhiAppContext.getName() + "'", timestampExpression.getQueryContextStartIndex(), timestampExpression.getQueryContextEndIndex());
}
return new ExpressionExecutor[] { timestampExecutor, timeZoneExecutor };
}
Aggregations