use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.
the class AggregationParser method createRestEvent.
public static StreamEvent createRestEvent(MetaStreamEvent metaStreamEvent, StreamEvent streamEvent) {
streamEvent.setTimestamp(0);
streamEvent.setType(ComplexEvent.Type.RESET);
List<Attribute> outputData = metaStreamEvent.getOutputData();
for (int i = 0, outputDataSize = outputData.size(); i < outputDataSize; i++) {
Attribute attribute = outputData.get(i);
switch(attribute.getType()) {
case STRING:
streamEvent.setOutputData("", i);
break;
case INT:
streamEvent.setOutputData(0, i);
break;
case LONG:
streamEvent.setOutputData(0L, i);
break;
case FLOAT:
streamEvent.setOutputData(0f, i);
break;
case DOUBLE:
streamEvent.setOutputData(0.0, i);
break;
case BOOL:
streamEvent.setOutputData(false, i);
break;
case OBJECT:
streamEvent.setOutputData(null, i);
break;
}
}
return streamEvent;
}
use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.
the class AggregationParser method generateCUDMetaStreamEvent.
private static MetaStreamEvent generateCUDMetaStreamEvent(boolean isProcessingOnExternalTime) {
MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
Map<Attribute, int[]> cudInputStreamAttributesList = generateCUDInputStreamAttributes(isProcessingOnExternalTime);
StreamDefinition inputDefinition = new StreamDefinition();
for (Attribute attribute : cudInputStreamAttributesList.keySet()) {
metaStreamEvent.addData(attribute);
inputDefinition.attribute(attribute.getName(), attribute.getType());
}
metaStreamEvent.addInputDefinition(inputDefinition);
metaStreamEvent.setEventType(MetaStreamEvent.EventType.DEFAULT);
return metaStreamEvent;
}
use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.
the class AggregationParser method generateCUDInputStreamAttributes.
private static Map<Attribute, int[]> generateCUDInputStreamAttributes(boolean isProcessingOnExternalTime) {
Map<Attribute, int[]> cudInputStreamAttributeList = new LinkedHashMap<>();
if (isProcessingOnExternalTime) {
cudInputStreamAttributeList.put(new Attribute(FROM_TIMESTAMP, Attribute.Type.LONG), new int[] { 0, 1, 3 });
cudInputStreamAttributeList.put(new Attribute(TO_TIMESTAMP, Attribute.Type.LONG), new int[] { 2, 4 });
} else {
cudInputStreamAttributeList.put(new Attribute(FROM_TIMESTAMP, Attribute.Type.LONG), new int[] { 0, 1 });
cudInputStreamAttributeList.put(new Attribute(TO_TIMESTAMP, Attribute.Type.LONG), new int[] { 2 });
}
return cudInputStreamAttributeList;
}
use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.
the class AggregationParser method processAggregationSelectors.
private static void processAggregationSelectors(AggregationDefinition aggregationDefinition, SiddhiQueryContext siddhiQueryContext, Map<String, Table> tableMap, List<VariableExpressionExecutor> incomingVariableExpressionExecutors, MetaStreamEvent incomingMetaStreamEvent, List<ExpressionExecutor> incomingExpressionExecutors, List<Expression> outputExpressions, OutputAttribute outputAttribute, Expression expression) {
ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(expression, incomingMetaStreamEvent, 0, tableMap, incomingVariableExpressionExecutors, false, 0, ProcessingMode.BATCH, false, siddhiQueryContext);
incomingExpressionExecutors.add(expressionExecutor);
incomingMetaStreamEvent.addOutputData(new Attribute(outputAttribute.getRename(), expressionExecutor.getReturnType()));
aggregationDefinition.getAttributeList().add(new Attribute(outputAttribute.getRename(), expressionExecutor.getReturnType()));
outputExpressions.add(Expression.variable(outputAttribute.getRename()));
}
use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.
the class AggregationParser method validateBaseAggregators.
private static void validateBaseAggregators(List<IncrementalAttributeAggregator> incrementalAttributeAggregators, IncrementalAttributeAggregator incrementalAttributeAggregator, Attribute[] baseAttributes, Expression[] baseAttributeInitialValues, Expression[] baseAggregators, int i) {
for (int i1 = i; i1 < incrementalAttributeAggregators.size(); i1++) {
IncrementalAttributeAggregator otherAttributeAggregator = incrementalAttributeAggregators.get(i1);
if (otherAttributeAggregator != incrementalAttributeAggregator) {
Attribute[] otherBaseAttributes = otherAttributeAggregator.getBaseAttributes();
Expression[] otherBaseAttributeInitialValues = otherAttributeAggregator.getBaseAttributeInitialValues();
Expression[] otherBaseAggregators = otherAttributeAggregator.getBaseAggregators();
for (int j = 0; j < otherBaseAttributes.length; j++) {
if (baseAttributes[i].equals(otherBaseAttributes[j])) {
if (!baseAttributeInitialValues[i].equals(otherBaseAttributeInitialValues[j])) {
throw new SiddhiAppCreationException("BaseAttributes having same name should " + "be defined with same initial values, but baseAttribute '" + baseAttributes[i] + "' is defined in '" + incrementalAttributeAggregator.getClass().getName() + "' and '" + otherAttributeAggregator.getClass().getName() + "' with different initial values.");
}
if (!baseAggregators[i].equals(otherBaseAggregators[j])) {
throw new SiddhiAppCreationException("BaseAttributes having same name should " + "be defined with same baseAggregators, but baseAttribute '" + baseAttributes[i] + "' is defined in '" + incrementalAttributeAggregator.getClass().getName() + "' and '" + otherAttributeAggregator.getClass().getName() + "' with different baseAggregators.");
}
}
}
}
}
}
Aggregations