public CodegenExpression CodegenMake(
     CodegenMethodScope parent,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(
         typeof(EventAdvancedIndexProvisionRuntime),
         typeof(EventAdvancedIndexProvisionCompileTime),
         classScope);
     var indexExpressions =
         ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceAsArray(IndexDesc.IndexedExpressions);
     var indexProperties = GetPropertiesPerExpressionExpectSingle(IndexDesc.IndexedExpressions);
     method.Block
         .DeclareVar<EventAdvancedIndexProvisionRuntime>(
             "desc",
             NewInstance(typeof(EventAdvancedIndexProvisionRuntime)))
         .SetProperty(Ref("desc"), "IndexExpressionTexts", Constant(indexExpressions))
         .SetProperty(Ref("desc"), "IndexProperties", Constant(indexProperties))
         .SetProperty(
             Ref("desc"),
             "IsIndexExpressionsAllProps",
             Constant(IsExpressionsAllPropsOnly(IndexDesc.IndexedExpressions)))
         .SetProperty(Ref("desc"), "Factory", Factory.CodegenMake(parent, classScope))
         .SetProperty(
             Ref("desc"),
             "ParameterExpressionTexts",
             Constant(ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(Parameters)))
         .SetProperty(
             Ref("desc"),
             "ParameterEvaluators",
             ExprNodeUtilityCodegen.CodegenEvaluators(Parameters, parent, GetType(), classScope))
         .SetProperty(Ref("desc"), "ConfigStatement", ConfigStatement.CodegenMake(parent, classScope))
         .SetProperty(Ref("desc"), "IndexTypeName", Constant(IndexDesc.IndexTypeName))
         .MethodReturn(Ref("desc"));
     return LocalMethod(method);
 }
        public static CodegenMethod GenerateGroupKeySingleCodegen(
            ExprNode[] groupKeyExpressions,
            MultiKeyClassRef optionalMultiKeyClasses,
            CodegenClassScope classScope,
            CodegenInstanceAux instance)
        {
            Consumer<CodegenMethod> code = methodNode => {
                string[] expressions = null;
                if (classScope.IsInstrumented) {
                    expressions = ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(groupKeyExpressions);
                }

                methodNode.Block.Apply(
                    Instblock(
                        classScope,
                        "qResultSetProcessComputeGroupKeys",
                        ExprForgeCodegenNames.REF_ISNEWDATA,
                        Constant(expressions),
                        REF_EPS));


                if (optionalMultiKeyClasses != null && optionalMultiKeyClasses.ClassNameMK != null) {
                    var method = MultiKeyCodegen.CodegenMethod(groupKeyExpressions, optionalMultiKeyClasses, methodNode, classScope);
                    methodNode
                        .Block
                        .DeclareVar<object>("key", LocalMethod(method, REF_EPS, ExprForgeCodegenNames.REF_ISNEWDATA, MEMBER_AGENTINSTANCECONTEXT))
                        .Apply(Instblock(classScope, "aResultSetProcessComputeGroupKeys", ExprForgeCodegenNames.REF_ISNEWDATA, Ref("key")))
                        .MethodReturn(Ref("key"));
                    return;
                }

                if (groupKeyExpressions.Length > 1) {
                    throw new IllegalStateException("Multiple group-by expression and no multikey");
                }

                var expression = CodegenLegoMethodExpression.CodegenExpression(groupKeyExpressions[0].Forge, methodNode, classScope);
                methodNode
                    .Block
                    .DeclareVar<object>("key", LocalMethod(expression, REF_EPS, ExprForgeCodegenNames.REF_ISNEWDATA, MEMBER_AGENTINSTANCECONTEXT))
                    .Apply(Instblock(classScope, "aResultSetProcessComputeGroupKeys", ExprForgeCodegenNames.REF_ISNEWDATA, Ref("key")))
                    .MethodReturn(Ref("key"));
            };

            return instance.Methods.AddMethod(
                typeof(object),
                "GenerateGroupKeySingle",
                CodegenNamedParam.From(
                    typeof(EventBean[]),
                    NAME_EPS,
                    typeof(bool),
                    ResultSetProcessorCodegenNames.NAME_ISNEWDATA),
                typeof(ResultSetProcessorUtil),
                classScope,
                code);
        }
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var methodNode = parent.MakeChild(typeof(SubordTableLookupStrategyFactory), GetType(), classScope);
            if (_isStrictKeys) {
                int[] keyStreamNums = IntArrayUtil.Copy(_keyStreamNumbers);
                var keyStreamTypes = _outerStreamTypesZeroIndexed;
                if (isNWOnTrigger) {
                    keyStreamTypes = EventTypeUtility.ShiftRight(_outerStreamTypesZeroIndexed);
                    for (var i = 0; i < keyStreamNums.Length; i++) {
                        keyStreamNums[i] = keyStreamNums[i] + 1;
                    }
                }

                var forges = ExprNodeUtilityQuery.ForgesForProperties(
                    keyStreamTypes, _hashStrictKeys, keyStreamNums);
                var eval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(
                    forges,
                    _hashKeyCoercionTypes.CoercionTypes,
                    _hashMultikeyClasses,
                    methodNode,
                    classScope);

                methodNode.Block.MethodReturn(
                    NewInstance<SubordHashedTableLookupStrategyPropFactory>(
                        Constant(_hashStrictKeys),
                        Constant(keyStreamNums),
                        eval));
                return LocalMethod(methodNode);
            }
            else {
                var forges = new ExprForge[_hashKeys.Count];
                for (var i = 0; i < _hashKeys.Count; i++) {
                    forges[i] = _hashKeys[i].HashKey.KeyExpr.Forge;
                }

                var expressions = ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(forges);
                var eval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(
                    forges,
                    _hashKeyCoercionTypes.CoercionTypes,
                    _hashMultikeyClasses,
                    methodNode,
                    classScope);
                
                methodNode.Block.MethodReturn(
                    NewInstance<SubordHashedTableLookupStrategyExprFactory>(
                        Constant(expressions),
                        eval,
                        Constant(isNWOnTrigger),
                        Constant(_numStreamsOuter)));
                return LocalMethod(methodNode);
            }
        }
예제 #4
0
 public CodegenExpression Make(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var expressions = ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(_rangeKey.RangeInfo.Expressions);
     return NewInstance<SubordSortedTableLookupStrategyFactory>(
         Constant(_isNwOnTrigger),
         Constant(_numStreamsOuter),
         Constant(expressions[0]),
         _rangeKey.RangeInfo.Make(_coercionDesc.CoercionTypes[0], parent, symbols, classScope));
 }
 public EventAdvancedIndexProvisionRuntime ToRuntime()
 {
     var runtime = new EventAdvancedIndexProvisionRuntime();
     runtime.IndexExpressionTexts =
         ExprNodeUtilityPrint.ToExpressionStringMinPrecedenceAsArray(IndexDesc.IndexedExpressions);
     runtime.IndexProperties = GetPropertiesPerExpressionExpectSingle(IndexDesc.IndexedExpressions);
     runtime.IndexExpressionsOpt = IndexDesc.IndexedExpressions;
     runtime.IsIndexExpressionsAllProps = IsExpressionsAllPropsOnly(IndexDesc.IndexedExpressions);
     runtime.Factory = Factory.RuntimeFactory;
     runtime.ParameterExpressionTexts = ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(Parameters);
     runtime.ParameterEvaluators = GetEvaluatorsNoCompile(Parameters);
     runtime.ParameterExpressionsOpt = Parameters;
     runtime.ConfigStatement = ConfigStatement.ToRuntime();
     runtime.IndexTypeName = IndexDesc.IndexTypeName;
     return runtime;
 }
예제 #6
0
        public CodegenExpression Make(
            CodegenMethodScope parent,
            SAIFFInitializeSymbol symbols,
            CodegenClassScope classScope)
        {
            var method = parent.MakeChild(typeof(SubordCompositeTableLookupStrategyFactory), GetType(), classScope);

            IList<string> expressions = new List<string>();
            var hashEval = ConstantNull();
            if (_hashKeys != null && !_hashKeys.IsEmpty()) {
                var forges = new ExprForge[_hashKeys.Count];
                for (var i = 0; i < _hashKeys.Count; i++) {
                    forges[i] = _hashKeys[i].HashKey.KeyExpr.Forge;
                }

                expressions.AddAll(ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(forges));
                hashEval = MultiKeyCodegen.CodegenExprEvaluatorMayMultikey(forges, _hashTypes, _hashMultikeyClasses, method, classScope);
            }

            method.Block.DeclareVar<QueryGraphValueEntryRange[]>(
                "rangeEvals",
                NewArrayByLength(typeof(QueryGraphValueEntryRange), Constant(_rangeProps.Count)));
            for (var i = 0; i < _rangeProps.Count; i++) {
                CodegenExpression rangeEval = _rangeProps[i]
                    .RangeInfo.Make(
                        _coercionRangeTypes[i],
                        parent,
                        symbols,
                        classScope);
                method.Block.AssignArrayElement(Ref("rangeEvals"), Constant(i), rangeEval);
            }

            method.Block.MethodReturn(
                NewInstance<SubordCompositeTableLookupStrategyFactory>(
                    Constant(_isNWOnTrigger),
                    Constant(_numStreams),
                    Constant(expressions.ToArray()),
                    hashEval,
                    Ref("rangeEvals")));
            return LocalMethod(method);
        }
 public CodegenExpression Make(
     CodegenMethodScope parent,
     SAIFFInitializeSymbol symbols,
     CodegenClassScope classScope)
 {
     var method = parent.MakeChild(typeof(QueryGraphValueEntryCustomKey), GetType(), classScope);
     method.Block
         .DeclareVar<QueryGraphValueEntryCustomKey>(
             "key",
             NewInstance(typeof(QueryGraphValueEntryCustomKey)))
         .SetProperty(Ref("key"), "OperationName", Constant(OperationName))
         .SetProperty(
             Ref("key"),
             "ExprNodes",
             ExprNodeUtilityCodegen.CodegenEvaluators(ExprNodes, method, GetType(), classScope))
         .SetProperty(
             Ref("key"),
             "Expressions",
             Constant(ExprNodeUtilityPrint.ToExpressionStringsMinPrecedence(ExprNodes)))
         .MethodReturn(Ref("key"));
     return LocalMethod(method);
 }