当前位置: 首页>>代码示例>>Java>>正文


Java SimpleNumberCoercerFactory类代码示例

本文整理汇总了Java中com.espertech.esper.util.SimpleNumberCoercerFactory的典型用法代码示例。如果您正苦于以下问题:Java SimpleNumberCoercerFactory类的具体用法?Java SimpleNumberCoercerFactory怎么用?Java SimpleNumberCoercerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleNumberCoercerFactory类属于com.espertech.esper.util包,在下文中一共展示了SimpleNumberCoercerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBeanFirstLastIndexCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
private static CodegenMethodNode getBeanFirstLastIndexCodegen(AggregationAccessorFirstLastIndexWEvalForge forge, int column, CodegenClassScope classScope, AggregationStateLinearForge stateForge, CodegenMethodNode parent, CodegenNamedMethods namedMethods) {
    CodegenMethodNode method = parent.makeChild(EventBean.class, AggregationAccessorFirstLastIndexWEval.class, classScope);
    if (forge.getConstant() == -1) {
        Class evalType = forge.getIndexNode().getEvaluationType();
        method.getBlock().declareVar(evalType, "indexResult", localMethod(CodegenLegoMethodExpression.codegenExpression(forge.getIndexNode(), method, classScope), constantNull(), constantTrue(), constantNull()));
        if (!evalType.isPrimitive()) {
            method.getBlock().ifRefNullReturnNull("indexResult");
        }
        method.getBlock().declareVar(int.class, "index", SimpleNumberCoercerFactory.SimpleNumberCoercerInt.codegenInt(ref("indexResult"), evalType));
    } else {
        method.getBlock().declareVar(int.class, "index", constant(forge.getConstant()));
    }
    CodegenExpression value = forge.isFirst() ? stateForge.getFirstNthValueCodegen(ref("index"), column, method, classScope, namedMethods) : stateForge.getLastNthValueCodegen(ref("index"), column, method, classScope, namedMethods);
    method.getBlock().methodReturn(value);
    return method;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:17,代码来源:AggregationAccessorFirstLastIndexWEval.java

示例2: applyEnterCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public static void applyEnterCodegen(AggregationMethodFactoryRate forge, int column, CodegenMethodNode method, ExprForgeCodegenSymbol symbols, ExprForge[] forges, CodegenClassScope classScope) {
    int numFilters = forge.getParent().getOptionalFilter() != null ? 1 : 0;
    if (numFilters == 1) {
        AggregatorCodegenUtil.prefixWithFilterCheck(forge.getParent().getOptionalFilter().getForge(), method, symbols, classScope);
    }

    CodegenExpressionRef accumulator = refCol("accumulator", column);
    CodegenExpressionRef latest = refCol("latest", column);

    Class firstType = forges[0].getEvaluationType();
    CodegenExpression firstExpr = forges[0].evaluateCodegen(long.class, method, symbols, classScope);
    method.getBlock().assignRef(latest, SimpleNumberCoercerFactory.SimpleNumberCoercerLong.codegenLong(firstExpr, firstType));

    if (forges.length == numFilters + 1) {
        method.getBlock().increment(accumulator);
    } else {
        Class secondType = forges[1].getEvaluationType();
        CodegenExpression secondExpr = forges[1].evaluateCodegen(double.class, method, symbols, classScope);
        method.getBlock().assignCompound(accumulator, "+", SimpleNumberCoercerFactory.SimpleNumberCoercerDouble.codegenDouble(secondExpr, secondType));
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:22,代码来源:AggregatorRate.java

示例3: applyLeaveCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public static void applyLeaveCodegen(AggregationMethodFactoryRate forge, int column, CodegenMethodNode method, ExprForgeCodegenSymbol symbols, ExprForge[] forges, CodegenClassScope classScope) {
    int numFilters = forge.getParent().getOptionalFilter() != null ? 1 : 0;
    if (numFilters == 1) {
        AggregatorCodegenUtil.prefixWithFilterCheck(forge.getParent().getOptionalFilter().getForge(), method, symbols, classScope);
    }

    CodegenExpressionRef accumulator = refCol("accumulator", column);
    CodegenExpressionRef oldest = refCol("oldest", column);
    CodegenExpressionRef isSet = refCol("isSet", column);

    Class firstType = forges[0].getEvaluationType();
    CodegenExpression firstExpr = forges[0].evaluateCodegen(long.class, method, symbols, classScope);

    method.getBlock().assignRef(oldest, SimpleNumberCoercerFactory.SimpleNumberCoercerLong.codegenLong(firstExpr, firstType))
            .ifCondition(not(isSet)).assignRef(isSet, constantTrue());
    if (forges.length == numFilters + 1) {
        method.getBlock().decrement(accumulator);
    } else {
        Class secondType = forges[1].getEvaluationType();
        CodegenExpression secondExpr = forges[1].evaluateCodegen(double.class, method, symbols, classScope);
        method.getBlock().assignCompound(accumulator, "-", SimpleNumberCoercerFactory.SimpleNumberCoercerDouble.codegenDouble(secondExpr, secondType));
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:24,代码来源:AggregatorRate.java

示例4: applyEnterCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public static void applyEnterCodegen(boolean distinct, boolean hasFilter, int column, CodegenMethodNode method, ExprForgeCodegenSymbol symbols, ExprForge[] forges, CodegenClassScope classScope) {
    CodegenExpressionTypePair value = AggregatorCodegenUtil.prefixWithFilterNullDistinctChecks(true, distinct, hasFilter, forges, column, method, symbols, classScope);

    CodegenExpressionRef mean = refCol("mean", column);
    CodegenExpressionRef qn = refCol("qn", column);
    CodegenExpressionRef cnt = refCol("cnt", column);

    method.getBlock().declareVar(double.class, "p", SimpleNumberCoercerFactory.SimpleNumberCoercerDouble.codegenDouble(value.getExpression(), value.getType()))
            .ifCondition(equalsIdentity(cnt, constant(0)))
            .assignRef(mean, ref("p"))
            .assignRef(qn, constant(0))
            .assignRef(cnt, constant(1))
            .ifElse()
            .increment(cnt)
            .declareVar(double.class, "oldmean", mean)
            .assignCompound(mean, "+", op(op(ref("p"), "-", mean), "/", cnt))
            .assignCompound(qn, "+", op(op(ref("p"), "-", ref("oldmean")), "*", op(ref("p"), "-", mean)));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:19,代码来源:AggregatorStddev.java

示例5: applyLeaveCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public static void applyLeaveCodegen(boolean distinct, boolean hasFilter, int column, CodegenMethodNode method, ExprForgeCodegenSymbol symbols, ExprForge[] forges, CodegenClassScope classScope) {
    CodegenExpressionTypePair value = AggregatorCodegenUtil.prefixWithFilterNullDistinctChecks(false, distinct, hasFilter, forges, column, method, symbols, classScope);

    CodegenExpressionRef mean = refCol("mean", column);
    CodegenExpressionRef qn = refCol("qn", column);
    CodegenExpressionRef cnt = refCol("cnt", column);

    Consumer<CodegenBlock> clear = block -> {
        block.assignRef(mean, constant(0))
                .assignRef(qn, constant(0))
                .assignRef(cnt, constant(0));
    };

    method.getBlock().declareVar(double.class, "p", SimpleNumberCoercerFactory.SimpleNumberCoercerDouble.codegenDouble(value.getExpression(), value.getType()))
            .ifCondition(relational(cnt, LE, constant(1)))
            .apply(clear)
            .ifElse()
            .decrement(cnt)
            .declareVar(double.class, "oldmean", mean)
            .assignCompound(mean, "-", op(op(ref("p"), "-", mean), "/", cnt))
            .assignCompound(qn, "-", op(op(ref("p"), "-", ref("oldmean")), "*", op(ref("p"), "-", mean)));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:AggregatorStddev.java

示例6: evaluateAsSecondsCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public CodegenExpression evaluateAsSecondsCodegen(CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) {
    CodegenMethodNode methodNode = codegenMethodScope.makeChild(double.class, ExprTimePeriodForge.class, codegenClassScope);

    CodegenBlock block = methodNode.getBlock()
            .declareVar(double.class, "seconds", constant(0))
            .declareVarNoInit(Double.class, "result");
    for (int i = 0; i < parent.getChildNodes().length; i++) {
        ExprForge forge = parent.getChildNodes()[i].getForge();
        Class evaluationType = forge.getEvaluationType();
        block.assignRef("result", SimpleNumberCoercerFactory.SimpleNumberCoercerDouble.codegenDoubleMayNullBoxedIncludeBig(forge.evaluateCodegen(evaluationType, methodNode, exprSymbol, codegenClassScope), evaluationType, methodNode, codegenClassScope));
        block.ifRefNull("result").blockThrow(staticMethod(ExprTimePeriodForge.class, "makeTimePeriodParamNullException", constant(ExprNodeUtilityCore.toExpressionStringMinPrecedenceSafe(this.parent))));
        block.assignRef("seconds", op(ref("seconds"), "+", adders[i].computeCodegen(ref("result"))));
    }
    block.methodReturn(ref("seconds"));
    return localMethod(methodNode);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:17,代码来源:ExprTimePeriodForge.java

示例7: getCoercer

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
private static SimpleNumberCoercer getCoercer(Class typeOne, Class typeTwo) throws ExprValidationException {
    // Get the common type such as Bool, String or Double and Long
    Class coercionType;
    boolean mustCoerce;
    try {
        coercionType = JavaClassHelper.getCompareToCoercionType(typeOne, typeTwo);
    } catch (CoercionException ex) {
        throw new ExprValidationException("Implicit conversion from datatype '" +
                typeTwo.getSimpleName() +
                "' to '" +
                typeOne.getSimpleName() +
                "' is not allowed");
    }

    // Check if we need to coerce
    mustCoerce = false;
    if ((coercionType != JavaClassHelper.getBoxedType(typeOne)) ||
            (coercionType != JavaClassHelper.getBoxedType(typeTwo))) {
        if (JavaClassHelper.isNumeric(coercionType)) {
            mustCoerce = true;
        }
    }
    return !mustCoerce ? null : SimpleNumberCoercerFactory.getCoercer(null, coercionType);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:25,代码来源:SubselectEvalStrategyNRFactory.java

示例8: evaluateCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) {
    ExprForge valueLower = this.getChildNodes()[0].getForge();
    ExprForge valueUpper = this.getChildNodes()[1].getForge();
    CodegenMethodNode methodNode = codegenMethodScope.makeChild(RangeParameter.class, ExprNumberSetRange.class, codegenClassScope);
    CodegenBlock block = methodNode.getBlock()
            .declareVar(valueLower.getEvaluationType(), "valueLower", valueLower.evaluateCodegen(requiredType, methodNode, exprSymbol, codegenClassScope))
            .declareVar(valueUpper.getEvaluationType(), "valueUpper", valueUpper.evaluateCodegen(requiredType, methodNode, exprSymbol, codegenClassScope));
    if (!valueLower.getEvaluationType().isPrimitive()) {
        block.ifRefNull("valueLower")
                .staticMethod(ExprNumberSetRange.class, METHOD_HANDLENUMBERSETRANGELOWERNULL)
                .assignRef("valueLower", constant(0))
                .blockEnd();

    }
    if (!valueUpper.getEvaluationType().isPrimitive()) {
        block.ifRefNull("valueUpper")
                .staticMethod(ExprNumberSetRange.class, METHOD_HANDLENUMBERSETRANGEUPPERNULL)
                .assignRef("valueUpper", enumValue(Integer.class, "MAX_VALUE"))
                .blockEnd();
    }
    block.methodReturn(newInstance(RangeParameter.class,
            SimpleNumberCoercerFactory.SimpleNumberCoercerInt.codegenInt(ref("valueLower"), valueLower.getEvaluationType()),
            SimpleNumberCoercerFactory.SimpleNumberCoercerInt.codegenInt(ref("valueUpper"), valueUpper.getEvaluationType())
    ));
    return localMethod(methodNode);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:27,代码来源:ExprNumberSetRange.java

示例9: evaluateCodegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) {
    CodegenExpression enumValue = enumValue(CronOperatorEnum.class, cronOperator.name());
    CodegenExpression defaultValue = newInstance(CronParameter.class, enumValue, constantNull());
    if (this.getChildNodes().length == 0) {
        return defaultValue;
    }
    ExprForge forge = this.getChildNodes()[0].getForge();
    Class evaluationType = forge.getEvaluationType();
    CodegenMethodNode methodNode = codegenMethodScope.makeChild(CronParameter.class, ExprNumberSetCronParam.class, codegenClassScope);

    CodegenBlock block = methodNode.getBlock()
            .declareVar(evaluationType, "value", forge.evaluateCodegen(requiredType, methodNode, exprSymbol, codegenClassScope));
    if (!evaluationType.isPrimitive()) {
        block.ifRefNull("value")
                .staticMethod(ExprNumberSetCronParam.class, METHOD_HANDLENUMBERSETCRONPARAMNULLVALUE)
                .blockReturn(defaultValue);
    }
    block.methodReturn(newInstance(CronParameter.class, enumValue, SimpleNumberCoercerFactory.SimpleNumberCoercerInt.codegenInt(ref("value"), evaluationType)));
    return localMethod(methodNode);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:21,代码来源:ExprNumberSetCronParam.java

示例10: codegen

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
public static CodegenExpression codegen(EnumAverageEventsForge forge, EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
    Class innerType = forge.innerExpression.getEvaluationType();

    ExprForgeCodegenSymbol scope = new ExprForgeCodegenSymbol(false, null);
    CodegenMethodNode methodNode = codegenMethodScope.makeChildWithScope(Double.class, EnumAverageEventsForgeEval.class, scope, codegenClassScope).addParam(EnumForgeCodegenNames.PARAMS);

    CodegenBlock block = methodNode.getBlock()
            .declareVar(double.class, "sum", constant(0d))
            .declareVar(int.class, "count", constant(0));
    CodegenBlock forEach = block.forEach(EventBean.class, "next", EnumForgeCodegenNames.REF_ENUMCOLL)
            .assignArrayElement(EnumForgeCodegenNames.REF_EPS, constant(forge.streamNumLambda), ref("next"))
            .declareVar(innerType, "num", forge.innerExpression.evaluateCodegen(innerType, methodNode, scope, codegenClassScope));
    if (!innerType.isPrimitive()) {
        forEach.ifRefNull("num").blockContinue();
    }
    forEach.increment("count")
            .assignRef("sum", op(ref("sum"), "+", SimpleNumberCoercerFactory.SimpleNumberCoercerDouble.codegenDouble(ref("num"), innerType)))
            .blockEnd();
    block.ifCondition(equalsIdentity(ref("count"), constant(0))).blockReturn(constantNull())
            .methodReturn(op(ref("sum"), "/", ref("count")));
    return localMethod(methodNode, args.getEps(), args.getEnumcoll(), args.getIsNewData(), args.getExprCtx());
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:EnumAverageEventsForgeEval.java

示例11: makeBigIntegerComputer

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
private Computer makeBigIntegerComputer(Class typeOne, Class typeTwo) {
    if ((typeOne == BigDecimal.class) && (typeTwo == BigDecimal.class)) {
        return computers.get(new MultiKeyUntyped(new Object[]{BigDecimal.class, this}));
    }
    if ((typeOne == BigInteger.class) && (typeTwo == BigInteger.class)) {
        Computer computer = computers.get(new MultiKeyUntyped(new Object[]{BigInteger.class, this}));
        if (computer != null) {
            return computer;
        }
    }
    SimpleNumberBigIntegerCoercer convertorOne = SimpleNumberCoercerFactory.getCoercerBigInteger(typeOne);
    SimpleNumberBigIntegerCoercer convertorTwo = SimpleNumberCoercerFactory.getCoercerBigInteger(typeTwo);
    if (this == ADD) {
        return new AddBigIntConvComputer(convertorOne, convertorTwo);
    }
    if (this == SUBTRACT) {
        return new SubtractBigIntConvComputer(convertorOne, convertorTwo);
    }
    if (this == MULTIPLY) {
        return new MultiplyBigIntConvComputer(convertorOne, convertorTwo);
    }
    if (this == DIVIDE) {
        return new DivideBigIntConvComputer(convertorOne, convertorTwo);
    }
    return new ModuloLong();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:27,代码来源:MathArithTypeEnum.java

示例12: SubselectEvalStrategyEqualsAny

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
/**
 * Ctor.
 * @param notIn false for =, true for !=
 * @param mustCoerce coercion required
 * @param coercionType type to coerce to
 * @param valueExpr LHS
 * @param selectClauseExpr select clause or null
 * @param filterExpr filter or null
 */
public SubselectEvalStrategyEqualsAny(boolean notIn, boolean mustCoerce, Class coercionType, ExprEvaluator valueExpr, ExprEvaluator selectClauseExpr, ExprEvaluator filterExpr)
{
    isNot = notIn;
    this.mustCoerce = mustCoerce;
    if (mustCoerce)
    {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    }
    else
    {
        coercer = null;
    }
    this.valueExpr = valueExpr;
    this.filterExpr = filterExpr;
    this.selectClauseExpr = selectClauseExpr;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:26,代码来源:SubselectEvalStrategyEqualsAny.java

示例13: SubselectEvalStrategyEqualsIn

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
/**
 * Ctor.
 * @param notIn false for =, true for !=
 * @param mustCoerce coercion required
 * @param coercionType type to coerce to
 * @param valueExpr LHS
 * @param selectClauseExpr select clause or null
 * @param filterExpr filter or null
 */
public SubselectEvalStrategyEqualsIn(boolean notIn, boolean mustCoerce, Class coercionType, ExprEvaluator valueExpr, ExprEvaluator selectClauseExpr, ExprEvaluator filterExpr)
{
    isNotIn = notIn;
    this.mustCoerce = mustCoerce;
    if (mustCoerce)
    {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    }
    else
    {
        coercer = null;
    }
    this.valueExpr = valueExpr;
    this.filterExpr = filterExpr;
    this.selectClauseExpr = selectClauseExpr;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:26,代码来源:SubselectEvalStrategyEqualsIn.java

示例14: SubselectEvalStrategyEqualsAll

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
/**
 * Ctor.
 * @param notIn false for =, true for !=
 * @param mustCoerce coercion required
 * @param coercionType type to coerce to
 * @param valueExpr LHS
 * @param selectClauseExpr select clause or null
 * @param filterExpr filter or null
 */
public SubselectEvalStrategyEqualsAll(boolean notIn, boolean mustCoerce, Class coercionType, ExprEvaluator valueExpr, ExprEvaluator selectClauseExpr, ExprEvaluator filterExpr)
{
    isNot = notIn;
    this.mustCoerce = mustCoerce;
    if (mustCoerce)
    {
        coercer = SimpleNumberCoercerFactory.getCoercer(null, coercionType);
    }
    else
    {
        coercer = null;
    }
    this.valueExpr = valueExpr;
    this.filterExpr = filterExpr;
    this.selectClauseExpr = selectClauseExpr;
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:26,代码来源:SubselectEvalStrategyEqualsAll.java

示例15: makeBigIntegerComputer

import com.espertech.esper.util.SimpleNumberCoercerFactory; //导入依赖的package包/类
private Computer makeBigIntegerComputer(Class typeOne, Class typeTwo)
{
    if ((typeOne == BigDecimal.class) && (typeTwo == BigDecimal.class))
    {
        return computers.get(new MultiKeyUntyped(new Object[] {BigDecimal.class, this}));
    }
    SimpleNumberBigIntegerCoercer convertorOne = SimpleNumberCoercerFactory.getCoercerBigInteger(typeOne);
    SimpleNumberBigIntegerCoercer convertorTwo = SimpleNumberCoercerFactory.getCoercerBigInteger(typeTwo);
    if (this == ADD)
    {
        return new AddBigIntConvComputer(convertorOne, convertorTwo);
    }
    if (this == SUBTRACT)
    {
        return new SubtractBigIntConvComputer(convertorOne, convertorTwo);
    }
    if (this == MULTIPLY)
    {
        return new MultiplyBigIntConvComputer(convertorOne, convertorTwo);
    }
    if (this == DIVIDE)
    {
        return new DivideBigIntConvComputer(convertorOne, convertorTwo);
    }
    return new ModuloLong();
}
 
开发者ID:mobile-event-processing,项目名称:Asper,代码行数:27,代码来源:MathArithTypeEnum.java


注:本文中的com.espertech.esper.util.SimpleNumberCoercerFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。