public CodegenExpression eventBeanGetCodegen(CodegenExpression beanExpression, CodegenMethodScope parent, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(String.class, this.getClass(), classScope).addParam(EventBean.class, "bean"); method.getBlock().methodReturn(exprDotMethodChain(ref("bean")).add("getEventType").add("getName")); return localMethod(method, beanExpression); } };
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 static CodegenMethod registerScriptCodegen(Map.Entry<NameAndParamNum, ExpressionScriptProvided> script, CodegenMethodScope parent, CodegenClassScope classScope, ModuleScriptInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(void.class, EPCompilerImpl.class, classScope); method.getBlock() .expression(exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPModuleScriptInitServices.GETSCRIPTCOLLECTOR) .add("registerScript", constant(script.getKey().getName()), constant(script.getKey().getParamNum()), script.getValue().make(method, classScope))); return method; }
public CodegenExpression make(CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { // resolve variable at init-time via field CodegenExpression variableExpression = constantNull(); if (variableMetaData != null) { variableExpression = VariableDeployTimeResolver.makeVariableField(variableMetaData, classScope, this.getClass()); } CodegenMethod method = parent.makeChild(OutputConditionFactory.class, this.getClass(), classScope); method.getBlock() .methodReturn(exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPStatementInitServices.GETRESULTSETPROCESSORHELPERFACTORY) .add("makeOutputConditionCount", constant(eventRate), variableExpression)); return localMethod(method); }
private static CodegenMethod registerTableCodegen(Map.Entry<String, TableMetaData> table, CodegenMethodScope parent, CodegenClassScope classScope, ModuleTableInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(void.class, EPCompilerImpl.class, classScope); method.getBlock() .declareVar(TableMetaData.class, "detail", table.getValue().make(parent, symbols, classScope)) .expression(exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPModuleTableInitServices.GETTABLECOLLECTOR).add("registerTable", constant(table.getKey()), ref("detail"))); return method; }
public CodegenExpression initCtorScoped() { CodegenExpression type = EventTypeUtility.resolveTypeCodegen(forge.getSpec().getStreamEventType(), EPStatementInitServices.REF); return exprDotMethodChain(EPStatementInitServices.REF).add(EPStatementInitServices.GETDATAINPUTOUTPUTSERDEPROVIDER).add("treeMapEventsMayDeque", constant(forge.getSpec().getCriteriaTypes()), type); } });
private static CodegenMethod registerContextCodegen(Map.Entry<String, ContextMetaData> context, CodegenMethod parent, CodegenClassScope classScope, ModuleContextInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(void.class, EPCompilerImpl.class, classScope); method.getBlock() .declareVar(ContextMetaData.class, "detail", context.getValue().make(symbols.getAddInitSvc(method))) .expression(exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPModuleContextInitServices.GETCONTEXTCOLLECTOR) .add("registerContext", constant(context.getKey()), ref("detail"))); return method; }
private static CodegenMethod registerExprDeclaredCodegen(Map.Entry<String, ExpressionDeclItem> expression, CodegenMethod parent, CodegenClassScope classScope, ModuleExpressionDeclaredInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(void.class, EPCompilerImpl.class, classScope); ExpressionDeclItem item = expression.getValue(); byte[] bytes = SerializerUtil.objectToByteArr(item.getOptionalSoda()); item.setOptionalSodaBytes(() -> bytes); method.getBlock() .declareVar(ExpressionDeclItem.class, "detail", expression.getValue().make(method, symbols, classScope)) .expression(exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPModuleExprDeclaredInitServices.GETEXPRDECLAREDCOLLECTOR) .add("registerExprDeclared", constant(expression.getKey()), ref("detail"))); return method; }
public CodegenMethod makeCodegen(CodegenClassScope classScope, CodegenMethodScope parent, SAIFFInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(ContextControllerKeyedFactory.class, this.getClass(), classScope); method.getBlock() .declareVar(ContextControllerKeyedFactory.class, "factory", exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPStatementInitServices.GETCONTEXTSERVICEFACTORY).add("keyedFactory")) .exprDotMethod(ref("factory"), "setKeyedSpec", detail.makeCodegen(method, symbols, classScope)) .methodReturn(ref("factory")); return method; }
public CodegenMethod makeCodegen(CodegenClassScope classScope, CodegenMethodScope parent, SAIFFInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(ContextControllerHashFactory.class, this.getClass(), classScope); method.getBlock() .declareVar(ContextControllerHashFactory.class, "factory", exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPStatementInitServices.GETCONTEXTSERVICEFACTORY).add("hashFactory")) .exprDotMethod(ref("factory"), "setHashSpec", detail.makeCodegen(method, symbols, classScope)) .methodReturn(ref("factory")); return method; }
private CodegenMethod routeCodegen(CodegenClassScope classScope, CodegenMethodScope parent) { CodegenMethod method = parent.makeChild(void.class, OutputStrategyPostProcessForge.class, classScope).addParam(EventBean[].class, "events"); CodegenBlock forEach = method.getBlock() .ifRefNull("events").blockReturnNoValue() .forEach(EventBean.class, "routed", ref("events")); if (audit) { forEach.expression(exprDotMethodChain(ref(NAME_AGENTINSTANCECONTEXT)).add("getAuditProvider").add("insert", ref("routed"), ref(NAME_AGENTINSTANCECONTEXT))); } forEach.expression(exprDotMethodChain(ref(NAME_AGENTINSTANCECONTEXT)).add("getInternalEventRouter").add("route", ref("routed"), ref(NAME_AGENTINSTANCECONTEXT), constant(routeToFront))); return method; }
public CodegenExpression getFirstValueCodegen(CodegenClassScope classScope, CodegenMethod parentMethod) { CodegenMethod method = parentMethod.makeChildWithScope(EventBean.class, AggregatorAccessLinearJoin.class, CodegenSymbolProviderEmpty.INSTANCE, classScope); method.getBlock().ifCondition(exprDotMethod(refSet, "isEmpty")).blockReturn(constantNull()) .declareVar(Map.Entry.class, "entry", cast(Map.Entry.class, exprDotMethodChain(refSet).add("entrySet").add("iterator").add("next"))) .methodReturn(cast(EventBean.class, exprDotMethod(ref("entry"), "getKey"))); return localMethod(method); }
public CodegenMethod makeCodegen(CodegenClassScope classScope, CodegenMethodScope parent, SAIFFInitializeSymbol symbols) { CodegenMethod method = parent.makeChild(ContextControllerCategoryFactory.class, ContextControllerCategoryFactoryForge.class, classScope); method.getBlock() .declareVar(ContextControllerCategoryFactory.class, "factory", exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPStatementInitServices.GETCONTEXTSERVICEFACTORY).add("categoryFactory")) .exprDotMethod(ref("factory"), "setCategorySpec", detail.makeCodegen(method, symbols, classScope)) .methodReturn(ref("factory")); return method; }
public CodegenExpression evaluateCodegenUninstrumented(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(String.class, ExprTypeofNodeForgeInnerEval.class, codegenClassScope); methodNode.getBlock() .declareVar(Object.class, "result", parent.getChildNodes()[0].getForge().evaluateCodegen(requiredType, methodNode, exprSymbol, codegenClassScope)) .ifRefNullReturnNull("result") .methodReturn(exprDotMethodChain(ref("result")).add("getClass").add("getSimpleName")); return localMethod(methodNode); }
private static void generate(CodegenBlock block, String name, CodegenExpression... expressions) { block.ifCondition(publicConstValue(InstrumentationCommon.RUNTIME_HELPER_CLASS, "ENABLED")) .expression(exprDotMethodChain(staticMethod(InstrumentationCommon.RUNTIME_HELPER_CLASS, "get")).add(name, expressions)) .blockEnd(); } }
public CodegenExpression codegen(Class requiredType, CodegenMethodScope parent, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope) { if (!audit) { return codegenGet(requiredType, parent, symbols, classScope); } Class targetType = getCodegenReturnType(requiredType); CodegenMethod method = parent.makeChild(targetType, this.getClass(), classScope); method.getBlock() .declareVar(targetType, "value", codegenGet(requiredType, method, symbols, classScope)) .expression(exprDotMethodChain(symbols.getAddExprEvalCtx(method)).add("getAuditProvider").add("property", constant(identNode.getResolvedPropertyName()), ref("value"), symbols.getAddExprEvalCtx(method))) .methodReturn(ref("value")); return localMethod(method); }
public CodegenExpression codegen(EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { Class type = EPTypeHelper.getCodegenReturnType(resultType); CodegenMethod method = codegenMethodScope.makeChild(type, EnumFirstOfNoPredicateForge.class, codegenClassScope).addParam(EnumForgeCodegenNames.PARAMS).getBlock() .ifCondition(or(equalsNull(EnumForgeCodegenNames.REF_ENUMCOLL), exprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "isEmpty"))) .blockReturn(constantNull()) .methodReturn(cast(type, exprDotMethodChain(EnumForgeCodegenNames.REF_ENUMCOLL).add("iterator").add("next"))); return localMethod(method, args.getExpressions()); } }
public static void applyEnterCodegenSweep(CodegenMethod method, CodegenClassScope classScope, AggregationClassNames classNames) { CodegenExpressionField timeAbacus = classScope.addOrGetFieldSharable(TimeAbacusField.INSTANCE); method.getBlock().declareVar(long.class, "currentTime", exprDotMethodChain(REF_EXPREVALCONTEXT).add("getTimeProvider").add("getTime")) .ifCondition(or(equalsNull(REF_NEXTSWEEPTIME), relational(REF_NEXTSWEEPTIME, LE, ref("currentTime")))) .assignRef(REF_CURRENTMAXAGE, staticMethod(AggSvcGroupByReclaimAgedImpl.class, "computeTimeReclaimAgeFreq", REF_CURRENTMAXAGE, REF_EVALUATORFUNCTIONMAXAGE, timeAbacus)) .assignRef(REF_CURRENTRECLAIMFREQUENCY, staticMethod(AggSvcGroupByReclaimAgedImpl.class, "computeTimeReclaimAgeFreq", REF_CURRENTRECLAIMFREQUENCY, REF_EVALUATIONFUNCTIONFREQUENCY, timeAbacus)) .assignRef(REF_NEXTSWEEPTIME, op(ref("currentTime"), "+", REF_CURRENTRECLAIMFREQUENCY)) .localMethod(sweepCodegen(method, classScope, classNames), ref("currentTime"), REF_CURRENTMAXAGE); }
protected void populateInline(CodegenExpression impl, CodegenMethod method, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { method.getBlock() .exprDotMethod(ref("impl"), "setQueryPlan", queryPlan.make(method, symbols, classScope)) .exprDotMethod(ref("impl"), "setStreamJoinAnalysisResult", streamJoinAnalysisResult.make(method, symbols, classScope)) .exprDotMethod(ref("impl"), "setStreamNames", constant(streamNames)) .exprDotMethod(ref("impl"), "setJoinRemoveStream", constant(joinRemoveStream)) .exprDotMethod(ref("impl"), "setEventTableIndexService", exprDotMethodChain(symbols.getAddInitSvc(method)).add(EPStatementInitServices.GETEVENTTABLEINDEXSERVICE)) .exprDotMethod(ref("impl"), "setHasHistorical", constant(hasHistorical)); } }