public void SortWOrderKeysCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { OrderByProcessorRowLimitOnly.SortWOrderKeysCodegen(method); }
public CodegenExpression GetFirstNthValueCodegen( CodegenExpressionRef index, CodegenMethod parentMethod, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { var initArray = InitArrayCodegen(namedMethods, classScope); var method = parentMethod.MakeChildWithScope( typeof(EventBean), typeof(AggregatorAccessLinearJoin), CodegenSymbolProviderEmpty.INSTANCE, classScope) .AddParam(typeof(int), "index"); method.Block.IfCondition(Relational(Ref("index"), LT, Constant(0))) .BlockReturn(ConstantNull()) .IfCondition(ExprDotMethod(refSet, "IsEmpty")) .BlockReturn(ConstantNull()) .IfCondition(Relational(Ref("index"), GE, ExprDotName(refSet, "Count"))) .BlockReturn(ConstantNull()) .IfCondition(EqualsNull(array)) .InstanceMethod(initArray) .BlockEnd() .MethodReturn(ArrayAtIndex(array, Ref("index"))); return LocalMethod(method, index); }
public void GetRowCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.MethodReturn(MEMBER_ROW); }
protected internal static void SortWGroupKeysCodegen( OrderByProcessorOrderedLimitForge forge, CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { var sortWGroupKeys = method.MakeChild(typeof(EventBean[]), typeof(OrderByProcessorOrderedLimit), classScope) .AddParam(SORTWGROUPKEYS_PARAMS); OrderByProcessorImpl.SortWGroupKeysCodegen( forge.OrderByProcessorForge, sortWGroupKeys, classScope, namedMethods); method.Block.DeclareVar<EventBean[]>( "sorted", LocalMethod( sortWGroupKeys, REF_OUTGOINGEVENTS, REF_GENERATINGEVENTS, REF_ORDERGROUPBYKEYS, ExprForgeCodegenNames.REF_ISNEWDATA, REF_EXPREVALCONTEXT, MEMBER_AGGREGATIONSVC)) .MethodReturn(ExprDotMethod(REF_ROWLIMITPROCESSOR, "DetermineLimitAndApply", Ref("sorted"))); }
public void GetEventBeanCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { GetterCodegen("GetEventBean", method, classScope, namedMethods); }
public void GetValueCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { GetterCodegen("GetValue", method, classScope, namedMethods); }
public void GetCollectionScalarCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { GetterCodegen("GetCollectionScalar", method, classScope, namedMethods); }
private CodegenMethod ReferenceAddToCollCodegen( CodegenMethod parent, CodegenNamedMethods namedMethods, CodegenClassScope classScope) { var getComparable = GetComparableWMultiKeyCodegen(forge.Spec.Criteria, sorted, namedMethods, classScope); var method = parent .MakeChildWithScope(typeof(void), this.GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope) .AddParam(typeof(EventBean), "theEvent") .AddParam(typeof(EventBean[]), NAME_EPS) .AddParam(typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT); method.Block .DeclareVar <object>("comparable", LocalMethod(getComparable, REF_EPS, ConstantTrue(), REF_EXPREVALCONTEXT)) .DeclareVar <object>("existing", ExprDotMethod(sorted, "Get", Ref("comparable"))) .IfRefNull("existing") .ExprDotMethod(sorted, "Put", Ref("comparable"), Ref("theEvent")) .IfElseIf(InstanceOf(Ref("existing"), typeof(EventBean))) .DeclareVar <ArrayDeque <EventBean> >("coll", NewInstance <ArrayDeque <EventBean> >(Constant(2))) .ExprDotMethod(Ref("coll"), "Add", Cast <EventBean>(Ref("existing"))) .ExprDotMethod(Ref("coll"), "Add", Ref("theEvent")) .ExprDotMethod(sorted, "Put", Ref("comparable"), Ref("coll")) .IfElse() .DeclareVar <ArrayDeque <EventBean> >("q", Cast <ArrayDeque <EventBean> >(Ref("existing"))) .ExprDotMethod(Ref("q"), "Add", Ref("theEvent")) .BlockEnd() .Increment(size); return(method); }
public void GetSortKeyRollupCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.MethodReturn(ConstantNull()); }
public void GetRowCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.MethodThrowUnsupported(); }
public void ApplyEnterCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods, AggregationClassNames classNames) { }
public CodegenExpression EnumeratorCodegen( CodegenClassScope classScope, CodegenMethod method, CodegenNamedMethods namedMethods) { return ExprDotMethod(events, "GetEnumerator"); }
public CodegenExpression CollectionReadOnlyCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { return events; }
public void SortWGroupKeysCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { OrderByProcessorOrderedLimit.SortWGroupKeysCodegen(this, method, classScope, namedMethods); }
public void GetSortKeyCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { OrderByProcessorImpl.GetSortKeyCodegen(orderByProcessorForge, method, classScope, namedMethods); }
internal override void ApplyLeaveFiltered( CodegenMethod method, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { var eps = symbols.GetAddEPS(method); var ctx = symbols.GetAddExprEvalCtx(method); var dereferenceRemove = DereferenceRemoveFromCollCodegen(method, namedMethods, classScope); method.Block.DeclareVar <EventBean>("theEvent", ArrayAtIndex(eps, Constant(forge.Spec.StreamNum))) .IfRefNull("theEvent") .BlockReturnNoValue(); if (joinRefs == null) { method.Block .LocalMethod(dereferenceRemove, Ref("theEvent"), eps, ctx); } else { method.Block .IfCondition(ExprDotMethod(joinRefs, "Remove", Ref("theEvent"))) .LocalMethod(dereferenceRemove, Ref("theEvent"), eps, ctx); } }
private CodegenMethod AddEventCodegen( CodegenMethod parent, CodegenNamedMethods namedMethods, CodegenClassScope classScope) { var comparable = GetComparableWObjectArrayKeyCodegen(_forge.Spec.Criteria, _currentMinMaxBean, namedMethods, classScope); var methodNode = parent .MakeChild(typeof(void), this.GetType(), classScope) .AddParam(typeof(EventBean), "theEvent") .AddParam(typeof(EventBean[]), NAME_EPS) .AddParam(typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT); methodNode.Block .DeclareVar <object>("comparable", LocalMethod(comparable, REF_EPS, ConstantTrue(), REF_EXPREVALCONTEXT)) .IfCondition(EqualsNull(_currentMinMax)) .AssignRef(_currentMinMax, Ref("comparable")) .AssignRef(_currentMinMaxBean, Ref("theEvent")) .IfElse() .DeclareVar <int>("compareResult", ExprDotMethod(_comparator, "Compare", _currentMinMax, Ref("comparable"))) .IfCondition(Relational(Ref("compareResult"), _forge.Spec.IsMax ? LT : GT, Constant(0))) .AssignRef(_currentMinMax, Ref("comparable")) .AssignRef(_currentMinMaxBean, Ref("theEvent")); return(methodNode); }
public void GetEventBeanCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.MethodReturn(ConstantNull()); }
public void SortPlainCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { OrderByProcessorImpl.SortPlainCodegen(this, method, classScope, namedMethods); }
private CodegenMethod DereferenceRemoveFromCollCodegen( CodegenMethod parent, CodegenNamedMethods namedMethods, CodegenClassScope classScope) { var getComparable = GetComparableWMultiKeyCodegen(forge.Spec.Criteria, sorted, namedMethods, classScope); var method = parent .MakeChildWithScope(typeof(void), GetType(), CodegenSymbolProviderEmpty.INSTANCE, classScope) .AddParam(typeof(EventBean), "theEvent") .AddParam(typeof(EventBean[]), NAME_EPS) .AddParam( typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT); method.Block.DeclareVar<object>( "comparable", LocalMethod(getComparable, REF_EPS, ConstantTrue(), REF_EXPREVALCONTEXT)) .DeclareVar<object>("existing", ExprDotMethod(sorted, "Get", Ref("comparable"))) .IfRefNull("existing") .BlockReturnNoValue() .IfCondition(ExprDotMethod(Ref("existing"), "Equals", Ref("theEvent"))) .ExprDotMethod(sorted, "Remove", Ref("comparable")) .Decrement(size) .IfElseIf(InstanceOf(Ref("existing"), typeof(ArrayDeque<EventBean>))) .DeclareVar<ArrayDeque<EventBean>>("q", Cast(typeof(ArrayDeque<EventBean>), Ref("existing"))) .ExprDotMethod(Ref("q"), "Remove", Ref("theEvent")) .IfCondition(ExprDotMethod(Ref("q"), "IsEmpty")) .ExprDotMethod(sorted, "Remove", Ref("comparable")) .BlockEnd() .Decrement(size); return method; }
public void GetCollectionOfEventsCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.MethodReturn(ConstantNull()); }
public void GetEventBeanCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.MethodReturn( ExprDotMethod(MEMBER_ROW, "GetEventBean", REF_COLUMN, REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT)); }
public void ApplyLeaveCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods, AggregationClassNames classNames) { ApplyCodegen(false, method, classScope, classNames); }
internal override void ApplyLeaveFiltered( CodegenMethod method, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { // this is an ever-type aggregation }
public void ApplyLeaveCodegen( CodegenMethod method, ExprForgeCodegenSymbol symbols, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.MethodThrowUnsupported(); }
protected internal static CodegenMethod CreateSortPropertiesWRollupCodegen( OrderByProcessorForgeImpl forge, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { Consumer<CodegenMethod> code = method => { method.Block.DeclareVar<object[]>( "sortProperties", NewArrayByLength(typeof(object), ExprDotName(REF_ORDERCURRENTGENERATORS, "Count"))) .DeclareVar<int>("count", Constant(0)); var forEach = method.Block.ForEach(typeof(GroupByRollupKey), "rollup", REF_ORDERCURRENTGENERATORS); if (forge.IsNeedsGroupByKeys) { forEach.ExprDotMethod( MEMBER_AGGREGATIONSVC, "SetCurrentAccess", ExprDotName(Ref("rollup"), "GroupKey"), ExprDotName(REF_EXPREVALCONTEXT, "AgentInstanceId"), ExprDotName(Ref("rollup"), "Level")); } forEach.DeclareVar<int>( "num", ExprDotMethodChain(Ref("rollup")).Get("Level").Get("LevelNumber")); var blocks = forEach.SwitchBlockOfLength(Ref("num"), forge.OrderByRollup.Length, false); for (var i = 0; i < blocks.Length; i++) { var getSortKey = GenerateOrderKeyCodegen( "GetSortKeyInternal_" + i, forge.OrderByRollup[i], classScope, namedMethods); blocks[i] .AssignArrayElement( "sortProperties", Ref("count"), LocalMethod( getSortKey, ExprDotName(Ref("rollup"), "Generator"), REF_ISNEWDATA, REF_EXPREVALCONTEXT)); } forEach.IncrementRef("count"); method.Block.MethodReturn(StaticMethod(typeof(CompatExtensions), "AsList", Ref("sortProperties"))); }; return namedMethods.AddMethod( typeof(IList<object>), "CreateSortPropertiesWRollup", CodegenNamedParam.From( typeof(IList<GroupByRollupKey>), REF_ORDERCURRENTGENERATORS.Ref, typeof(bool), REF_ISNEWDATA.Ref, typeof(ExprEvaluatorContext), REF_EXPREVALCONTEXT.Ref, typeof(AggregationService), MEMBER_AGGREGATIONSVC.Ref), typeof(OrderByProcessorImpl), classScope, code); }
private static CodegenMethod GetComparableWMultiKeyCodegen( ExprNode[] criteria, CodegenExpressionRef @ref, CodegenNamedMethods namedMethods, CodegenClassScope classScope) { var methodName = "GetComparable_" + @ref.Ref; Consumer<CodegenMethod> code = method => { if (criteria.Length == 1) { method.Block.MethodReturn( LocalMethod( CodegenLegoMethodExpression.CodegenExpression( criteria[0].Forge, method, classScope, true), REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT)); } else { var exprSymbol = new ExprForgeCodegenSymbol(true, null); var expressions = new CodegenExpression[criteria.Length]; for (var i = 0; i < criteria.Length; i++) { expressions[i] = criteria[i] .Forge.EvaluateCodegen( typeof(object), method, exprSymbol, classScope); } exprSymbol.DerivedSymbolsCodegen(method, method.Block, classScope); method.Block.DeclareVar<object[]>( "result", NewArrayByLength(typeof(object), Constant(criteria.Length))); for (var i = 0; i < criteria.Length; i++) { method.Block.AssignArrayElement(Ref("result"), Constant(i), expressions[i]); } method.Block.MethodReturn(NewInstance<HashableMultiKey>(Ref("result"))); } }; return namedMethods.AddMethod( typeof(object), methodName, CodegenNamedParam.From( typeof(EventBean[]), NAME_EPS, typeof(bool), NAME_ISNEWDATA, typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT), typeof(AggregatorAccessSortedImpl), classScope, code); }
public void GetValueCodegen( CodegenMethod method, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { method.Block.DebugStack(); method.Block.MethodReturn( ExprDotMethod(MEMBER_ROW, "GetValue", REF_COLUMN, REF_EPS, REF_ISNEWDATA, REF_EXPREVALCONTEXT)); }
public static CodegenMethod ComputeMultiKeyCodegen( int idNumber, ExprForge[] partitionForges, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { var exprSymbol = new ExprForgeCodegenSymbol(true, null); Consumer<CodegenMethod> code = method => { if (partitionForges.Length == 1) { CodegenExpression expression = partitionForges[0] .EvaluateCodegen( typeof(object), method, exprSymbol, classScope); exprSymbol.DerivedSymbolsCodegen(method, method.Block, classScope); method.Block.MethodReturn(expression); } else { var expressions = new CodegenExpression[partitionForges.Length]; for (var i = 0; i < partitionForges.Length; i++) { expressions[i] = partitionForges[i] .EvaluateCodegen( typeof(object), method, exprSymbol, classScope); } exprSymbol.DerivedSymbolsCodegen(method, method.Block, classScope); method.Block.DeclareVar<object[]>( "keys", NewArrayByLength(typeof(object), Constant(partitionForges.Length))); for (var i = 0; i < expressions.Length; i++) { method.Block.AssignArrayElement("keys", Constant(i), expressions[i]); } method.Block.MethodReturn(NewInstance<HashableMultiKey>(Ref("keys"))); } }; return namedMethods.AddMethodWithSymbols( typeof(object), "ComputeKeyArrayCodegen_" + idNumber, CodegenNamedParam.From( typeof(EventBean[]), NAME_EPS, typeof(bool), NAME_ISNEWDATA, typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT), typeof(AggregationServiceCodegenUtil), classScope, code, exprSymbol); }
protected internal static CodegenMethod GenerateOrderKeyCodegen( string methodName, OrderByElementForge[] orderBy, CodegenClassScope classScope, CodegenNamedMethods namedMethods) { Consumer<CodegenMethod> code = methodNode => { if (orderBy.Length == 1) { var expression = CodegenLegoMethodExpression.CodegenExpression( orderBy[0].ExprNode.Forge, methodNode, classScope, true); methodNode.Block.MethodReturn( LocalMethod( expression, EnumForgeCodegenNames.REF_EPS, ResultSetProcessorCodegenNames.REF_ISNEWDATA, REF_EXPREVALCONTEXT)); return; } methodNode.Block.DeclareVar<object[]>( "keys", NewArrayByLength(typeof(object), Constant(orderBy.Length))); for (var i = 0; i < orderBy.Length; i++) { var expression = CodegenLegoMethodExpression.CodegenExpression( orderBy[i].ExprNode.Forge, methodNode, classScope, true); methodNode.Block.AssignArrayElement( "keys", Constant(i), LocalMethod( expression, EnumForgeCodegenNames.REF_EPS, ResultSetProcessorCodegenNames.REF_ISNEWDATA, REF_EXPREVALCONTEXT)); } methodNode.Block.MethodReturn(NewInstance<HashableMultiKey>(Ref("keys"))); }; return namedMethods.AddMethod( typeof(object), methodName, CodegenNamedParam.From( typeof(EventBean[]), NAME_EPS, typeof(bool), NAME_ISNEWDATA, typeof(ExprEvaluatorContext), NAME_EXPREVALCONTEXT), typeof(ResultSetProcessorUtil), classScope, code); }