use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class TimeLengthWindowProcessor method init.
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
this.siddhiAppContext = siddhiAppContext;
expiredEventChunk = new ComplexEventChunk<StreamEvent>(false);
if (attributeExpressionExecutors.length == 2) {
length = (Integer) ((ConstantExpressionExecutor) attributeExpressionExecutors[1]).getValue();
if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.INT) {
timeInMilliSeconds = (Integer) ((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue();
} else if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.LONG) {
timeInMilliSeconds = (Long) ((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue();
} else {
throw new SiddhiAppValidationException("TimeLength window's first parameter attribute should " + "be either int or long, but found " + attributeExpressionExecutors[0].getReturnType());
}
} else {
throw new SiddhiAppValidationException("TimeLength window should have constant parameter " + "attributes but found a dynamic attribute " + attributeExpressionExecutors[0].getClass().getCanonicalName());
}
} else {
throw new SiddhiAppValidationException("TimeLength window should only have two parameters (<int> " + "windowTime,<int> windowLength), but found " + attributeExpressionExecutors.length + " input " + "attributes");
}
}
use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class TimeWindowProcessor method init.
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, boolean outputExpectsExpiredEvents, SiddhiAppContext siddhiAppContext) {
this.siddhiAppContext = siddhiAppContext;
this.expiredEventChunk = new ComplexEventChunk<StreamEvent>(false);
if (attributeExpressionExecutors.length == 1) {
if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.INT) {
timeInMilliSeconds = (Integer) ((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue();
} else if (attributeExpressionExecutors[0].getReturnType() == Attribute.Type.LONG) {
timeInMilliSeconds = (Long) ((ConstantExpressionExecutor) attributeExpressionExecutors[0]).getValue();
} else {
throw new SiddhiAppValidationException("Time window's parameter attribute should be either " + "int or long, but found " + attributeExpressionExecutors[0].getReturnType());
}
} else {
throw new SiddhiAppValidationException("Time window should have constant parameter attribute but " + "found a dynamic attribute " + attributeExpressionExecutors[0].getClass().getCanonicalName());
}
} else {
throw new SiddhiAppValidationException("Time window should only have one parameter (<int|long|time> " + "windowTime), but found " + attributeExpressionExecutors.length + " input attributes");
}
}
use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class QuerySelector method clone.
public QuerySelector clone(String key) {
QuerySelector clonedQuerySelector = new QuerySelector(id + key, selector, currentOn, expiredOn, siddhiAppContext);
List<AttributeProcessor> clonedAttributeProcessorList = new ArrayList<AttributeProcessor>();
for (AttributeProcessor attributeProcessor : attributeProcessorList) {
clonedAttributeProcessorList.add(attributeProcessor.cloneProcessor(key));
}
clonedQuerySelector.attributeProcessorList = clonedAttributeProcessorList;
clonedQuerySelector.isGroupBy = isGroupBy;
clonedQuerySelector.containsAggregator = containsAggregator;
clonedQuerySelector.groupByKeyGenerator = groupByKeyGenerator;
clonedQuerySelector.havingConditionExecutor = havingConditionExecutor;
clonedQuerySelector.eventPopulator = eventPopulator;
clonedQuerySelector.batchingEnabled = batchingEnabled;
clonedQuerySelector.isOrderBy = isOrderBy;
clonedQuerySelector.orderByEventComparator = orderByEventComparator;
clonedQuerySelector.limit = limit;
return clonedQuerySelector;
}
use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class AttributeAggregator method cloneAggregator.
public AttributeAggregator cloneAggregator(String key) {
try {
AttributeAggregator attributeAggregator = this.getClass().newInstance();
ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeSize];
for (int i = 0; i < attributeSize; i++) {
innerExpressionExecutors[i] = attributeExpressionExecutors[i].cloneExecutor(key);
}
attributeAggregator.elementId = elementId + "-" + key;
attributeAggregator.initAggregator(innerExpressionExecutors, siddhiAppContext, configReader);
return attributeAggregator;
} catch (Exception e) {
throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
}
}
use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class AttributeAggregator method initAggregator.
public void initAggregator(ExpressionExecutor[] attributeExpressionExecutors, SiddhiAppContext siddhiAppContext, ConfigReader configReader) {
this.configReader = configReader;
try {
this.siddhiAppContext = siddhiAppContext;
this.attributeExpressionExecutors = attributeExpressionExecutors;
this.attributeSize = attributeExpressionExecutors.length;
if (elementId == null) {
elementId = "AttributeAggregator-" + siddhiAppContext.getElementIdGenerator().createNewId();
}
// Not added to Snapshotable as the AggregationAttributeExecutors are added
// siddhiAppContext.getSnapshotService().addSnapshotable(this);
init(attributeExpressionExecutors, configReader, siddhiAppContext);
} catch (Throwable t) {
throw new SiddhiAppCreationException(t);
}
}
Aggregations