Search in sources :

Example 1 with SiddhiElement

use of org.wso2.siddhi.query.api.SiddhiElement in project siddhi by wso2.

the class AbstractStreamProcessor method initProcessor.

public AbstractDefinition initProcessor(AbstractDefinition inputDefinition, ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiAppContext siddhiAppContext, boolean outputExpectsExpiredEvents, String queryName, SiddhiElement siddhiElement) {
    this.configReader = configReader;
    this.outputExpectsExpiredEvents = outputExpectsExpiredEvents;
    try {
        this.inputDefinition = inputDefinition;
        this.attributeExpressionExecutors = attributeExpressionExecutors;
        this.siddhiAppContext = siddhiAppContext;
        this.attributeExpressionLength = attributeExpressionExecutors.length;
        this.queryName = queryName;
        if (elementId == null) {
            elementId = "AbstractStreamProcessor-" + siddhiAppContext.getElementIdGenerator().createNewId();
        }
        siddhiAppContext.getSnapshotService().addSnapshotable(queryName, this);
        this.additionalAttributes = init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
        siddhiAppContext.addEternalReferencedHolder(this);
        StreamDefinition outputDefinition = StreamDefinition.id(inputDefinition.getId());
        outputDefinition.setQueryContextStartIndex(siddhiElement.getQueryContextStartIndex());
        outputDefinition.setQueryContextEndIndex(siddhiElement.getQueryContextEndIndex());
        for (Attribute attribute : inputDefinition.getAttributeList()) {
            outputDefinition.attribute(attribute.getName(), attribute.getType());
        }
        for (Attribute attribute : additionalAttributes) {
            outputDefinition.attribute(attribute.getName(), attribute.getType());
        }
        return outputDefinition;
    } catch (Throwable t) {
        throw new SiddhiAppCreationException(t);
    }
}
Also used : StreamDefinition(org.wso2.siddhi.query.api.definition.StreamDefinition) Attribute(org.wso2.siddhi.query.api.definition.Attribute) SiddhiAppCreationException(org.wso2.siddhi.core.exception.SiddhiAppCreationException)

Aggregations

SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)1 Attribute (org.wso2.siddhi.query.api.definition.Attribute)1 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)1