Package com.espertech.esper.epl.variable

Examples of com.espertech.esper.epl.variable.VariableReader


    {
      throw new NullPointerException("Output condition by count requires a non-null callback");
    }

        // Check if a variable is present
        VariableReader reader = null;
        if (outputLimitSpec.getVariableName() != null)
        {
            reader = agentInstanceContext.getStatementContext().getVariableService().getReader(outputLimitSpec.getVariableName(), agentInstanceContext.getAgentInstanceId());
            if (reader == null)
            {
                throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' has not been declared");
            }
        }

        if(outputLimitSpec.getRateType() == OutputLimitRateType.CRONTAB)
        {
            return new OutputConditionPolledCrontab(outputLimitSpec.getCrontabAtSchedule(), agentInstanceContext);
        }
        else if(outputLimitSpec.getRateType() == OutputLimitRateType.WHEN_EXPRESSION)
        {
            return new OutputConditionPolledExpression(outputLimitSpec.getWhenExpressionNode(), outputLimitSpec.getThenExpressions(), agentInstanceContext);
        }
        else if(outputLimitSpec.getRateType() == OutputLimitRateType.EVENTS)
    {
            if (log.isDebugEnabled())
            {
          log.debug(".createCondition creating OutputConditionCount with event rate " + outputLimitSpec);
            }

            if ((reader != null) && (!JavaClassHelper.isNumericNonFP(reader.getVariableMetaData().getType())))
            {
                throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be type integer, long or short");
            }

            int rate = -1;
            if (outputLimitSpec.getRate() != null)
            {
                rate = outputLimitSpec.getRate().intValue();
            }
            return new OutputConditionPolledCount(rate, reader);
    }
    else
    {
            if ((reader != null) && (!JavaClassHelper.isNumeric(reader.getVariableMetaData().getType())))
            {
                throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be of numeric type");
            }

            return new OutputConditionPolledTime(outputLimitSpec.getTimePeriodExpr(), agentInstanceContext);
View Full Code Here


            if ((statements != null) && (!statements.isEmpty())) {
                throw new ConfigurationException("Variable '" + name + "' is in use by one or more statements");
            }
        }

        VariableReader reader = variableService.getReader(name, VariableService.NOCONTEXT_AGENTINSTANCEID);
        if (reader == null)
        {
            return false;
        }
View Full Code Here

            }
        }
    }

    public OrderByProcessor instantiate(AggregationService aggregationService, AgentInstanceContext agentInstanceContext) {
        VariableReader numRowsVariableReader = null;
        if (numRowsVariableMetaData != null) {
            numRowsVariableReader = agentInstanceContext.getStatementContext().getVariableService().getReader(numRowsVariableMetaData.getVariableName(), agentInstanceContext.getAgentInstanceId());
        }

        VariableReader offsetVariableReader = null;
        if (offsetVariableMetaData != null) {
            offsetVariableReader = agentInstanceContext.getStatementContext().getVariableService().getReader(offsetVariableMetaData.getVariableName(), agentInstanceContext.getAgentInstanceId());
        }

        return new OrderByProcessorRowLimit(numRowsVariableReader, offsetVariableReader,
View Full Code Here

            if (message != null) {
                throw new ExprValidationException(message);
            }
            return new AggSvcGroupByReclaimAgedEvalFuncFactory() {
                public AggSvcGroupByReclaimAgedEvalFunc make(AgentInstanceContext agentInstanceContext) {
                    VariableReader reader = variableService.getReader(variableMetaData.getVariableName(), agentInstanceContext.getAgentInstanceId());
                    return new AggSvcGroupByReclaimAgedEvalFuncVariable(reader);
                }
            };
        }
        else
View Full Code Here

            throw new VariableNotFoundException("Variable by name '" + variableName + "' has not been declared");
        }
        if (metaData.getContextPartitionName() != null) {
            throw new VariableNotFoundException("Variable by name '" + variableName + "' has been declared for context '" + metaData.getContextPartitionName() + "' and cannot be read without context partition selector");
        }
        VariableReader reader = services.getVariableService().getReader(variableName, VariableService.NOCONTEXT_AGENTINSTANCEID);
        Object value = reader.getValue();
        if (value == null || reader.getVariableMetaData().getEventType() == null) {
            return value;
        }
        return ((EventBean) value).getUnderlying();
    }
View Full Code Here

        Map<String, List<ContextPartitionVariableState>> statesMap = new HashMap<String, List<ContextPartitionVariableState>>();
        for (String variableName : variableNames) {
            List<ContextPartitionVariableState> states = new ArrayList<ContextPartitionVariableState>();
            statesMap.put(variableName, states);
            for (Map.Entry<Integer, ContextPartitionDescriptor> entry : contextPartitions.entrySet()) {
                VariableReader reader = services.getVariableService().getReader(variableName, entry.getKey());
                Object value = reader.getValue();
                if (value != null && reader.getVariableMetaData().getEventType() != null) {
                    value = ((EventBean) value).getUnderlying();
                }
                states.add(new ContextPartitionVariableState(entry.getKey(), entry.getValue().getIdentifier(), value));
            }
        }
View Full Code Here

        Map<String, Object> values = new HashMap<String, Object>();
        for (String variableName : variableNames)
        {
            VariableMetaData metaData = services.getVariableService().getVariableMetaData(variableName);
            checkVariable(variableName, metaData, false, false);
            VariableReader reader = services.getVariableService().getReader(variableName, VariableService.NOCONTEXT_AGENTINSTANCEID);
            if (reader == null)
            {
                throw new VariableNotFoundException("Variable by name '" + variableName + "' has not been declared");
            }

            Object value = reader.getValue();
            if (value != null && reader.getVariableMetaData().getEventType() != null) {
                value = ((EventBean) value).getUnderlying();
            }
            values.put(variableName, value);
        }
        return values;
View Full Code Here

        return "variableName=" + variableName;
    }

    public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext)
    {
        VariableReader reader;
        if (readerNonCP != null) {
            reader = readerNonCP;
        }
        else {
            reader = readersPerCp.get(exprEvaluatorContext.getAgentInstanceId());
        }

        if (InstrumentationHelper.ENABLED) { InstrumentationHelper.get().qExprVariable(this);}
        Object value = reader.getValue();
        if (isPrimitive || value == null) {
            if (InstrumentationHelper.ENABLED) { InstrumentationHelper.get().aExprVariable(value);}
            return value;
        }
View Full Code Here

            if ((statements != null) && (!statements.isEmpty())) {
                throw new ConfigurationException("Variable '" + name + "' is in use by one or more statements");
            }
        }

        VariableReader reader = variableService.getReader(name);
        if (reader == null)
        {
            return false;
        }
View Full Code Here

    {
      throw new NullPointerException("Output condition by count requires a non-null callback");
    }

        // Check if a variable is present
        VariableReader reader = null;
        if (outputLimitSpec.getVariableName() != null)
        {
            reader = agentInstanceContext.getStatementContext().getVariableService().getReader(outputLimitSpec.getVariableName());
            if (reader == null)
            {
                throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' has not been declared");
            }
        }

        if(outputLimitSpec.getRateType() == OutputLimitRateType.CRONTAB)
        {
            return new OutputConditionPolledCrontab(outputLimitSpec.getCrontabAtSchedule(), agentInstanceContext);
        }
        else if(outputLimitSpec.getRateType() == OutputLimitRateType.WHEN_EXPRESSION)
        {
            return new OutputConditionPolledExpression(outputLimitSpec.getWhenExpressionNode(), outputLimitSpec.getThenExpressions(), agentInstanceContext);
        }
        else if(outputLimitSpec.getRateType() == OutputLimitRateType.EVENTS)
    {
            if (log.isDebugEnabled())
            {
          log.debug(".createCondition creating OutputConditionCount with event rate " + outputLimitSpec);
            }

            if ((reader != null) && (!JavaClassHelper.isNumericNonFP(reader.getType())))
            {
                throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be type integer, long or short");
            }

            int rate = -1;
            if (outputLimitSpec.getRate() != null)
            {
                rate = outputLimitSpec.getRate().intValue();
            }
            return new OutputConditionPolledCount(rate, reader);
    }
    else
    {
            if ((reader != null) && (!JavaClassHelper.isNumeric(reader.getType())))
            {
                throw new IllegalArgumentException("Variable named '" + outputLimitSpec.getVariableName() + "' must be of numeric type");
            }

            return new OutputConditionPolledTime(outputLimitSpec.getTimePeriodExpr(), agentInstanceContext);
View Full Code Here

TOP

Related Classes of com.espertech.esper.epl.variable.VariableReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.