Пример #1
0
        public AggregatorPlugInMultiParam(
            AggregationForgeFactoryPlugin factory,
            int col,
            CodegenCtor rowCtor,
            CodegenMemberCol membersColumnized,
            CodegenClassScope classScope,
            AggregationFunctionModeMultiParam mode)
        {
            this.mode = mode;
            var injectionStrategy =
                (InjectionStrategyClassNewInstance) mode.InjectionStrategyAggregationFunctionFactory;
            var factoryField = classScope.AddDefaultFieldUnshared<AggregationFunctionFactory>(
                true,
                injectionStrategy.GetInitializationExpression(classScope));

            plugin = membersColumnized.AddMember(col, typeof(AggregationFunction), "plugin");
            rowCtor.Block.AssignRef(plugin, ExprDotMethod(factoryField, "NewAggregator", ConstantNull()));
        }
Пример #2
0
        public override void InitMethodForge(
            int col,
            CodegenCtor rowCtor,
            CodegenMemberCol membersColumnized,
            CodegenClassScope classScope)
        {
            if (mode is AggregationFunctionModeManaged)
            {
                AggregationFunctionModeManaged singleValue = (AggregationFunctionModeManaged)mode;
                if (parent.PositionalParams.Length == 0)
                {
                    throw new ArgumentException(typeof(AggregationFunctionModeManaged).Name + " requires at least one positional parameter");
                }

                Type distinctType = !parent.IsDistinct ? null : aggregatedValueType;
                aggregator = new AggregatorPlugInManaged(
                    this,
                    col,
                    rowCtor,
                    membersColumnized,
                    classScope,
                    distinctType,
                    distinctSerde,
                    parent.ChildNodes.Length > 1,
                    parent.OptionalFilter,
                    singleValue);
            }
            else if (mode is AggregationFunctionModeMultiParam)
            {
                AggregationFunctionModeMultiParam multiParam = (AggregationFunctionModeMultiParam)mode;
                aggregator = new AggregatorPlugInMultiParam(this, col, rowCtor, membersColumnized, classScope, multiParam);
            }
            else if (mode is AggregationFunctionModeCodeGenerated)
            {
                AggregationFunctionModeCodeGenerated codeGenerated = (AggregationFunctionModeCodeGenerated)mode;
                aggregator = codeGenerated.AggregatorMethodFactory.GetAggregatorMethod(
                    new AggregatorMethodFactoryContext(col, rowCtor, membersColumnized, classScope));
            }
            else
            {
                throw new IllegalStateException("Received an unrecognized value for mode, the value is " + mode);
            }
        }