public void rowReadMethodCodegen(CodegenMethod method, int level) { if (level != -1) { method.getBlock().assignRef("row.refcount", exprDotMethod(ref("input"), "readInt")); } }
private CodegenExpression codegenLDTZDT(CodegenExpression val, Class type) { CodegenExpression chronoUnit = enumValue(ChronoUnit.class, fieldName.getChronoUnit().name()); if (code == ApacheCommonsDateUtils.MODIFY_TRUNCATE) { return exprDotMethod(val, "truncatedTo", chronoUnit); } else if (code == ApacheCommonsDateUtils.MODIFY_CEILING) { return exprDotMethodChain(val).add("plus", constant(1), chronoUnit).add("truncatedTo", chronoUnit); } else { throw new EPException("Round-half operation not supported for " + type.getSimpleName()); } } }
protected void readWODistinct(CodegenExpressionRef row, int col, CodegenExpressionRef input, CodegenExpressionRef unitKey, CodegenMethod method, CodegenClassScope classScope) { CodegenExpressionRef state = refCol("state", col); method.getBlock() .declareVar(AggregationNthState.class, state.getRef(), staticMethod(this.getClass(), "read", input, unitKey, serdeValue, constant(factory.getSizeOfBuf()))) .assignRef(rowDotRef(row, circularBuffer), exprDotMethod(state, "getCircularBuffer")) .assignRef(rowDotRef(row, currentBufferElementPointer), exprDotMethod(state, "getCurrentBufferElementPointer")) .assignRef(rowDotRef(row, numDataPoints), exprDotMethod(state, "getNumDataPoints")); }
protected void applyEvalEnterNonNull(CodegenExpressionRef value, Class valueType, CodegenMethod method, ExprForgeCodegenSymbol symbols, ExprForge[] forges, CodegenClassScope classScope) { if (valueType == BigInteger.class) { method.getBlock().assignRef(sum, exprDotMethod(sum, "add", newInstance(BigDecimal.class, value))); } else { method.getBlock().assignRef(sum, exprDotMethod(sum, "add", valueType == BigDecimal.class ? value : cast(BigDecimal.class, value))); } method.getBlock().increment(cnt); }
public void acceptGroupDetailCodegen(CodegenMethod method, CodegenClassScope classScope) { method.getBlock().exprDotMethod(REF_AGGVISITOR, "visitGrouped", getGroupKeyCountCodegen(method, classScope)) .forEach(Map.class, "anAggregatorsPerGroup", REF_AGGREGATORSPERGROUP) .forEach(Map.Entry.class, "entry", exprDotMethod(ref("anAggregatorsPerGroup"), "entrySet")) .exprDotMethod(REF_AGGVISITOR, "visitGroup", exprDotMethod(ref("entry"), "getKey"), exprDotMethod(ref("entry"), "getValue")) .blockEnd() .blockEnd() .exprDotMethod(REF_AGGVISITOR, "visitGroup", publicConstValue(CollectionUtil.class, "OBJECTARRAY_EMPTY"), REF_AGGREGATORTOPGROUP); }
public static CodegenExpression codegen(DTLocalDateIntervalForge forge, CodegenExpression start, CodegenExpression end, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Boolean.class, DTLocalDateIntervalEval.class, codegenClassScope).addParam(Date.class, "start").addParam(Date.class, "end"); methodNode.getBlock().methodReturn(forge.intervalForge.codegen(exprDotMethod(ref("start"), "getTime"), exprDotMethod(ref("end"), "getTime"), methodNode, exprSymbol, codegenClassScope)); return localMethod(methodNode, start, end); } }
public CodegenExpression codegenCal(CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenExpressionField formatField = codegenFormatFieldInit(codegenClassScope); CodegenBlock blockMethod = codegenMethodScope.makeChild(String.class, ReformatFormatForge.class, codegenClassScope).addParam(Calendar.class, "cal").getBlock() .synchronizedOn(formatField) .blockReturn(exprDotMethod(formatField, "format", exprDotMethod(ref("cal"), "getTime"))); return localMethodBuild(blockMethod.methodEnd()).pass(inner).call(); }
public void getGroupKeysCodegen(CodegenMethod method, CodegenClassScope classScope) { if (aggGroupByDesc.isRefcounted()) { method.getBlock().localMethod(handleRemovedKeysCodegen(method, classScope)); } method.getBlock().methodReturn(exprDotMethod(REF_AGGREGATORSPERGROUP, "keySet")); }
public void getValueCodegen(CodegenMethod method, CodegenClassScope classScope) { method.getBlock().ifCondition(not(exprDotMethod(points, "isEmpty"))) .declareVar(long.class, "newest", cast(Long.class, exprDotMethod(points, "getLast"))) .declareVar(boolean.class, "leave", staticMethod(AggregatorRateEver.class, "removeFromHead", points, ref("newest"), constant(factory.getIntervalTime()))) .assignCompound(hasLeave, "|", ref("leave")) .blockEnd() .ifCondition(not(hasLeave)).blockReturn(constantNull()) .ifCondition(exprDotMethod(points, "isEmpty")).blockReturn(constant(0d)) .methodReturn(op(op(op(exprDotMethod(points, "size"), "*", constant(factory.getTimeAbacus().getOneSecond())), "*", constant(1d)), "/", constant(factory.getIntervalTime()))); }
public CodegenExpression codegenLong(CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope classScope) { CodegenExpressionField formatField = codegenFormatFieldInit(classScope); CodegenBlock blockMethod = codegenMethodScope.makeChild(String.class, ReformatFormatForge.class, classScope).addParam(long.class, "ts").getBlock(); CodegenBlock syncBlock = blockMethod.synchronizedOn(formatField); if (timeAbacus.getOneSecond() == 1000L) { syncBlock.blockReturn(exprDotMethod(formatField, "format", ref("ts"))); } else { syncBlock.blockReturn(exprDotMethod(formatField, "format", timeAbacus.toDateCodegen(ref("ts")))); } return localMethodBuild(blockMethod.methodEnd()).pass(inner).call(); }
public static CodegenExpression codegenCal(ReformatBetweenNonConstantParamsForge forge, CodegenExpression inner, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Boolean.class, ReformatBetweenNonConstantParamsForgeOp.class, codegenClassScope).addParam(Calendar.class, "cal"); methodNode.getBlock() .ifRefNullReturnNull("cal") .methodReturn(codegenLongInternal(forge, exprDotMethod(ref("cal"), "getTimeInMillis"), methodNode, exprSymbol, codegenClassScope)); return localMethod(methodNode, inner); }
private void applyTableValuePrefix(boolean enter, CodegenExpressionRef value, CodegenMethod method, CodegenClassScope classScope) { method.getBlock().ifCondition(equalsNull(value)).blockReturnNoValue(); if (distinct != null) { method.getBlock().ifCondition(not(exprDotMethod(distinct, enter ? "add" : "remove", value))).blockReturnNoValue(); } } }
private void applyEvalValuePrefix(boolean enter, CodegenMethod method, ExprForgeCodegenSymbol symbols, ExprForge[] forges, CodegenClassScope classScope) { Class type = forges[0].getEvaluationType(); CodegenExpression expr = forges[0].evaluateCodegen(type, method, symbols, classScope); method.getBlock().declareVar(type, "val", expr); if (!type.isPrimitive()) { method.getBlock().ifRefNull("val").blockReturnNoValue(); } if (distinct != null) { method.getBlock().ifCondition(not(exprDotMethod(distinct, enter ? "add" : "remove", ref("val")))).blockReturnNoValue(); } }
public CodegenExpression evaluateCodegenUninstrumented(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(getEvaluationType(), ExprContextPropertyNodeImpl.class, codegenClassScope); CodegenExpressionRef refExprEvalCtx = exprSymbol.getAddExprEvalCtx(methodNode); CodegenBlock block = methodNode.getBlock() .declareVar(EventBean.class, "props", exprDotMethod(refExprEvalCtx, "getContextProperties")) .ifRefNullReturnNull("props"); block.methodReturn(CodegenLegoCast.castSafeFromObjectType(returnType, getter.eventBeanGetCodegen(ref("props"), methodNode, codegenClassScope))); return localMethod(methodNode); }
public CodegenExpression evaluateCodegenUninstrumented(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(eventType.getUnderlyingType(), ExprStreamUnderlyingNodeImpl.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamNum))) .ifRefNullReturnNull("event") .methodReturn(cast(eventType.getUnderlyingType(), exprDotMethod(ref("event"), "getUnderlying"))); return localMethod(methodNode); }
public CodegenExpression getFirstNthValueCodegen(CodegenExpressionRef index, CodegenMethod parentMethod, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { CodegenMethod initArray = initArrayCodegen(namedMethods, classScope); CodegenMethod method = parentMethod.makeChildWithScope(EventBean.class, AggregatorAccessLinearJoin.class, CodegenSymbolProviderEmpty.INSTANCE, classScope).addParam(int.class, "index"); method.getBlock().ifCondition(relational(ref("index"), LT, constant(0))).blockReturn(constantNull()) .ifCondition(exprDotMethod(refSet, "isEmpty")).blockReturn(constantNull()) .ifCondition(relational(ref("index"), GE, exprDotMethod(refSet, "size"))).blockReturn(constantNull()) .ifCondition(equalsNull(array)).localMethod(initArray).blockEnd() .methodReturn(arrayAtIndex(array, ref("index"))); return localMethod(method, index); }
private CodegenExpression getGroupKeyCountCodegen(CodegenMethodScope parent, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(int.class, AggSvcGroupByRollupForge.class, classScope); method.getBlock().declareVar(int.class, "size", constant(1)); for (int i = 0; i < rollupDesc.getNumLevelsAggregation(); i++) { method.getBlock().assignCompound("size", "+", exprDotMethod(arrayAtIndex(REF_AGGREGATORSPERGROUP, constant(i)), "size")); } method.getBlock().methodReturn(ref("size")); return localMethod(method); }
public static CodegenExpression codegen(IntervalOpDateForge forge, CodegenExpression start, CodegenExpression end, CodegenExpression parameter, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Boolean.class, IntervalOpDateEval.class, codegenClassScope).addParam(long.class, "startTs").addParam(long.class, "endTs").addParam(Date.class, "parameter"); methodNode.getBlock() .declareVar(long.class, "time", exprDotMethod(ref("parameter"), "getTime")) .methodReturn(forge.intervalComputer.codegen(ref("startTs"), ref("endTs"), ref("time"), ref("time"), methodNode, exprSymbol, codegenClassScope)); return localMethod(methodNode, start, end, parameter); } }
public static CodegenExpression codegen(IntervalOpCalForge forge, CodegenExpression start, CodegenExpression end, CodegenExpression parameter, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Boolean.class, IntervalOpDateEval.class, codegenClassScope) .addParam(long.class, "startTs").addParam(long.class, "endTs").addParam(Calendar.class, "parameter"); methodNode.getBlock() .declareVar(long.class, "time", exprDotMethod(ref("parameter"), "getTimeInMillis")) .methodReturn(forge.intervalComputer.codegen(ref("startTs"), ref("endTs"), ref("time"), ref("time"), methodNode, exprSymbol, codegenClassScope)); return localMethod(methodNode, start, end, parameter); } }
public static CodegenExpression codegenLDT(CalendarSetForge forge, CodegenExpression ldt, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { ChronoField chronoField = forge.fieldName.getChronoField(); CodegenMethod methodNode = codegenMethodScope.makeChild(LocalDateTime.class, CalendarSetForgeOp.class, codegenClassScope).addParam(LocalDateTime.class, "ldt"); Class evaluationType = forge.valueExpr.getEvaluationType(); methodNode.getBlock() .declareVar(Integer.class, "value", SimpleNumberCoercerFactory.SimpleNumberCoercerInt.coerceCodegenMayNull(forge.valueExpr.evaluateCodegen(evaluationType, methodNode, exprSymbol, codegenClassScope), evaluationType, methodNode, codegenClassScope)) .ifRefNull("value").blockReturn(ref("ldt")) .methodReturn(exprDotMethod(ref("ldt"), "with", enumValue(ChronoField.class, chronoField.name()), ref("value"))); return localMethod(methodNode, ldt); }