use of org.wso2.siddhi.core.util.config.ConfigReader 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.util.config.ConfigReader in project siddhi by wso2.
the class TableWindowProcessor method cloneProcessor.
@Override
public Processor cloneProcessor(String key) {
try {
TableWindowProcessor streamProcessor = new TableWindowProcessor(table);
streamProcessor.inputDefinition = inputDefinition;
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
for (int i = 0; i < attributeExpressionLength; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
}
streamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
streamProcessor.attributeExpressionLength = attributeExpressionLength;
streamProcessor.additionalAttributes = additionalAttributes;
streamProcessor.complexEventPopulater = complexEventPopulater;
streamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
streamProcessor.start();
return streamProcessor;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
use of org.wso2.siddhi.core.util.config.ConfigReader in project siddhi by wso2.
the class WindowWindowProcessor method cloneProcessor.
@Override
public Processor cloneProcessor(String key) {
try {
WindowWindowProcessor streamProcessor = new WindowWindowProcessor(window);
streamProcessor.inputDefinition = inputDefinition;
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
for (int i = 0; i < attributeExpressionLength; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
}
streamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
streamProcessor.attributeExpressionLength = attributeExpressionLength;
streamProcessor.additionalAttributes = additionalAttributes;
streamProcessor.complexEventPopulater = complexEventPopulater;
streamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
streamProcessor.start();
return streamProcessor;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
use of org.wso2.siddhi.core.util.config.ConfigReader in project siddhi by wso2.
the class SinkMapper method init.
public final void init(StreamDefinition streamDefinition, String type, OptionHolder mapOptionHolder, List<Element> unmappedPayloadList, Sink sink, ConfigReader mapperConfigReader, LatencyTracker mapperLatencyTracker, SiddhiAppContext siddhiAppContext) {
this.mapperLatencyTracker = mapperLatencyTracker;
this.siddhiAppContext = siddhiAppContext;
sink.setTrpDynamicOptions(trpDynamicOptions);
this.sinkListener = sink;
this.optionHolder = mapOptionHolder;
this.type = type;
if (unmappedPayloadList != null && !unmappedPayloadList.isEmpty()) {
templateBuilderMap = new HashMap<>();
for (Element e : unmappedPayloadList) {
TemplateBuilder templateBuilder = new TemplateBuilder(streamDefinition, e.getValue());
if (templateBuilderMap.containsKey(e.getKey())) {
throw new SiddhiAppCreationException("Duplicate Keys, " + e.getKey() + ", in @payload() ");
}
templateBuilderMap.put(e.getKey(), templateBuilder);
}
}
init(streamDefinition, mapOptionHolder, templateBuilderMap, mapperConfigReader, siddhiAppContext);
}
Aggregations