Search in sources :

Example 1 with AttributeNotExistException

use of org.wso2.siddhi.query.api.exception.AttributeNotExistException in project siddhi by wso2.

the class PartitionedDistributionStrategy method init.

/**
 * Initialize the Distribution strategy with the information it will require to make decisions.
 *  @param streamDefinition         The stream attached to the sink this DistributionStrategy is used in
 * @param transportOptionHolder    Sink options of the sink which uses this DistributionStrategy
 * @param destinationOptionHolders The list of options under @destination of the relevant sink.
 * @param configReader This hold the {@link PartitionedDistributionStrategy} configuration reader.
 */
@Override
public void init(StreamDefinition streamDefinition, OptionHolder transportOptionHolder, OptionHolder distributionOptionHolder, List<OptionHolder> destinationOptionHolders, ConfigReader configReader) {
    totalDestinationCount = destinationOptionHolders.size();
    String partitionKey = distributionOptionHolder.validateAndGetStaticValue(SiddhiConstants.PARTITION_KEY_FIELD_KEY);
    if (partitionKey == null || partitionKey.isEmpty()) {
        throw new SiddhiAppValidationException("PartitionKey is required for partitioned distribution " + "strategy.");
    }
    try {
        int partitionKeyFieldPosition = streamDefinition.getAttributePosition(partitionKey);
        partitionOption = new Option(partitionKeyFieldPosition);
    } catch (AttributeNotExistException e) {
        throw new SiddhiAppValidationException("Could not find partition key attribute", e);
    }
}
Also used : AttributeNotExistException(org.wso2.siddhi.query.api.exception.AttributeNotExistException) SiddhiAppValidationException(org.wso2.siddhi.query.api.exception.SiddhiAppValidationException) Option(org.wso2.siddhi.core.util.transport.Option)

Example 2 with AttributeNotExistException

use of org.wso2.siddhi.query.api.exception.AttributeNotExistException in project siddhi by wso2.

the class ExpressionParser method parseVariable.

/**
 * Parse and validate the given Siddhi variable and return a VariableExpressionExecutor
 *
 * @param variable     Variable to be parsed
 * @param metaEvent    Meta event used to collect execution info of stream associated with query
 * @param currentState Current State Number
 * @param executorList List to hold VariableExpressionExecutors to update after query parsing @return
 *                     VariableExpressionExecutor representing given variable
 */
private static ExpressionExecutor parseVariable(Variable variable, MetaComplexEvent metaEvent, int currentState, List<VariableExpressionExecutor> executorList, int defaultStreamEventIndex) {
    String attributeName = variable.getAttributeName();
    int[] eventPosition = new int[2];
    if (variable.getStreamIndex() != null) {
        if (variable.getStreamIndex() <= LAST) {
            eventPosition[STREAM_EVENT_INDEX_IN_CHAIN] = variable.getStreamIndex() + 1;
        } else {
            eventPosition[STREAM_EVENT_INDEX_IN_CHAIN] = variable.getStreamIndex();
        }
    } else {
        eventPosition[STREAM_EVENT_INDEX_IN_CHAIN] = defaultStreamEventIndex;
    }
    eventPosition[STREAM_EVENT_CHAIN_INDEX] = UNKNOWN_STATE;
    if (metaEvent instanceof MetaStreamEvent) {
        MetaStreamEvent metaStreamEvent = (MetaStreamEvent) metaEvent;
        AbstractDefinition abstractDefinition;
        Attribute.Type type;
        if (currentState == HAVING_STATE) {
            abstractDefinition = metaStreamEvent.getOutputStreamDefinition();
            type = abstractDefinition.getAttributeType(attributeName);
            eventPosition[STREAM_EVENT_CHAIN_INDEX] = HAVING_STATE;
        } else {
            abstractDefinition = metaStreamEvent.getLastInputDefinition();
            type = abstractDefinition.getAttributeType(attributeName);
            ((MetaStreamEvent) metaEvent).addData(new Attribute(attributeName, type));
        }
        VariableExpressionExecutor variableExpressionExecutor = new VariableExpressionExecutor(new Attribute(attributeName, type), eventPosition[STREAM_EVENT_CHAIN_INDEX], eventPosition[STREAM_EVENT_INDEX_IN_CHAIN]);
        if (((MetaStreamEvent) metaEvent).getEventType() != MetaStreamEvent.EventType.DEFAULT) {
            variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_TYPE_INDEX] = OUTPUT_DATA_INDEX;
            variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_INDEX_IN_TYPE] = abstractDefinition.getAttributePosition(variableExpressionExecutor.getAttribute().getName());
        }
        if (executorList != null) {
            executorList.add(variableExpressionExecutor);
        }
        return variableExpressionExecutor;
    } else {
        MetaStateEvent metaStateEvent = (MetaStateEvent) metaEvent;
        Attribute.Type type = null;
        AbstractDefinition definition = null;
        String firstInput = null;
        if (variable.getStreamId() == null) {
            MetaStreamEvent[] metaStreamEvents = metaStateEvent.getMetaStreamEvents();
            if (currentState == HAVING_STATE) {
                definition = metaStateEvent.getOutputStreamDefinition();
                try {
                    type = definition.getAttributeType(attributeName);
                    eventPosition[STREAM_EVENT_CHAIN_INDEX] = HAVING_STATE;
                } catch (AttributeNotExistException e) {
                    currentState = UNKNOWN_STATE;
                }
            }
            if (currentState == UNKNOWN_STATE) {
                for (int i = 0; i < metaStreamEvents.length; i++) {
                    MetaStreamEvent metaStreamEvent = metaStreamEvents[i];
                    definition = metaStreamEvent.getLastInputDefinition();
                    if (type == null) {
                        try {
                            type = definition.getAttributeType(attributeName);
                            firstInput = "Input Stream: " + definition.getId() + " with " + "reference: " + metaStreamEvent.getInputReferenceId();
                            eventPosition[STREAM_EVENT_CHAIN_INDEX] = i;
                        } catch (AttributeNotExistException e) {
                        // do nothing
                        }
                    } else {
                        try {
                            definition.getAttributeType(attributeName);
                            throw new SiddhiAppValidationException(firstInput + " and Input Stream: " + definition.getId() + " with " + "reference: " + metaStreamEvent.getInputReferenceId() + " contains attribute " + "with same" + " name '" + attributeName + "'");
                        } catch (AttributeNotExistException e) {
                        // do nothing as its expected
                        }
                    }
                }
            } else if (currentState >= 0) {
                MetaStreamEvent metaStreamEvent = metaStreamEvents[currentState];
                definition = metaStreamEvent.getLastInputDefinition();
                try {
                    type = definition.getAttributeType(attributeName);
                    eventPosition[STREAM_EVENT_CHAIN_INDEX] = currentState;
                } catch (AttributeNotExistException e) {
                    throw new SiddhiAppValidationException(e.getMessageWithOutContext() + " Input Stream: " + definition.getId() + " with reference: " + metaStreamEvent.getInputReferenceId(), e, e.getQueryContextStartIndex(), e.getQueryContextEndIndex());
                }
            }
        } else {
            MetaStreamEvent[] metaStreamEvents = metaStateEvent.getMetaStreamEvents();
            for (int i = 0, metaStreamEventsLength = metaStreamEvents.length; i < metaStreamEventsLength; i++) {
                MetaStreamEvent metaStreamEvent = metaStreamEvents[i];
                definition = metaStreamEvent.getLastInputDefinition();
                if (metaStreamEvent.getInputReferenceId() == null) {
                    if (definition.getId().equals(variable.getStreamId())) {
                        type = definition.getAttributeType(attributeName);
                        eventPosition[STREAM_EVENT_CHAIN_INDEX] = i;
                        break;
                    }
                } else {
                    if (metaStreamEvent.getInputReferenceId().equals(variable.getStreamId())) {
                        type = definition.getAttributeType(attributeName);
                        eventPosition[STREAM_EVENT_CHAIN_INDEX] = i;
                        if (currentState > -1 && metaStreamEvents[currentState].getInputReferenceId() != null && variable.getStreamIndex() != null && variable.getStreamIndex() <= LAST) {
                            if (variable.getStreamId().equals(metaStreamEvents[currentState].getInputReferenceId())) {
                                eventPosition[STREAM_EVENT_INDEX_IN_CHAIN] = variable.getStreamIndex();
                            }
                        }
                        break;
                    }
                }
            }
        }
        if (eventPosition[STREAM_EVENT_CHAIN_INDEX] == UNKNOWN_STATE) {
            throw new SiddhiAppValidationException("Stream with reference : " + variable.getStreamId() + " not found");
        }
        VariableExpressionExecutor variableExpressionExecutor = new VariableExpressionExecutor(new Attribute(attributeName, type), eventPosition[STREAM_EVENT_CHAIN_INDEX], eventPosition[STREAM_EVENT_INDEX_IN_CHAIN]);
        if (eventPosition[STREAM_EVENT_CHAIN_INDEX] != HAVING_STATE) {
            MetaStreamEvent metaStreamEvent = ((MetaStateEvent) metaEvent).getMetaStreamEvent(eventPosition[STREAM_EVENT_CHAIN_INDEX]);
            if (metaStreamEvent.getEventType() != MetaStreamEvent.EventType.DEFAULT) {
                variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_TYPE_INDEX] = OUTPUT_DATA_INDEX;
                variableExpressionExecutor.getPosition()[STREAM_ATTRIBUTE_INDEX_IN_TYPE] = metaStreamEvent.getLastInputDefinition().getAttributePosition(variableExpressionExecutor.getAttribute().getName());
                for (Attribute attribute : metaStreamEvent.getLastInputDefinition().getAttributeList()) {
                    metaStreamEvent.addOutputData(new Attribute(attribute.getName(), attribute.getType()));
                }
            }
            metaStreamEvent.addData(new Attribute(attributeName, type));
        }
        if (executorList != null) {
            executorList.add(variableExpressionExecutor);
        }
        return variableExpressionExecutor;
    }
}
Also used : AttributeNotExistException(org.wso2.siddhi.query.api.exception.AttributeNotExistException) Attribute(org.wso2.siddhi.query.api.definition.Attribute) VariableExpressionExecutor(org.wso2.siddhi.core.executor.VariableExpressionExecutor) AbstractDefinition(org.wso2.siddhi.query.api.definition.AbstractDefinition) SiddhiAppValidationException(org.wso2.siddhi.query.api.exception.SiddhiAppValidationException) EqualCompareConditionExpressionExecutorStringString(org.wso2.siddhi.core.executor.condition.compare.equal.EqualCompareConditionExpressionExecutorStringString) NotEqualCompareConditionExpressionExecutorStringString(org.wso2.siddhi.core.executor.condition.compare.notequal.NotEqualCompareConditionExpressionExecutorStringString) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(org.wso2.siddhi.core.event.state.MetaStateEvent)

Example 3 with AttributeNotExistException

use of org.wso2.siddhi.query.api.exception.AttributeNotExistException in project siddhi by wso2.

the class ExpressionBuilder method buildVariableExecutors.

private void buildVariableExecutors(Expression expression, ExpressionVisitor expressionVisitor) {
    try {
        if (expression instanceof And) {
            expressionVisitor.beginVisitAnd();
            expressionVisitor.beginVisitAndLeftOperand();
            buildVariableExecutors(((And) expression).getLeftExpression(), expressionVisitor);
            expressionVisitor.endVisitAndLeftOperand();
            expressionVisitor.beginVisitAndRightOperand();
            buildVariableExecutors(((And) expression).getRightExpression(), expressionVisitor);
            expressionVisitor.endVisitAndRightOperand();
            expressionVisitor.endVisitAnd();
        } else if (expression instanceof Or) {
            expressionVisitor.beginVisitOr();
            expressionVisitor.beginVisitOrLeftOperand();
            buildVariableExecutors(((Or) expression).getLeftExpression(), expressionVisitor);
            expressionVisitor.endVisitOrLeftOperand();
            expressionVisitor.beginVisitOrRightOperand();
            buildVariableExecutors(((Or) expression).getRightExpression(), expressionVisitor);
            expressionVisitor.endVisitOrRightOperand();
            expressionVisitor.endVisitOr();
        } else if (expression instanceof Not) {
            expressionVisitor.beginVisitNot();
            buildVariableExecutors(((Not) expression).getExpression(), expressionVisitor);
            expressionVisitor.endVisitNot();
        } else if (expression instanceof Compare) {
            expressionVisitor.beginVisitCompare(((Compare) expression).getOperator());
            expressionVisitor.beginVisitCompareLeftOperand(((Compare) expression).getOperator());
            buildVariableExecutors(((Compare) expression).getLeftExpression(), expressionVisitor);
            expressionVisitor.endVisitCompareLeftOperand(((Compare) expression).getOperator());
            expressionVisitor.beginVisitCompareRightOperand(((Compare) expression).getOperator());
            buildVariableExecutors(((Compare) expression).getRightExpression(), expressionVisitor);
            expressionVisitor.endVisitCompareRightOperand(((Compare) expression).getOperator());
            expressionVisitor.endVisitCompare(((Compare) expression).getOperator());
        } else if (expression instanceof Add) {
            expressionVisitor.beginVisitMath(ExpressionVisitor.MathOperator.ADD);
            expressionVisitor.beginVisitMathLeftOperand(ExpressionVisitor.MathOperator.ADD);
            buildVariableExecutors(((Add) expression).getLeftValue(), expressionVisitor);
            expressionVisitor.endVisitMathLeftOperand(ExpressionVisitor.MathOperator.ADD);
            expressionVisitor.beginVisitMathRightOperand(ExpressionVisitor.MathOperator.ADD);
            buildVariableExecutors(((Add) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMathRightOperand(ExpressionVisitor.MathOperator.ADD);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.ADD);
        } else if (expression instanceof Subtract) {
            expressionVisitor.beginVisitMath(ExpressionVisitor.MathOperator.SUBTRACT);
            expressionVisitor.beginVisitMathLeftOperand(ExpressionVisitor.MathOperator.SUBTRACT);
            buildVariableExecutors(((Subtract) expression).getLeftValue(), expressionVisitor);
            expressionVisitor.endVisitMathLeftOperand(ExpressionVisitor.MathOperator.SUBTRACT);
            expressionVisitor.beginVisitMathRightOperand(ExpressionVisitor.MathOperator.SUBTRACT);
            buildVariableExecutors(((Subtract) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMathRightOperand(ExpressionVisitor.MathOperator.SUBTRACT);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.SUBTRACT);
        } else if (expression instanceof Divide) {
            expressionVisitor.beginVisitMath(ExpressionVisitor.MathOperator.DIVIDE);
            expressionVisitor.beginVisitMathLeftOperand(ExpressionVisitor.MathOperator.DIVIDE);
            buildVariableExecutors(((Divide) expression).getLeftValue(), expressionVisitor);
            expressionVisitor.endVisitMathLeftOperand(ExpressionVisitor.MathOperator.DIVIDE);
            expressionVisitor.beginVisitMathRightOperand(ExpressionVisitor.MathOperator.DIVIDE);
            buildVariableExecutors(((Divide) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMathRightOperand(ExpressionVisitor.MathOperator.DIVIDE);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.DIVIDE);
        } else if (expression instanceof Multiply) {
            expressionVisitor.beginVisitMath(ExpressionVisitor.MathOperator.MULTIPLY);
            expressionVisitor.beginVisitMathLeftOperand(ExpressionVisitor.MathOperator.MULTIPLY);
            buildVariableExecutors(((Multiply) expression).getLeftValue(), expressionVisitor);
            expressionVisitor.endVisitMathLeftOperand(ExpressionVisitor.MathOperator.MULTIPLY);
            expressionVisitor.beginVisitMathRightOperand(ExpressionVisitor.MathOperator.MULTIPLY);
            buildVariableExecutors(((Multiply) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMathRightOperand(ExpressionVisitor.MathOperator.MULTIPLY);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.MULTIPLY);
        } else if (expression instanceof Mod) {
            expressionVisitor.beginVisitMath(ExpressionVisitor.MathOperator.MOD);
            expressionVisitor.beginVisitMathLeftOperand(ExpressionVisitor.MathOperator.MOD);
            buildVariableExecutors(((Mod) expression).getLeftValue(), expressionVisitor);
            expressionVisitor.endVisitMathLeftOperand(ExpressionVisitor.MathOperator.MOD);
            expressionVisitor.beginVisitMathRightOperand(ExpressionVisitor.MathOperator.MOD);
            buildVariableExecutors(((Mod) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMathRightOperand(ExpressionVisitor.MathOperator.MOD);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.MOD);
        } else if (expression instanceof IsNull) {
            IsNull isNull = (IsNull) expression;
            if (isNull.getExpression() != null) {
                expressionVisitor.beginVisitIsNull(null);
                buildVariableExecutors(((IsNull) expression).getExpression(), expressionVisitor);
                expressionVisitor.endVisitIsNull(null);
            } else {
                String streamId = isNull.getStreamId();
                MetaStateEvent metaStateEvent = matchingMetaInfoHolder.getMetaStateEvent();
                if (streamId == null) {
                    throw new SiddhiAppCreationException("IsNull does not support streamId being null");
                } else {
                    AbstractDefinition definitionOutput = null;
                    MetaStreamEvent[] metaStreamEvents = metaStateEvent.getMetaStreamEvents();
                    for (int i = 0, metaStreamEventsLength = metaStreamEvents.length; i < metaStreamEventsLength; i++) {
                        MetaStreamEvent metaStreamEvent = metaStreamEvents[i];
                        AbstractDefinition definition = metaStreamEvent.getLastInputDefinition();
                        if (metaStreamEvent.getInputReferenceId() == null) {
                            if (definition.getId().equals(streamId)) {
                                definitionOutput = definition;
                                break;
                            }
                        } else {
                            if (metaStreamEvent.getInputReferenceId().equals(streamId)) {
                                definitionOutput = definition;
                                break;
                            }
                        }
                    }
                    if (definitionOutput != null) {
                        expressionVisitor.beginVisitIsNull(definitionOutput.getId());
                        expressionVisitor.endVisitIsNull(definitionOutput.getId());
                    } else {
                        expressionVisitor.beginVisitIsNull(null);
                        expressionVisitor.endVisitIsNull(null);
                    }
                }
            }
        } else if (expression instanceof In) {
            expressionVisitor.beginVisitIn(((In) expression).getSourceId());
            buildVariableExecutors(((In) expression).getExpression(), expressionVisitor);
            expressionVisitor.endVisitIn(((In) expression).getSourceId());
        } else if (expression instanceof Constant) {
            if (expression instanceof DoubleConstant) {
                expressionVisitor.beginVisitConstant(((DoubleConstant) expression).getValue(), Attribute.Type.DOUBLE);
                expressionVisitor.endVisitConstant(((DoubleConstant) expression).getValue(), Attribute.Type.DOUBLE);
            } else if (expression instanceof StringConstant) {
                expressionVisitor.beginVisitConstant(((StringConstant) expression).getValue(), Attribute.Type.STRING);
                expressionVisitor.endVisitConstant(((StringConstant) expression).getValue(), Attribute.Type.STRING);
            } else if (expression instanceof IntConstant) {
                expressionVisitor.beginVisitConstant(((IntConstant) expression).getValue(), Attribute.Type.INT);
                expressionVisitor.endVisitConstant(((IntConstant) expression).getValue(), Attribute.Type.INT);
            } else if (expression instanceof BoolConstant) {
                expressionVisitor.beginVisitConstant(((BoolConstant) expression).getValue(), Attribute.Type.BOOL);
                expressionVisitor.endVisitConstant(((BoolConstant) expression).getValue(), Attribute.Type.BOOL);
            } else if (expression instanceof FloatConstant) {
                expressionVisitor.beginVisitConstant(((FloatConstant) expression).getValue(), Attribute.Type.FLOAT);
                expressionVisitor.endVisitConstant(((FloatConstant) expression).getValue(), Attribute.Type.FLOAT);
            } else if (expression instanceof LongConstant) {
                expressionVisitor.beginVisitConstant(((LongConstant) expression).getValue(), Attribute.Type.LONG);
                expressionVisitor.endVisitConstant(((LongConstant) expression).getValue(), Attribute.Type.LONG);
            } else {
                throw new OperationNotSupportedException("No constant exist with type " + expression.getClass().getName());
            }
        } else if (expression instanceof AttributeFunction) {
            expressionVisitor.beginVisitAttributeFunction(((AttributeFunction) expression).getNamespace(), ((AttributeFunction) expression).getName());
            Expression[] expressions = ((AttributeFunction) expression).getParameters();
            for (int i = 0; i < expressions.length; i++) {
                expressionVisitor.beginVisitParameterAttributeFunction(i);
                buildVariableExecutors(expressions[i], expressionVisitor);
                expressionVisitor.endVisitParameterAttributeFunction(i);
            }
            expressionVisitor.endVisitAttributeFunction(((AttributeFunction) expression).getNamespace(), ((AttributeFunction) expression).getName());
        } else if (expression instanceof Variable) {
            Variable variable = ((Variable) expression);
            String attributeName = variable.getAttributeName();
            AbstractDefinition definition;
            Attribute.Type type = null;
            int streamEventChainIndex = matchingMetaInfoHolder.getCurrentState();
            if (variable.getStreamId() == null) {
                MetaStreamEvent[] metaStreamEvents = matchingMetaInfoHolder.getMetaStateEvent().getMetaStreamEvents();
                if (streamEventChainIndex == UNKNOWN_STATE) {
                    String firstInput = null;
                    for (int i = 0; i < metaStreamEvents.length; i++) {
                        MetaStreamEvent metaStreamEvent = metaStreamEvents[i];
                        definition = metaStreamEvent.getLastInputDefinition();
                        if (type == null) {
                            try {
                                type = definition.getAttributeType(attributeName);
                                firstInput = "Input Stream: " + definition.getId() + " with " + "reference: " + metaStreamEvent.getInputReferenceId();
                                streamEventChainIndex = i;
                            } catch (AttributeNotExistException e) {
                            // do nothing
                            }
                        } else {
                            try {
                                definition.getAttributeType(attributeName);
                                throw new SiddhiAppValidationException(firstInput + " and Input Stream: " + definition.getId() + " with " + "reference: " + metaStreamEvent.getInputReferenceId() + " contains attribute " + "with same" + " name '" + attributeName + "'");
                            } catch (AttributeNotExistException e) {
                            // do nothing as its expected
                            }
                        }
                    }
                    if (streamEventChainIndex != UNKNOWN_STATE) {
                        if (matchingMetaInfoHolder.getMatchingStreamEventIndex() == streamEventChainIndex) {
                            buildStreamVariableExecutor(variable, streamEventChainIndex, expressionVisitor, type);
                        } else {
                            buildStoreVariableExecutor(variable, expressionVisitor, type, matchingMetaInfoHolder.getStoreDefinition());
                        }
                    }
                } else {
                    MetaStreamEvent metaStreamEvent = matchingMetaInfoHolder.getMetaStateEvent().getMetaStreamEvent(matchingMetaInfoHolder.getCurrentState());
                    definition = metaStreamEvent.getLastInputDefinition();
                    try {
                        type = definition.getAttributeType(attributeName);
                    } catch (AttributeNotExistException e) {
                        throw new SiddhiAppValidationException(e.getMessageWithOutContext() + " Input Stream: " + definition.getId() + " with " + "reference: " + metaStreamEvent.getInputReferenceId(), e.getQueryContextStartIndex(), e.getQueryContextEndIndex(), siddhiAppContext.getName(), siddhiAppContext.getSiddhiAppString());
                    }
                    if (matchingMetaInfoHolder.getCurrentState() == matchingMetaInfoHolder.getMatchingStreamEventIndex()) {
                        buildStreamVariableExecutor(variable, streamEventChainIndex, expressionVisitor, type);
                    } else {
                        buildStoreVariableExecutor(variable, expressionVisitor, type, matchingMetaInfoHolder.getStoreDefinition());
                    }
                }
            } else {
                MetaStreamEvent[] metaStreamEvents = matchingMetaInfoHolder.getMetaStateEvent().getMetaStreamEvents();
                for (int i = 0, metaStreamEventsLength = metaStreamEvents.length; i < metaStreamEventsLength; i++) {
                    MetaStreamEvent metaStreamEvent = metaStreamEvents[i];
                    definition = metaStreamEvent.getLastInputDefinition();
                    if (metaStreamEvent.getInputReferenceId() == null) {
                        if (definition.getId().equals(variable.getStreamId())) {
                            type = definition.getAttributeType(attributeName);
                            streamEventChainIndex = i;
                            break;
                        }
                    } else {
                        if (metaStreamEvent.getInputReferenceId().equals(variable.getStreamId())) {
                            type = definition.getAttributeType(attributeName);
                            streamEventChainIndex = i;
                            break;
                        }
                    }
                }
                if (matchingMetaInfoHolder.getMatchingStreamEventIndex() == streamEventChainIndex) {
                    buildStreamVariableExecutor(variable, streamEventChainIndex, expressionVisitor, type);
                } else {
                    buildStoreVariableExecutor(variable, expressionVisitor, type, matchingMetaInfoHolder.getStoreDefinition());
                }
            }
        }
    } catch (Throwable t) {
        ExceptionUtil.populateQueryContext(t, expression, siddhiAppContext);
        throw t;
    }
}
Also used : Add(org.wso2.siddhi.query.api.expression.math.Add) DoubleConstant(org.wso2.siddhi.query.api.expression.constant.DoubleConstant) Or(org.wso2.siddhi.query.api.expression.condition.Or) Variable(org.wso2.siddhi.query.api.expression.Variable) In(org.wso2.siddhi.query.api.expression.condition.In) StringConstant(org.wso2.siddhi.query.api.expression.constant.StringConstant) Constant(org.wso2.siddhi.query.api.expression.constant.Constant) DoubleConstant(org.wso2.siddhi.query.api.expression.constant.DoubleConstant) LongConstant(org.wso2.siddhi.query.api.expression.constant.LongConstant) FloatConstant(org.wso2.siddhi.query.api.expression.constant.FloatConstant) BoolConstant(org.wso2.siddhi.query.api.expression.constant.BoolConstant) IntConstant(org.wso2.siddhi.query.api.expression.constant.IntConstant) FloatConstant(org.wso2.siddhi.query.api.expression.constant.FloatConstant) Divide(org.wso2.siddhi.query.api.expression.math.Divide) AttributeNotExistException(org.wso2.siddhi.query.api.exception.AttributeNotExistException) Multiply(org.wso2.siddhi.query.api.expression.math.Multiply) IntConstant(org.wso2.siddhi.query.api.expression.constant.IntConstant) Compare(org.wso2.siddhi.query.api.expression.condition.Compare) LongConstant(org.wso2.siddhi.query.api.expression.constant.LongConstant) OperationNotSupportedException(org.wso2.siddhi.core.exception.OperationNotSupportedException) BoolConstant(org.wso2.siddhi.query.api.expression.constant.BoolConstant) Mod(org.wso2.siddhi.query.api.expression.math.Mod) SiddhiAppCreationException(org.wso2.siddhi.core.exception.SiddhiAppCreationException) AbstractDefinition(org.wso2.siddhi.query.api.definition.AbstractDefinition) SiddhiAppValidationException(org.wso2.siddhi.query.api.exception.SiddhiAppValidationException) AttributeFunction(org.wso2.siddhi.query.api.expression.AttributeFunction) MetaStateEvent(org.wso2.siddhi.core.event.state.MetaStateEvent) Not(org.wso2.siddhi.query.api.expression.condition.Not) Expression(org.wso2.siddhi.query.api.expression.Expression) And(org.wso2.siddhi.query.api.expression.condition.And) Subtract(org.wso2.siddhi.query.api.expression.math.Subtract) IsNull(org.wso2.siddhi.query.api.expression.condition.IsNull) StringConstant(org.wso2.siddhi.query.api.expression.constant.StringConstant) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent)

Aggregations

AttributeNotExistException (org.wso2.siddhi.query.api.exception.AttributeNotExistException)3 SiddhiAppValidationException (org.wso2.siddhi.query.api.exception.SiddhiAppValidationException)3 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)2 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)2 AbstractDefinition (org.wso2.siddhi.query.api.definition.AbstractDefinition)2 OperationNotSupportedException (org.wso2.siddhi.core.exception.OperationNotSupportedException)1 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)1 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)1 EqualCompareConditionExpressionExecutorStringString (org.wso2.siddhi.core.executor.condition.compare.equal.EqualCompareConditionExpressionExecutorStringString)1 NotEqualCompareConditionExpressionExecutorStringString (org.wso2.siddhi.core.executor.condition.compare.notequal.NotEqualCompareConditionExpressionExecutorStringString)1 Option (org.wso2.siddhi.core.util.transport.Option)1 Attribute (org.wso2.siddhi.query.api.definition.Attribute)1 AttributeFunction (org.wso2.siddhi.query.api.expression.AttributeFunction)1 Expression (org.wso2.siddhi.query.api.expression.Expression)1 Variable (org.wso2.siddhi.query.api.expression.Variable)1 And (org.wso2.siddhi.query.api.expression.condition.And)1 Compare (org.wso2.siddhi.query.api.expression.condition.Compare)1 In (org.wso2.siddhi.query.api.expression.condition.In)1 IsNull (org.wso2.siddhi.query.api.expression.condition.IsNull)1 Not (org.wso2.siddhi.query.api.expression.condition.Not)1