use of org.wso2.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class SortWindowProcessor method init.
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.INT) {
lengthToKeep = Integer.parseInt(String.valueOf(((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue()));
} else {
throw new UnsupportedOperationException("The first parameter should be an integer");
}
parameterInfo = new ArrayList<Object[]>();
eventComparator = new EventComparator();
for (int i = 1, parametersLength = attributeExpressionExecutors.length; i < parametersLength; i++) {
if (!(attributeExpressionExecutors[i] instanceof VariableExpressionExecutor)) {
throw new UnsupportedOperationException("Required a variable, but found a string parameter");
} else {
ExpressionExecutor variableExpressionExecutor = attributeExpressionExecutors[i];
int order;
String nextParameter;
if (i + 1 < parametersLength && attributeExpressionExecutors[i + 1].getReturnType() == Attribute.Type.STRING) {
nextParameter = (String) ((ConstantExpressionExecutor) attributeExpressionExecutors[i + 1]).getValue();
if (nextParameter.equalsIgnoreCase(DESC)) {
order = -1;
i++;
} else if (nextParameter.equalsIgnoreCase(ASC)) {
order = 1;
i++;
} else {
throw new UnsupportedOperationException("Parameter string literals should only be \"asc\" or " + "\"desc\"");
}
} else {
// assigning the default order: "asc"
order = 1;
}
parameterInfo.add(new Object[] { variableExpressionExecutor, order });
}
}
}
use of org.wso2.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class InMemoryTable method compileUpdateSet.
@Override
public CompiledUpdateSet compileUpdateSet(UpdateSet updateSet, MatchingMetaInfoHolder matchingMetaInfoHolder, SiddhiAppContext siddhiAppContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, String queryName) {
Map<Integer, ExpressionExecutor> expressionExecutorMap = new HashMap<>();
for (UpdateSet.SetAttribute setAttribute : updateSet.getSetAttributeList()) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(setAttribute.getAssignmentExpression(), matchingMetaInfoHolder.getMetaStateEvent(), matchingMetaInfoHolder.getCurrentState(), tableMap, variableExpressionExecutors, siddhiAppContext, false, 0, queryName);
int attributePosition = tableDefinition.getAttributePosition(setAttribute.getTableVariable().getAttributeName());
expressionExecutorMap.put(attributePosition, expressionExecutor);
}
return new InMemoryCompiledUpdateSet(expressionExecutorMap);
}
use of org.wso2.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class AbstractRecordTable method compileUpdateSet.
public CompiledUpdateSet compileUpdateSet(UpdateSet updateSet, MatchingMetaInfoHolder matchingMetaInfoHolder, SiddhiAppContext siddhiAppContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, String queryName) {
RecordTableCompiledUpdateSet recordTableCompiledUpdateSet = new RecordTableCompiledUpdateSet();
Map<String, ExpressionExecutor> parentExecutorMap = new HashMap<>();
for (UpdateSet.SetAttribute setAttribute : updateSet.getSetAttributeList()) {
ExpressionBuilder expressionBuilder = new ExpressionBuilder(setAttribute.getAssignmentExpression(), matchingMetaInfoHolder, siddhiAppContext, variableExpressionExecutors, tableMap, queryName);
CompiledExpression compiledExpression = compileSetAttribute(expressionBuilder);
recordTableCompiledUpdateSet.put(setAttribute.getTableVariable().getAttributeName(), compiledExpression);
Map<String, ExpressionExecutor> expressionExecutorMap = expressionBuilder.getVariableExpressionExecutorMap();
parentExecutorMap.putAll(expressionExecutorMap);
}
recordTableCompiledUpdateSet.setExpressionExecutorMap(parentExecutorMap);
return recordTableCompiledUpdateSet;
}
use of org.wso2.siddhi.core.executor.VariableExpressionExecutor in project siddhi by wso2.
the class AbstractRecordTable method compileCondition.
@Override
public CompiledCondition compileCondition(Expression condition, MatchingMetaInfoHolder matchingMetaInfoHolder, SiddhiAppContext siddhiAppContext, List<VariableExpressionExecutor> variableExpressionExecutors, Map<String, Table> tableMap, String queryName) {
ExpressionBuilder expressionBuilder = new ExpressionBuilder(condition, matchingMetaInfoHolder, siddhiAppContext, variableExpressionExecutors, tableMap, queryName);
CompiledCondition compileCondition = compileCondition(expressionBuilder);
Map<String, ExpressionExecutor> expressionExecutorMap = expressionBuilder.getVariableExpressionExecutorMap();
return new RecordStoreCompiledCondition(expressionExecutorMap, compileCondition);
}
Aggregations