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;
}
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);
}
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();
}
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();
}
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;
}
Aggregations