public SAIFFInitializeBuilder constant(String name, Object value) { if (value instanceof CodegenExpression) { throw new IllegalArgumentException("Expected a non-expression value, received " + value); } return setValue(name, value == null ? constantNull() : CodegenExpressionBuilder.constant(value)); }
protected void inlineInitializeOnTriggerSpecific(CodegenExpressionRef saiff, CodegenMethod method, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { method.getBlock() .exprDotMethod(saiff, "setResultSetProcessorFactoryProvider", CodegenExpressionBuilder.newInstance(resultSetProcessorProviderClassName, symbols.getAddInitSvc(method))) .exprDotMethod(saiff, "setInsertInto", constant(insertInto)) .exprDotMethod(saiff, "setAddToFront", constant(addToFront)) .exprDotMethod(saiff, "setSelectAndDelete", constant(selectAndDelete)) .exprDotMethod(saiff, "setDistinct", constant(distinct)) .exprDotMethod(saiff, "setOptionalInsertIntoTable", optionalInsertIntoTable == null ? constantNull() : TableDeployTimeResolver.makeResolveTable(optionalInsertIntoTable, symbols.getAddInitSvc(method))); } }
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 static CodegenExpression codegenCalendar(CalendarPlusMinusForge forge, CodegenExpression cal, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { Class evaluationType = forge.param.getEvaluationType(); if (JavaClassHelper.isNumeric(evaluationType)) { CodegenExpression longDuration = SimpleNumberCoercerFactory.SimpleNumberCoercerLong.codegenLong(forge.param.evaluateCodegen(evaluationType, codegenMethodScope, exprSymbol, codegenClassScope), evaluationType); return staticMethod(CalendarPlusMinusForgeOp.class, "actionCalendarPlusMinusNumber", cal, constant(forge.factor), longDuration); } return staticMethod(CalendarPlusMinusForgeOp.class, "actionCalendarPlusMinusTimePeriod", cal, constant(forge.factor), forge.param.evaluateCodegen(evaluationType, codegenMethodScope, exprSymbol, codegenClassScope)); }
public static void getValueCodegen(AggregationAccessorFirstWEvalForge forge, AggregationStateLinearForge accessStateFactory, AggregationAccessorForgeGetCodegenContext context) { CodegenMethod childExpr = CodegenLegoMethodExpression.codegenExpression(forge.getChildNode(), context.getMethod(), context.getClassScope()); context.getMethod().getBlock().declareVar(EventBean.class, "bean", accessStateFactory.getAggregatorLinear().getFirstValueCodegen(context.getClassScope(), context.getMethod())) .ifRefNullReturnNull("bean") .declareVar(EventBean[].class, "eventsPerStreamBuf", newArrayByLength(EventBean.class, constant(forge.getStreamNum() + 1))) .assignArrayElement("eventsPerStreamBuf", constant(forge.getStreamNum()), ref("bean")) .methodReturn(localMethod(childExpr, ref("eventsPerStreamBuf"), constant(true), constantNull())); }
public static CodegenExpression codegenZDT(CalendarPlusMinusForge forge, CodegenExpression zdt, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { Class evaluationType = forge.param.getEvaluationType(); if (JavaClassHelper.isNumeric(evaluationType)) { CodegenExpression longDuration = SimpleNumberCoercerFactory.SimpleNumberCoercerLong.codegenLongMayNullBox(forge.param.evaluateCodegen(evaluationType, codegenMethodScope, exprSymbol, codegenClassScope), evaluationType, codegenMethodScope, codegenClassScope); return staticMethod(CalendarPlusMinusForgeOp.class, "actionZDTPlusMinusNumber", zdt, constant(forge.factor), longDuration); } return staticMethod(CalendarPlusMinusForgeOp.class, "actionZDTPlusMinusTimePeriod", zdt, constant(forge.factor), forge.param.evaluateCodegen(evaluationType, codegenMethodScope, exprSymbol, codegenClassScope)); }
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); }
protected final void applyTableLeaveNonNull(CodegenExpressionRef value, Class[] evaluationTypes, CodegenMethod method, CodegenClassScope classScope) { method.getBlock() .ifCondition(relational(cnt, LE, constant(1))) .assignRef(cnt, constant(0)) .assignRef(sum, initOfSum()) .blockReturnNoValue() .decrement(cnt); applyTableLeaveSum(value, evaluationTypes, method, classScope); }
public static void getEnumerableScalarCodegen(AggregationAccessorFirstWEvalForge forge, AggregationStateLinearForge accessStateFactory, AggregationAccessorForgeGetCodegenContext context) { CodegenMethod childExpr = CodegenLegoMethodExpression.codegenExpression(forge.getChildNode(), context.getMethod(), context.getClassScope()); context.getMethod().getBlock().declareVar(EventBean.class, "bean", accessStateFactory.getAggregatorLinear().getFirstValueCodegen(context.getClassScope(), context.getMethod())) .ifRefNullReturnNull("bean") .declareVar(EventBean[].class, "eventsPerStreamBuf", newArrayByLength(EventBean.class, constant(forge.getStreamNum() + 1))) .assignArrayElement("eventsPerStreamBuf", constant(forge.getStreamNum()), ref("bean")) .declareVar(Object.class, "value", localMethod(childExpr, ref("eventsPerStreamBuf"), constant(true), constantNull())) .ifRefNullReturnNull("value") .methodReturn(staticMethod(Collections.class, "singletonList", ref("value"))); }
public AggregatorAvgBig(AggregationForgeFactoryAvg factory, int col, CodegenCtor rowCtor, CodegenMemberCol membersColumnized, CodegenClassScope classScope, Class optionalDistinctValueType, boolean hasFilter, ExprNode optionalFilter) { super(factory, col, rowCtor, membersColumnized, classScope, optionalDistinctValueType, hasFilter, optionalFilter); this.factory = factory; sum = membersColumnized.addMember(col, BigDecimal.class, "sum"); cnt = membersColumnized.addMember(col, long.class, "cnt"); rowCtor.getBlock().assignRef(sum, newInstance(BigDecimal.class, constant(0d))); }
private static CodegenExpression makeOpBuildOrder(Set<Integer> operatorBuildOrder, CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(LinkedHashSet.class, DataflowDescForge.class, classScope); method.getBlock().declareVar(LinkedHashSet.class, "order", newInstance(LinkedHashSet.class, constant(CollectionUtil.capacityHashMap(operatorBuildOrder.size())))); for (Integer entry : operatorBuildOrder) { method.getBlock().exprDotMethod(ref("order"), "add", constant(entry)); } method.getBlock().methodReturn(ref("order")); return localMethod(method); }
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()); } } }
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 CodegenExpression codegenCreateReader(CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(AggregationMethodSortedMinMaxBy.class, this.getClass(), classScope); method.getBlock() .declareVar(AggregationMethodSortedMinMaxBy.class, "strat", newInstance(AggregationMethodSortedMinMaxBy.class)) .exprDotMethod(ref("strat"), "setMax", constant(max)) .methodReturn(ref("strat")); return localMethod(method); } }
protected void applyEnterFiltered(CodegenMethod method, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { CodegenExpressionRef eps = symbols.getAddEPS(method); method.getBlock() .declareVar(EventBean.class, "theEvent", arrayAtIndex(eps, constant(forge.getStreamNum()))) .ifRefNull("theEvent").blockReturnNoValue() .exprDotMethod(events, "add", ref("theEvent")); }
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")); }
public CodegenMethod initializeCodegen(CodegenClassScope classScope, CodegenMethodScope parent, SAIFFInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(StatementAgentInstanceFactoryCreateContext.class, this.getClass(), classScope); method.getBlock() .declareVar(StatementAgentInstanceFactoryCreateContext.class, "saiff", newInstance(StatementAgentInstanceFactoryCreateContext.class)) .exprDotMethod(ref("saiff"), "setContextName", constant(contextName)) .exprDotMethod(ref("saiff"), "setStatementEventType", EventTypeUtility.resolveTypeCodegen(statementEventType, symbols.getAddInitSvc(method))) .exprDotMethod(symbols.getAddInitSvc(method), "addReadyCallback", ref("saiff")) .methodReturn(ref("saiff")); return method; } }
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(getterReturnTypeBoxed, ExprEvaluatorStreamDTProp.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamId))) .ifRefNullReturnNull("event") .methodReturn(CodegenLegoCast.castSafeFromObjectType(getterReturnTypeBoxed, getter.eventBeanGetCodegen(ref("event"), methodNode, codegenClassScope))); return localMethod(methodNode); }