public CodegenExpression codegenCreateReader(CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(AggregationMultiFunctionAggregationMethod.class, this.getClass(), classScope); method.getBlock() .methodReturn(staticMethod(AggregationMethodSortedNoParamFactory.class, "makeSortedAggregationNoParam", enumValue(AggregationMethodSortedEnum.class, aggMethod.name()), constant(underlyingClass))); return localMethod(method); }
public CodegenExpression eventBeanGetCodegen(CodegenExpression beanExpression, CodegenMethodScope parent, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(Object.class, this.getClass(), classScope).addParam(EventBean.class, "eventBean"); CodegenMethod methodExpr = CodegenLegoMethodExpression.codegenExpression(eval.getForge(), method, classScope); method.getBlock() .declareVar(EventBean[].class, "events", newArrayWithInit(EventBean.class, ref("eventBean"))) .declareVar(String.class, "code", cast(String.class, localMethod(methodExpr, ref("events"), constantTrue(), constantNull()))) .methodReturn(staticMethod(ContextControllerHashedGetterCRC32SingleForge.class, "stringToCRC32Hash", ref("code"), constant(granularity))); return localMethod(method, beanExpression); } }
static void getIteratorJoinCodegen(CodegenMethod method) { method.getBlock() .declareVar(UniformPair.class, EventBean[].class, "result", exprDotMethod(ref("this"), "processJoinResult", REF_JOINSET, staticMethod(Collections.class, "emptySet"), constant(true))) .methodReturn(newInstance(ArrayEventIterator.class, cast(EventBean[].class, exprDotMethod(ref("result"), "getFirst")))); } }
public CodegenExpression getLastNthValueCodegen(CodegenExpressionRef index, CodegenMethod parentMethod, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { CodegenMethod method = parentMethod.makeChildWithScope(EventBean.class, AggregatorAccessLinearNonJoin.class, CodegenSymbolProviderEmpty.INSTANCE, classScope).addParam(int.class, "index"); method.getBlock().ifCondition(relational(ref("index"), LT, constant(0))).blockReturn(constantNull()) .ifCondition(relational(ref("index"), GE, exprDotMethod(events, "size"))).blockReturn(constantNull()) .methodReturn(cast(EventBean.class, exprDotMethod(events, "get", op(op(exprDotMethod(events, "size"), "-", ref("index")), "-", constant(1))))); return localMethod(method, index); }
public CodegenExpression codegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpressionRef left, CodegenExpressionRef right, Class ltype, Class rtype) { CodegenBlock block = codegenMethodScope.makeChild(BigDecimal.class, DivideBigDec.class, codegenClassScope).addParam(BigDecimal.class, "b1").addParam(BigDecimal.class, "b2").getBlock(); CodegenBlock ifBlock = block.ifCondition(equalsIdentity(exprDotMethod(ref("b1"), "doubleValue"), constant(0d))); if (divisionByZeroReturnsNull) { ifBlock.blockReturn(constantNull()); } else { ifBlock.blockReturn(newInstance(BigDecimal.class, op(exprDotMethod(ref("b1"), "doubleValue"), "/", constant(0d)))); } CodegenMethod method = block.methodReturn(exprDotMethod(ref("b1"), "divide", ref("b2"))); return localMethod(method, left, right); } }
public CodegenExpression getLastNthValueCodegen(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, op(op(arrayLength(array), "-", ref("index")), "-", constant(1)))); return localMethod(method, index); }
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 makeCodegen(CodegenClassScope classScope, CodegenMethodScope parent) { CodegenMethod method = parent.makeChild(Object.class, this.getClass(), classScope).addParam(GET_FILTER_VALUE_FP); CodegenExpression get = exprIdentNodeEvaluator.getGetter().eventBeanGetCodegen(ref("event"), method, classScope); method.getBlock() .declareVar(EventBean.class, "event", exprDotMethod(ref("matchedEvents"), "getMatchingEventByTag", constant(resultEventAsName))) .ifRefNull(ref("event")).blockThrow(newInstance(IllegalStateException.class, constant("Matching event named '" + resultEventAsName + "' not found in event result set"))) .declareVar(Number.class, "value", cast(Number.class, get)) .ifRefNull("value").blockReturn(constantNull()) .methodReturn(exprDotMethod(ref("value"), "doubleValue")); return localMethod(method, GET_FILTER_VALUE_REFS); }
public CodegenExpression eventBeanGetMappedCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, CodegenExpression beanExpression, CodegenExpression key) { CodegenMethod method = codegenMethodScope.makeChild(Object.class, AvroEventBeanGetterMappedRuntimeKeyed.class, codegenClassScope).addParam(EventBean.class, "event").addParam(String.class, "key").getBlock() .declareVar(GenericData.Record.class, "record", castUnderlying(GenericData.Record.class, ref("event"))) .declareVar(Map.class, "values", cast(Map.class, exprDotMethod(ref("record"), "get", constant(pos)))) .methodReturn(staticMethod(AvroEventBeanGetterMapped.class, "getAvroMappedValueWNullCheck", ref("values"), ref("key"))); return localMethodBuild(method).pass(beanExpression).pass(key).call(); } }
private static CodegenMethod obtainIteratorCodegen(ResultSetProcessorRowForAllForge forge, CodegenClassScope classScope, CodegenMethod parent, CodegenInstanceAux instance) { CodegenMethod selectList = getSelectListEventsAsArrayCodegen(forge, classScope, instance); CodegenMethod method = parent.makeChild(Iterator.class, ResultSetProcessorRowForAllImpl.class, classScope); method.getBlock().declareVar(EventBean[].class, "events", localMethod(selectList, constantTrue(), constantTrue(), constantFalse())) .ifRefNull("events") .blockReturn(enumValue(CollectionUtil.class, "NULL_EVENT_ITERATOR")) .methodReturn(newInstance(SingleEventIterator.class, arrayAtIndex(ref("events"), constant(0)))); return method; }
public static CodegenExpression evaluateCodegen(ExprEventIdentityEqualsNodeForge forge, CodegenMethodScope parent, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(Boolean.class, ExprEventIdentityEqualsNodeEval.class, classScope); method.getBlock() .declareVar(EventBean.class, "left", arrayAtIndex(symbols.getAddEPS(method), constant(forge.getUndLeft().getStreamId()))) .declareVar(EventBean.class, "right", arrayAtIndex(symbols.getAddEPS(method), constant(forge.getUndRight().getStreamId()))) .ifCondition(or(equalsNull(ref("left")), equalsNull(ref("right")))) .blockReturn(constantNull()) .methodReturn(exprDotMethod(ref("left"), "equals", ref("right"))); return localMethod(method); }
@Override public CodegenExpression evaluateCodegen(CodegenMethodScope parent, ExprSubselectEvalMatchSymbol symbols, CodegenClassScope classScope) { CodegenExpressionField eventToPublic = TableDeployTimeResolver.makeTableEventToPublicField(table, classScope, this.getClass()); CodegenMethod method = parent.makeChild(subselect.getEvaluationType(), this.getClass(), classScope); method.getBlock() .ifCondition(relational(exprDotMethod(symbols.getAddMatchingEvents(method), "size"), CodegenExpressionRelational.CodegenRelational.GT, constant(1))) .blockReturn(constantNull()) .declareVar(EventBean.class, "event", staticMethod(EventBeanUtility.class, "getNonemptyFirstEvent", symbols.getAddMatchingEvents(method))) .methodReturn(exprDotMethod(eventToPublic, "convertToUnd", ref("event"), symbols.getAddEPS(method), symbols.getAddIsNewData(method), symbols.getAddExprEvalCtx(method))); return localMethod(method); } }
static void processViewResultCodegen(ResultSetProcessorHandThroughFactoryForge prototype, CodegenMethod method) { CodegenExpression oldEvents = constantNull(); if (prototype.isSelectRStream()) { oldEvents = staticMethod(ResultSetProcessorHandThroughUtil.class, METHOD_GETSELECTEVENTSNOHAVINGHANDTHRUVIEW, REF_SELECTEXPRPROCESSOR, REF_OLDDATA, constant(false), REF_ISSYNTHESIZE, REF_AGENTINSTANCECONTEXT); } CodegenExpression newEvents = staticMethod(ResultSetProcessorHandThroughUtil.class, METHOD_GETSELECTEVENTSNOHAVINGHANDTHRUVIEW, REF_SELECTEXPRPROCESSOR, REF_NEWDATA, constant(true), REF_ISSYNTHESIZE, REF_AGENTINSTANCECONTEXT); method.getBlock() .declareVar(EventBean[].class, "selectOldEvents", oldEvents) .declareVar(EventBean[].class, "selectNewEvents", newEvents) .methodReturn(newInstance(UniformPair.class, ref("selectNewEvents"), ref("selectOldEvents"))); }
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Long.class, ExprEvaluatorStreamDTPropFragment.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "theEvent", arrayAtIndex(refEPS, constant(streamId))) .ifRefNullReturnNull("theEvent") .declareVar(Object.class, "event", getterFragment.eventBeanFragmentCodegen(ref("theEvent"), methodNode, codegenClassScope)) .ifCondition(not(instanceOf(ref("event"), EventBean.class))) .blockReturn(constantNull()) .methodReturn(CodegenLegoCast.castSafeFromObjectType(Long.class, getterTimestamp.eventBeanGetCodegen(cast(EventBean.class, ref("event")), methodNode, codegenClassScope))); return localMethod(methodNode); }
private static CodegenMethod obtainIteratorCodegen(ResultSetProcessorRowPerGroupRollupForge forge, CodegenClassScope classScope, CodegenMethod parent, CodegenInstanceAux instance) { CodegenMethod resetEventPerGroupBufView = resetEventPerGroupBufCodegen(NAME_EVENTPERGROUPBUFVIEW, classScope, instance); CodegenMethod generateGroupKeysView = generateGroupKeysViewCodegen(forge, classScope, instance); CodegenMethod generateOutputEventsView = generateOutputEventsViewCodegen(forge, classScope, instance); CodegenMethod iterator = parent.makeChild(Iterator.class, ResultSetProcessorRowPerGroupRollupImpl.class, classScope).addParam(Viewable.class, NAME_VIEWABLE); iterator.getBlock().localMethod(resetEventPerGroupBufView) .declareVar(EventBean[].class, "events", staticMethod(CollectionUtil.class, METHOD_ITERATORTOARRAYEVENTS, exprDotMethod(REF_VIEWABLE, "iterator"))) .localMethod(generateGroupKeysView, ref("events"), ref(NAME_EVENTPERGROUPBUFVIEW), constantTrue()) .declareVar(EventBean[].class, "output", localMethod(generateOutputEventsView, ref(NAME_EVENTPERGROUPBUFVIEW), constantTrue(), constantTrue())) .methodReturn(newInstance(ArrayEventIterator.class, ref("output"))); return iterator; }
public static CodegenMethod getBeanArrayValueCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, BeanEventPropertyGetter nestedGetter, int index) { return codegenMethodScope.makeChild(Object.class, BaseNestableEventUtil.class, codegenClassScope).addParam(Object.class, "value").getBlock() .ifRefNullReturnNull("value") .ifConditionReturnConst(not(exprDotMethodChain(ref("value")).add("getClass").add("isArray")), null) .ifConditionReturnConst(relational(staticMethod(Array.class, "getLength", ref("value")), LE, constant(index)), null) .declareVar(Object.class, "arrayItem", staticMethod(Array.class, "get", ref("value"), constant(index))) .ifRefNullReturnNull("arrayItem") .methodReturn(nestedGetter.underlyingGetCodegen(cast(nestedGetter.getTargetType(), ref("arrayItem")), codegenMethodScope, codegenClassScope)); }
public CodegenExpression getFirstValueCodegen(CodegenClassScope classScope, CodegenMethod parent) { CodegenMethod method = parent.makeChildWithScope(EventBean.class, this.getClass(), CodegenSymbolProviderEmpty.INSTANCE, classScope); method.getBlock().ifCondition(exprDotMethod(sorted, "isEmpty")) .blockReturn(constantNull()) .declareVar(Map.Entry.class, "max", exprDotMethod(sorted, "firstEntry")) .methodReturn(staticMethod(AggregatorAccessSortedImpl.class, "checkedPayloadMayDeque", exprDotMethod(ref("max"), "getValue"))); return localMethod(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 CodegenExpression codegen(EnumForgeCodegenParams args, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenMethod method = codegenMethodScope.makeChild(Collection.class, EnumDistinctScalarForge.class, codegenClassScope).addParam(EnumForgeCodegenNames.PARAMS).getBlock() .ifCondition(relational(exprDotMethod(EnumForgeCodegenNames.REF_ENUMCOLL, "size"), LE, constant(1))) .blockReturn(EnumForgeCodegenNames.REF_ENUMCOLL) .ifCondition(instanceOf(ref("enumcoll"), Set.class)) .blockReturn(EnumForgeCodegenNames.REF_ENUMCOLL) .methodReturn(newInstance(LinkedHashSet.class, EnumForgeCodegenNames.REF_ENUMCOLL)); return localMethod(method, args.getExpressions()); } }
public CodegenExpression evaluateCodegenUninstrumented(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(String.class, ExprTypeofNodeForgeStreamEvent.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamNum))) .ifRefNullReturnNull("event") .ifCondition(instanceOf(ref("event"), VariantEvent.class)) .blockReturn(exprDotMethodChain(cast(VariantEvent.class, ref("event"))).add("getUnderlyingEventBean").add("getEventType").add("getName")) .methodReturn(exprDotMethodChain(ref("event")).add("getEventType").add("getName")); return localMethod(methodNode); }