use of io.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class AbstractQueryableRecordTable method compileCondition.
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
ExpressionExecutor inMemoryCompiledCondition = ExpressionParser.parseExpression(condition, matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
ExpressionBuilder expressionBuilder = new ExpressionBuilder(condition, matchingMetaInfoHolder, variableExpressionExecutors, tableMap, new UpdateOrInsertReducer(inMemoryCompiledCondition, matchingMetaInfoHolder), null, siddhiQueryContext);
CompiledCondition compileCondition = compileCondition(expressionBuilder);
Map<String, ExpressionExecutor> expressionExecutorMap = expressionBuilder.getVariableExpressionExecutorMap();
if (cacheEnabled) {
CompiledCondition compiledConditionWithCache = new CompiledConditionWithCache(compileCondition, ((CacheTable) cacheTable).generateCacheCompileCondition(condition, matchingMetaInfoHolder, siddhiQueryContext, variableExpressionExecutors), siddhiQueryContext);
return new RecordStoreCompiledCondition(expressionExecutorMap, compiledConditionWithCache, siddhiQueryContext);
} else {
return new RecordStoreCompiledCondition(expressionExecutorMap, compileCondition, siddhiQueryContext);
}
}
use of io.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class AbstractQueryableRecordTable method generateCSForSelectAll.
private CompiledSelection generateCSForSelectAll() {
MetaStreamEvent metaStreamEventForSelectAll = new MetaStreamEvent();
for (Attribute attribute : tableDefinition.getAttributeList()) {
metaStreamEventForSelectAll.addOutputData(attribute);
}
metaStreamEventForSelectAll.addInputDefinition(tableDefinition);
MetaStateEvent metaStateEventForSelectAll = new MetaStateEvent(1);
metaStateEventForSelectAll.addEvent(metaStreamEventForSelectAll);
MatchingMetaInfoHolder matchingMetaInfoHolderForSlectAll = new MatchingMetaInfoHolder(metaStateEventForSelectAll, -1, 0, tableDefinition, tableDefinition, 0);
List<OutputAttribute> outputAttributesAll = new ArrayList<>();
List<Attribute> attributeList = tableDefinition.getAttributeList();
for (Attribute attribute : attributeList) {
outputAttributesAll.add(new OutputAttribute(new Variable(attribute.getName())));
}
List<SelectAttributeBuilder> selectAttributeBuilders = new ArrayList<>(outputAttributesAll.size());
List<VariableExpressionExecutor> variableExpressionExecutors = new ArrayList<>();
for (OutputAttribute outputAttribute : outputAttributesAll) {
ExpressionBuilder expressionBuilder = new ExpressionBuilder(outputAttribute.getExpression(), matchingMetaInfoHolderForSlectAll, variableExpressionExecutors, tableMap, null, null, null);
selectAttributeBuilders.add(new SelectAttributeBuilder(expressionBuilder, outputAttribute.getRename()));
}
return compileSelection(selectAttributeBuilders, null, null, null, null, null);
}
use of io.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class InMemoryTable method compileUpdateSet.
@Override
public CompiledUpdateSet compileUpdateSet(UpdateSet updateSet, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
Map<Integer, ExpressionExecutor> expressionExecutorMap = new HashMap<>();
for (UpdateSet.SetAttribute setAttribute : updateSet.getSetAttributeList()) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(setAttribute.getAssignmentExpression(), matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
int attributePosition = tableDefinition.getAttributePosition(setAttribute.getTableVariable().getAttributeName());
expressionExecutorMap.put(attributePosition, expressionExecutor);
}
return new InMemoryCompiledUpdateSet(expressionExecutorMap);
}
use of io.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class AbstractRecordTable method compileCondition.
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, SiddhiQueryContext siddhiQueryContext) {
ExpressionExecutor inMemoryCompiledCondition = ExpressionParser.parseExpression(condition, matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
ExpressionBuilder expressionBuilder = new ExpressionBuilder(condition, matchingMetaInfoHolder, variableExpressionExecutors, tableMap, new UpdateOrInsertReducer(inMemoryCompiledCondition, matchingMetaInfoHolder), null, siddhiQueryContext);
CompiledCondition compileCondition = compileCondition(expressionBuilder);
Map<String, ExpressionExecutor> expressionExecutorMap = expressionBuilder.getVariableExpressionExecutorMap();
return new RecordStoreCompiledCondition(expressionExecutorMap, compileCondition, siddhiQueryContext);
}
use of io.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class CacheExpirer method generateExpiryCompiledCondition.
private CompiledCondition generateExpiryCompiledCondition() {
MetaStreamEvent tableMetaStreamEvent = new MetaStreamEvent();
tableMetaStreamEvent.setEventType(MetaStreamEvent.EventType.TABLE);
TableDefinition matchingTableDefinition = TableDefinition.id(cacheTable.getTableDefinition().getId());
for (Attribute attribute : cacheTable.getTableDefinition().getAttributeList()) {
tableMetaStreamEvent.addOutputData(attribute);
matchingTableDefinition.attribute(attribute.getName(), attribute.getType());
}
tableMetaStreamEvent.addInputDefinition(matchingTableDefinition);
streamEventFactory = new StreamEventFactory(tableMetaStreamEvent);
Variable rightExpressionForSubtract = new Variable(CACHE_TABLE_TIMESTAMP_ADDED);
rightExpressionForSubtract.setStreamId(cacheTable.getTableDefinition().getId());
Expression rightExpressionForCompare = new LongConstant(retentionPeriod);
Compare.Operator greaterThanOperator = Compare.Operator.GREATER_THAN;
MetaStreamEvent currentTimeMetaStreamEvent = new MetaStreamEvent();
currentTimeMetaStreamEvent.setEventType(MetaStreamEvent.EventType.TABLE);
Attribute currentTimeAttribute = new Attribute(CACHE_EXPIRE_CURRENT_TIME, Attribute.Type.LONG);
currentTimeMetaStreamEvent.addOutputData(currentTimeAttribute);
TableDefinition currentTimeTableDefinition = TableDefinition.id("");
currentTimeTableDefinition.attribute(CACHE_EXPIRE_CURRENT_TIME, Attribute.Type.LONG);
currentTimeMetaStreamEvent.addInputDefinition(currentTimeTableDefinition);
MetaStateEvent metaStateEvent = new MetaStateEvent(2);
metaStateEvent.addEvent(currentTimeMetaStreamEvent);
metaStateEvent.addEvent(tableMetaStreamEvent);
MatchingMetaInfoHolder matchingMetaInfoHolder = MatcherParser.constructMatchingMetaStateHolder(metaStateEvent, 0, cacheTable.getTableDefinition(), 0);
List<VariableExpressionExecutor> variableExpressionExecutors = new ArrayList<>();
Expression leftExpressionForSubtract = new Variable(CACHE_EXPIRE_CURRENT_TIME);
Expression leftExpressionForCompare = new Subtract(leftExpressionForSubtract, rightExpressionForSubtract);
Expression deleteCondition = new Compare(leftExpressionForCompare, greaterThanOperator, rightExpressionForCompare);
SiddhiQueryContext siddhiQueryContext = new SiddhiQueryContext(siddhiAppContext, "expiryDeleteQuery");
return cacheTable.compileCondition(deleteCondition, matchingMetaInfoHolder, variableExpressionExecutors, tableMap, siddhiQueryContext);
}
Aggregations