當前位置: 首頁>>代碼示例>>Java>>正文


Java VariableReader類代碼示例

本文整理匯總了Java中com.espertech.esper.epl.variable.VariableReader的典型用法代碼示例。如果您正苦於以下問題:Java VariableReader類的具體用法?Java VariableReader怎麽用?Java VariableReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VariableReader類屬於com.espertech.esper.epl.variable包,在下文中一共展示了VariableReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: codegen

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public static CodegenExpression codegen(ExprDotNodeForgeVariable forge, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) {

        CodegenMember variableReader = codegenClassScope.makeAddMember(VariableReader.class, forge.getVariableReader());
        Class variableType;
        VariableMetaData metaData = forge.getVariableReader().getVariableMetaData();
        if (metaData.getEventType() != null) {
            variableType = EventBean.class;
        } else {
            variableType = metaData.getType();
        }
        CodegenMethodNode methodNode = codegenMethodScope.makeChild(forge.getEvaluationType(), ExprDotNodeForgeVariableEval.class, codegenClassScope);


        CodegenBlock block = methodNode.getBlock()
                .declareVar(variableType, "result", cast(variableType, exprDotMethod(member(variableReader.getMemberId()), "getValue")));
        CodegenExpression chain = ExprDotNodeUtility.evaluateChainCodegen(methodNode, exprSymbol, codegenClassScope, ref("result"), variableType, forge.getChainForge(), forge.getResultWrapLambda());
        block.methodReturn(chain);
        return localMethod(methodNode);
    }
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:20,代碼來源:ExprDotNodeForgeVariableEval.java

示例2: getCheckMetadataVariable

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
private static MethodMetadataDesc getCheckMetadataVariable(String methodName, VariableMetaData variableMetaData, VariableReader variableReader, EngineImportService engineImportService, Class metadataClass)
        throws ExprValidationException {
    Method typeGetterMethod = getRequiredTypeGetterMethodCanNonStatic(methodName, null, variableMetaData.getType(), engineImportService, metadataClass);

    if (Modifier.isStatic(typeGetterMethod.getModifiers())) {
        return invokeMetadataMethod(null, variableMetaData.getClass().getSimpleName(), typeGetterMethod);
    }

    // if the metadata is not a static method and we don't have an instance this is a problem
    String messagePrefix = "Failed to access variable method invocation metadata: ";
    if (variableReader == null) {
        throw new ExprValidationException(messagePrefix + "The metadata method is an instance method however the variable is contextual, please declare the metadata method as static or remove the context declaration for the variable");
    }

    Object value = variableReader.getValue();
    if (value == null) {
        throw new ExprValidationException(messagePrefix + "The variable value is null and the metadata method is an instance method");
    }

    if (value instanceof EventBean) {
        value = ((EventBean) value).getUnderlying();
    }
    return invokeMetadataMethod(value, variableMetaData.getClass().getSimpleName(), typeGetterMethod);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:25,代碼來源:MethodPollingViewableFactory.java

示例3: poll

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public List<EventBean> poll(Object[] lookupValues, ExprEvaluatorContext exprEvaluatorContext) {
    switch (strategy) {
        case TARGET_CONST:
            return invokeInternal(lookupValues, invocationTarget);
        case TARGET_VAR:
            return invokeInternalVariable(lookupValues, variableReader);
        case TARGET_VAR_CONTEXT:
            VariableReader reader = variableService.getReader(variableName, exprEvaluatorContext.getAgentInstanceId());
            if (reader == null) {
                return null;
            }
            return invokeInternalVariable(lookupValues, reader);
        default:
            throw new UnsupportedOperationException("unrecognized strategy " + strategy);
    }
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:17,代碼來源:MethodPollingExecStrategyBase.java

示例4: removeVariable

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public boolean removeVariable(String name, boolean force) throws ConfigurationException {
    if (!force) {
        Set<String> statements = statementVariableRef.getStatementNamesForVar(name);
        if ((statements != null) && (!statements.isEmpty())) {
            throw new ConfigurationException("Variable '" + name + "' is in use by one or more statements");
        }
    }

    VariableReader reader = variableService.getReader(name, EPStatementStartMethod.DEFAULT_AGENT_INSTANCE_ID);
    if (reader == null) {
        return false;
    }

    variableService.removeVariableIfFound(name);
    statementVariableRef.removeReferencesVariable(name);
    statementVariableRef.removeConfiguredVariable(name);
    return true;
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:19,代碼來源:ConfigurationOperationsImpl.java

示例5: getVariableValue

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public Object getVariableValue(String variableName) throws EPException {
    services.getVariableService().setLocalVersion();
    VariableMetaData metaData = services.getVariableService().getVariableMetaData(variableName);
    if (metaData == null) {
        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, EPStatementStartMethod.DEFAULT_AGENT_INSTANCE_ID);
    Object value = reader.getValue();
    if (value == null || reader.getVariableMetaData().getEventType() == null) {
        return value;
    }
    return ((EventBean) value).getUnderlying();
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:17,代碼來源:EPRuntimeImpl.java

示例6: removeVariable

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public boolean removeVariable(String name, boolean force) throws ConfigurationException
{
    if (!force) {
        Set<String> statements = statementVariableRef.getStatementNamesForVar(name);
        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;
    }

    variableService.removeVariable(name);
    statementVariableRef.removeReferencesVariable(name);
    statementVariableRef.removeConfiguredVariable(name);
    return true;
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:21,代碼來源:ConfigurationOperationsImpl.java

示例7: setVariableValue

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public void setVariableValue(String variableName, Object variableValue) throws EPException
{
    VariableReader reader = services.getVariableService().getReader(variableName);
    if (reader == null) {
        throw new VariableNotFoundException("Variable by name '" + variableName + "' has not been declared");
    }
    if (reader.isConstant()) {
        throw new VariableConstantValueException("Variable by name '" + variableName + "' is declared as constant and may not be assigned a new value");
    }

    services.getVariableService().getReadWriteLock().writeLock().lock();
    try {
        services.getVariableService().checkAndWrite(reader.getVariableNumber(), variableValue);
        services.getVariableService().commit();
    }
    finally {
        services.getVariableService().getReadWriteLock().writeLock().unlock();
    }
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:20,代碼來源:EPRuntimeImpl.java

示例8: getVariableValue

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public Map<String, Object> getVariableValue(Set<String> variableNames) throws EPException
{
    services.getVariableService().setLocalVersion();
    Map<String, Object> values = new HashMap<String, Object>();
    for (String variableName : variableNames)
    {
        VariableReader reader = services.getVariableService().getReader(variableName);
        if (reader == null)
        {
            throw new VariableNotFoundException("Variable by name '" + variableName + "' has not been declared");
        }

        Object value = reader.getValue();
        if (value != null && reader.getEventType() != null) {
            value = ((EventBean) value).getUnderlying();
        }
        values.put(variableName, value);
    }
    return values;
}
 
開發者ID:mobile-event-processing,項目名稱:Asper,代碼行數:21,代碼來源:EPRuntimeImpl.java

示例9: make

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public OutputCondition make(AgentInstanceContext agentInstanceContext, OutputCallback outputCallback) {
    VariableReader variableReader = null;
    if (variableMetaData != null) {
        variableReader = agentInstanceContext.getStatementContext().getVariableService().getReader(variableMetaData.getVariableName(), agentInstanceContext.getAgentInstanceId());
    }
    return new OutputConditionCount(outputCallback, eventRate, variableReader);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:8,代碼來源:OutputConditionCountFactory.java

示例10: evaluate

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
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;
    }

    EventBean theEvent = (EventBean) value;
    if (optSubPropName == null) {
        if (InstrumentationHelper.ENABLED) {
            InstrumentationHelper.get().aExprVariable(theEvent.getUnderlying());
        }
        return theEvent.getUnderlying();
    }
    Object result = eventTypeGetter.get(theEvent);
    if (InstrumentationHelper.ENABLED) {
        InstrumentationHelper.get().aExprVariable(result);
    }
    return result;
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:33,代碼來源:ExprVariableNodeImpl.java

示例11: evaluateCodegen

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) {
    CodegenMethodNode methodNode = codegenMethodScope.makeChild(variableType, ExprVariableNodeImpl.class, codegenClassScope);
    CodegenExpressionRef refExprEvalCtx = exprSymbol.getAddExprEvalCtx(methodNode);

    CodegenExpression readerExpression;
    if (readerNonCP != null) {
        CodegenMember memberVariableReader = codegenClassScope.makeAddMember(VariableReader.class, readerNonCP);
        readerExpression = member(memberVariableReader.getMemberId());
    } else {
        CodegenMember memberReadersPerCp = codegenClassScope.makeAddMember(Map.class, readersPerCp);
        readerExpression = cast(VariableReader.class, exprDotMethod(member(memberReadersPerCp.getMemberId()), "get", exprDotMethod(refExprEvalCtx, "getAgentInstanceId")));
    }

    CodegenBlock block = methodNode.getBlock()
            .declareVar(VariableReader.class, "reader", readerExpression);
    if (isPrimitive) {
        block.declareVar(variableType, "value", cast(variableType, exprDotMethod(ref("reader"), "getValue")))
                .methodReturn(ref("value"));
    } else {
        block.declareVar(Object.class, "value", exprDotMethod(ref("reader"), "getValue"))
                .ifRefNullReturnNull("value")
                .declareVar(EventBean.class, "theEvent", cast(EventBean.class, ref("value")));
        if (optSubPropName == null) {
            block.methodReturn(cast(variableType, exprDotUnderlying(ref("theEvent"))));
        } else {
            block.methodReturn(CodegenLegoCast.castSafeFromObjectType(variableType, eventTypeGetter.eventBeanGetCodegen(ref("theEvent"), methodNode, codegenClassScope)));
        }
    }
    return localMethod(methodNode);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:31,代碼來源:ExprVariableNodeImpl.java

示例12: MethodPollingViewableMeta

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public MethodPollingViewableMeta(Class methodProviderClass, boolean isStaticMethod, Map<String, Object> optionalMapType, LinkedHashMap<String, Object> optionalOaType, Object invocationTarget, MethodPollingExecStrategyEnum strategy, boolean isCollection, boolean isIterator, VariableReader variableReader, String variableName, EventType eventTypeEventBeanArray, ExprNodeScript scriptExpression) {
    this.methodProviderClass = methodProviderClass;
    this.isStaticMethod = isStaticMethod;
    this.optionalMapType = optionalMapType;
    this.optionalOaType = optionalOaType;
    this.invocationTarget = invocationTarget;
    this.strategy = strategy;
    this.isCollection = isCollection;
    this.isIterator = isIterator;
    this.variableReader = variableReader;
    this.variableName = variableName;
    this.eventTypeEventBeanArray = eventTypeEventBeanArray;
    this.scriptExpression = scriptExpression;
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:15,代碼來源:MethodPollingViewableMeta.java

示例13: MethodPollingExecStrategyBase

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public MethodPollingExecStrategyBase(EventAdapterService eventAdapterService, FastMethod method, EventType eventType, Object invocationTarget, MethodPollingExecStrategyEnum strategy, VariableReader variableReader, String variableName, VariableService variableService) {
    this.eventAdapterService = eventAdapterService;
    this.method = method;
    this.eventType = eventType;
    this.invocationTarget = invocationTarget;
    this.strategy = strategy;
    this.variableReader = variableReader;
    this.variableName = variableName;
    this.variableService = variableService;
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:11,代碼來源:MethodPollingExecStrategyBase.java

示例14: invokeInternalVariable

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
private List<EventBean> invokeInternalVariable(Object[] lookupValues, VariableReader variableReader) {
    Object target = variableReader.getValue();
    if (target == null) {
        return null;
    }
    if (target instanceof EventBean) {
        target = ((EventBean) target).getUnderlying();
    }
    return invokeInternal(lookupValues, target);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:11,代碼來源:MethodPollingExecStrategyBase.java

示例15: instantiate

import com.espertech.esper.epl.variable.VariableReader; //導入依賴的package包/類
public RowLimitProcessor instantiate(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 RowLimitProcessor(numRowsVariableReader, offsetVariableReader,
            currentRowLimit, currentOffset);
}
 
開發者ID:espertechinc,項目名稱:esper,代碼行數:15,代碼來源:RowLimitProcessorFactory.java


注:本文中的com.espertech.esper.epl.variable.VariableReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。