Search in sources :

Example 1 with Attribute

use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.

the class MetaStreamEvent method clone.

public MetaStreamEvent clone() {
    MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
    if (outputData != null) {
        for (Attribute attribute : outputData) {
            metaStreamEvent.addOutputData(attribute);
        }
    }
    if (this.onAfterWindowData != null) {
        metaStreamEvent.onAfterWindowData = new ArrayList<>(onAfterWindowData);
    }
    metaStreamEvent.beforeWindowData = new ArrayList<>(beforeWindowData);
    for (AbstractDefinition abstractDefinition : this.getInputDefinitions()) {
        metaStreamEvent.addInputDefinition(abstractDefinition);
    }
    metaStreamEvent.setInputReferenceId(this.getInputReferenceId());
    metaStreamEvent.setOutputDefinition(this.getOutputStreamDefinition());
    metaStreamEvent.setEventType(this.getEventType());
    metaStreamEvent.setMultiValue(this.isMultiValue());
    return metaStreamEvent;
}
Also used : Attribute(io.siddhi.query.api.definition.Attribute) AbstractDefinition(io.siddhi.query.api.definition.AbstractDefinition)

Example 2 with Attribute

use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.

the class StreamEventPopulaterFactory method constructEventPopulator.

/**
 * Constructs StreamEventPopulater according to MetaStateEvent and to be mapped attributes
 *
 * @param metaStreamEvent       info for populating the StreamEvent
 * @param streamEventChainIndex StreamEvent chain index
 * @param attributes            mapped attributes
 * @return StateEventPopulater
 */
public static SelectiveComplexEventPopulater constructEventPopulator(MetaStreamEvent metaStreamEvent, int streamEventChainIndex, List<Attribute> attributes) {
    List<StreamMappingElement> streamMappingElements = new ArrayList<StreamMappingElement>();
    for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) {
        Attribute attribute = attributes.get(i);
        StreamMappingElement streamMappingElement = new StreamMappingElement();
        streamMappingElement.setFromPosition(i);
        int index = metaStreamEvent.getOutputData().indexOf(attribute);
        if (index > -1) {
            streamMappingElement.setToPosition(new int[] { streamEventChainIndex, 0, OUTPUT_DATA_INDEX, index });
        } else {
            index = metaStreamEvent.getOnAfterWindowData().indexOf(attribute);
            if (index > -1) {
                streamMappingElement.setToPosition(new int[] { streamEventChainIndex, 0, ON_AFTER_WINDOW_DATA_INDEX, index });
            } else {
                index = metaStreamEvent.getBeforeWindowData().indexOf(attribute);
                if (index > -1) {
                    streamMappingElement.setToPosition(new int[] { streamEventChainIndex, 0, BEFORE_WINDOW_DATA_INDEX, index });
                } else {
                    streamMappingElement.setToPosition(null);
                }
            }
        }
        streamMappingElements.add(streamMappingElement);
    }
    return new SelectiveComplexEventPopulater(streamMappingElements);
}
Also used : Attribute(io.siddhi.query.api.definition.Attribute) ArrayList(java.util.ArrayList)

Example 3 with Attribute

use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.

the class ExpressionBatchWindowProcessor method init.

@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();
}
Also used : Attribute(io.siddhi.query.api.definition.Attribute) ConstantExpressionExecutor(io.siddhi.core.executor.ConstantExpressionExecutor)

Example 4 with Attribute

use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.

the class ExpressionWindowProcessor method init.

@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();
}
Also used : Attribute(io.siddhi.query.api.definition.Attribute) ConstantExpressionExecutor(io.siddhi.core.executor.ConstantExpressionExecutor)

Example 5 with Attribute

use of io.siddhi.query.api.definition.Attribute in project siddhi by wso2.

the class GroupingWindowProcessor method init.

@Override
protected StateFactory<S> init(MetaStreamEvent metaStreamEvent, AbstractDefinition inputDefinition, ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, StreamEventClonerHolder streamEventClonerHolder, boolean outputExpectsExpiredEvents, boolean findToBeExecuted, SiddhiQueryContext siddhiQueryContext) {
    StateFactory<S> stateFactory = init(attributeExpressionExecutors, configReader, outputExpectsExpiredEvents, siddhiQueryContext);
    Attribute groupingKey = new Attribute("_groupingKey", Attribute.Type.STRING);
    internalAttributes = new ArrayList<Attribute>(1);
    internalAttributes.add(groupingKey);
    metaStreamEvent.addData(groupingKey);
    return stateFactory;
}
Also used : Attribute(io.siddhi.query.api.definition.Attribute)

Aggregations

Attribute (io.siddhi.query.api.definition.Attribute)86 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)43 ArrayList (java.util.ArrayList)29 VariableExpressionExecutor (io.siddhi.core.executor.VariableExpressionExecutor)27 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)23 OutputAttribute (io.siddhi.query.api.execution.query.selection.OutputAttribute)23 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)22 StreamEvent (io.siddhi.core.event.stream.StreamEvent)21 ConstantExpressionExecutor (io.siddhi.core.executor.ConstantExpressionExecutor)19 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)18 Variable (io.siddhi.query.api.expression.Variable)18 Expression (io.siddhi.query.api.expression.Expression)17 Test (org.testng.annotations.Test)17 StreamEventFactory (io.siddhi.core.event.stream.StreamEventFactory)15 HashMap (java.util.HashMap)15 StreamEventCloner (io.siddhi.core.event.stream.StreamEventCloner)14 MatchingMetaInfoHolder (io.siddhi.core.util.collection.operator.MatchingMetaInfoHolder)14 TableDefinition (io.siddhi.query.api.definition.TableDefinition)13 Map (java.util.Map)13 Annotation (io.siddhi.query.api.annotation.Annotation)12