Java Code Examples for io.siddhi.query.api.definition.AbstractDefinition#getAttributeList()

The following examples show how to use io.siddhi.query.api.definition.AbstractDefinition#getAttributeList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpressionWindowProcessor.java    From siddhi with Apache License 2.0 6 votes vote down vote up
@Override
protected StateFactory init(MetaStreamEvent metaStreamEvent,
                            AbstractDefinition inputDefinition,
                            ExpressionExecutor[] attributeExpressionExecutors,
                            ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder,
                            boolean outputExpectsExpiredEvents, boolean findToBeExecuted,
                            SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
        expressionString = (String) ((ConstantExpressionExecutor)
                attributeExpressionExecutors[0]).getValue();
        constructExpression(metaStreamEvent, siddhiQueryContext);
    } else {
        for (Attribute attribute : inputDefinition.getAttributeList()) {
            metaStreamEvent.addData(attribute);
        }
        expressionStringExecutor = attributeExpressionExecutors[0];
    }
    return () -> new WindowState();
}
 
Example 2
Source File: SiddhiTypeFactory.java    From flink-siddhi with Apache License 2.0 5 votes vote down vote up
public static <T extends Tuple> TypeInformation<T> getTupleTypeInformation(AbstractDefinition definition) {
    List<TypeInformation> types = new ArrayList<>();
    for (Attribute attribute : definition.getAttributeList()) {
        types.add(TypeInformation.of(getJavaType(attribute.getType())));
    }
    try {
        return Types.TUPLE(types.toArray(new TypeInformation[0]));
    } catch (IllegalArgumentException ex) {
        throw new IllegalArgumentException("Unable to parse ", ex);
    }
}
 
Example 3
Source File: SiddhiDefinitionAdapter.java    From eagle with Apache License 2.0 5 votes vote down vote up
public static StreamDefinition convertFromSiddiDefinition(AbstractDefinition siddhiDefinition) {
    StreamDefinition streamDefinition = new StreamDefinition();
    streamDefinition.setStreamId(siddhiDefinition.getId());
    List<StreamColumn> columns = new ArrayList<>(siddhiDefinition.getAttributeNameArray().length);
    for (Attribute attribute : siddhiDefinition.getAttributeList()) {
        StreamColumn column = new StreamColumn();
        column.setType(convertFromSiddhiAttributeType(attribute.getType()));
        column.setName(attribute.getName());
        columns.add(column);
    }
    streamDefinition.setColumns(columns);
    streamDefinition.setTimeseries(true);
    streamDefinition.setDescription("Auto-generated stream schema from siddhi for " + siddhiDefinition.getId());
    return streamDefinition;
}
 
Example 4
Source File: ExpressionBatchWindowProcessor.java    From siddhi with Apache License 2.0 5 votes vote down vote up
@Override
protected StateFactory init(MetaStreamEvent metaStreamEvent,
                            AbstractDefinition inputDefinition,
                            ExpressionExecutor[] attributeExpressionExecutors,
                            ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder,
                            boolean outputExpectsExpiredEvents, boolean findToBeExecuted,
                            SiddhiQueryContext siddhiQueryContext) {
    if (attributeExpressionExecutors[0] instanceof ConstantExpressionExecutor) {
        expressionString = (String) ((ConstantExpressionExecutor)
                attributeExpressionExecutors[0]).getValue();
        constructExpression(metaStreamEvent, siddhiQueryContext);
    } else {
        for (Attribute attribute : inputDefinition.getAttributeList()) {
            metaStreamEvent.addData(attribute);
        }
        expressionStringExecutor = attributeExpressionExecutors[0];
    }
    if (attributeExpressionExecutors.length > 1) {
        if (attributeExpressionExecutors[1] instanceof ConstantExpressionExecutor) {
            includeTriggeringEvent = (Boolean) ((ConstantExpressionExecutor)
                    attributeExpressionExecutors[1]).getValue();
        } else {
            includeTriggeringEventExecutor = attributeExpressionExecutors[1];
        }
        if (attributeExpressionExecutors.length > 2 &&
                attributeExpressionExecutors[2] instanceof ConstantExpressionExecutor) {
            streamInputEvents = (Boolean) ((ConstantExpressionExecutor)
                    attributeExpressionExecutors[2]).getValue();
        }
    }
    return () -> new WindowState();
}