public TableMetadataColumnPairAggAccess(
     int dest,
     AggregationAccessorForge accessor)
     : base(dest)
 {
     Accessor = accessor;
 }
 /// <summary>
 ///     Ctor.
 /// </summary>
 /// <param name="slot">number of accessorForge</param>
 /// <param name="accessorForge">accessorForge</param>
 public AggregationAccessorSlotPairForge(
     int slot,
     AggregationAccessorForge accessorForge)
 {
     Slot = slot;
     AccessorForge = accessorForge;
 }
Пример #3
0
 public AggregationForgeFactoryAccessSorted(
     ExprAggMultiFunctionSortedMinMaxByNode parent,
     AggregationAccessorForge accessor,
     Type accessorResultType,
     EventType containedEventType,
     AggregationMultiFunctionStateKey optionalStateKey,
     SortedAggregationStateDesc optionalSortedStateDesc,
     AggregationAgentForge optionalAgent)
 {
     Parent = parent;
     AccessorForge = accessor;
     ResultType = accessorResultType;
     ContainedEventType = containedEventType;
     this.optionalStateKey = optionalStateKey;
     OptionalSortedStateDesc = optionalSortedStateDesc;
     this.optionalAgent = optionalAgent;
 }
Пример #4
0
 public AggregationForgeFactoryAccessLinear(
     ExprAggMultiFunctionLinearAccessNode parent,
     AggregationAccessorForge accessor,
     Type accessorResultType,
     AggregationMultiFunctionStateKey optionalStateKey,
     AggregationStateFactoryForge optionalStateFactory,
     AggregationAgentForge optionalAgent,
     EventType containedEventType)
 {
     this.parent = parent;
     AccessorForge = accessor;
     ResultType = accessorResultType;
     this.optionalStateKey = optionalStateKey;
     this.optionalStateFactory = optionalStateFactory;
     this.optionalAgent = optionalAgent;
     this.containedEventType = containedEventType;
 }
        // handle accessor aggregation (direct data window by-group access to properties)
        public static AggregationMultiFunctionAnalysisResult AnalyzeAccessAggregations(
            IList<AggregationServiceAggExpressionDesc> aggregations,
            ImportServiceCompileTime importService,
            bool isFireAndForget,
            string statementName,
            ExprNode[] groupByNodes)
        {
            var currentSlot = 0;
            Deque<AggregationMFIdentifier> accessProviderSlots = new ArrayDeque<AggregationMFIdentifier>();
            IList<AggregationAccessorSlotPairForge> accessorPairsForges = new List<AggregationAccessorSlotPairForge>();
            IList<AggregationStateFactoryForge> stateFactoryForges = new List<AggregationStateFactoryForge>();

            foreach (var aggregation in aggregations) {
                var aggregateNode = aggregation.AggregationNode;
                if (!aggregateNode.Factory.IsAccessAggregation) {
                    continue;
                }

                AggregationMultiFunctionStateKey providerKey = aggregateNode.Factory.GetAggregationStateKey(false);
                var existing = FindExisting(
                    accessProviderSlots,
                    providerKey,
                    aggregateNode.OptionalLocalGroupBy,
                    groupByNodes);

                int slot;
                if (existing == null) {
                    accessProviderSlots.Add(
                        new AggregationMFIdentifier(providerKey, aggregateNode.OptionalLocalGroupBy, currentSlot));
                    slot = currentSlot++;
                    AggregationStateFactoryForge
                        providerForge = aggregateNode.Factory.GetAggregationStateFactory(false);
                    stateFactoryForges.Add(providerForge);
                }
                else {
                    slot = existing.Slot;
                }

                AggregationAccessorForge accessorForge = aggregateNode.Factory.AccessorForge;
                accessorPairsForges.Add(new AggregationAccessorSlotPairForge(slot, accessorForge));
            }

            AggregationAccessorSlotPairForge[] forges = accessorPairsForges.ToArray();
            AggregationStateFactoryForge[] accessForges = stateFactoryForges.ToArray();
            return new AggregationMultiFunctionAnalysisResult(forges, accessForges);
        }
Пример #6
0
        // Obtain those method and state factories for each level
        private static AggregationLocalGroupByLevelForge GetLevel(
            int levelNumber,
            AggregationGroupByLocalGroupLevel level,
            ExprForge[][] methodForgesAll,
            AggregationForgeFactory[] methodFactoriesAll,
            AggregationStateFactoryForge[] accessForges,
            AggregationLocalGroupByColumnForge[] columns,
            bool defaultLevel,
            AggregationAccessorSlotPairForge[] accessors,
            ImportService importService,
            bool isFireAndForget,
            string statementName)
        {
            var partitionExpr = level.PartitionExpr;
            ExprForge[] partitionForges = ExprNodeUtilityQuery.GetForges(partitionExpr);

            IList<ExprForge[]> methodForges = new List<ExprForge[]>();
            IList<AggregationForgeFactory> methodFactories = new List<AggregationForgeFactory>();
            IList<AggregationStateFactoryForge> stateFactories = new List<AggregationStateFactoryForge>();

            foreach (var expr in level.Expressions) {
                int column = expr.AggregationNode.Column;
                var methodOffset = -1;
                var methodAgg = true;
                AggregationAccessorSlotPairForge pair = null;

                if (column < methodForgesAll.Length) {
                    methodForges.Add(methodForgesAll[column]);
                    methodFactories.Add(methodFactoriesAll[column]);
                    methodOffset = methodFactories.Count - 1;
                }
                else {
                    // slot gives us the number of the state factory
                    int absoluteSlot = accessors[column - methodForgesAll.Length].Slot;
                    AggregationAccessorForge accessor = accessors[column - methodForgesAll.Length].AccessorForge;
                    var factory = accessForges[absoluteSlot];
                    var relativeSlot = stateFactories.IndexOf(factory);
                    if (relativeSlot == -1) {
                        stateFactories.Add(factory);
                        relativeSlot = stateFactories.Count - 1;
                    }

                    methodAgg = false;
                    pair = new AggregationAccessorSlotPairForge(relativeSlot, accessor);
                }

                columns[column] = new AggregationLocalGroupByColumnForge(
                    defaultLevel,
                    partitionForges,
                    methodOffset,
                    methodAgg,
                    pair,
                    levelNumber);
            }

            return new AggregationLocalGroupByLevelForge(
                methodForges.ToArray(),
                methodFactories.ToArray(),
                stateFactories.ToArray(),
                partitionForges,
                defaultLevel);
        }
        // Obtain those method and state factories for each level
        private static AggregationGroupByLocalGroupLevelDesc GetLevel(
            int levelNumber,
            AggregationGroupByLocalGroupLevel level,
            ExprForge[][] methodForgesAll,
            AggregationForgeFactory[] methodFactoriesAll,
            AggregationStateFactoryForge[] accessForges,
            AggregationLocalGroupByColumnForge[] columns,
            bool defaultLevel,
            AggregationAccessorSlotPairForge[] accessors,
            ExprNode[] groupByExpressions,
            MultiKeyClassRef optionalGroupByMultiKey,
            StatementRawInfo raw,
            SerdeCompileTimeResolver serdeResolver)
        {
            var partitionExpr = level.PartitionExpr;
            MultiKeyPlan multiKeyPlan;
            if (defaultLevel && optionalGroupByMultiKey != null) { // use default multi-key that is already generated
                multiKeyPlan = new MultiKeyPlan(EmptyList<StmtClassForgeableFactory>.Instance, optionalGroupByMultiKey);
                partitionExpr = groupByExpressions;
            } else {
                multiKeyPlan = MultiKeyPlanner.PlanMultiKey(partitionExpr, false, raw, serdeResolver);
            }

            IList<ExprForge[]> methodForges = new List<ExprForge[]>();
            IList<AggregationForgeFactory> methodFactories = new List<AggregationForgeFactory>();
            IList<AggregationStateFactoryForge> stateFactories = new List<AggregationStateFactoryForge>();

            foreach (var expr in level.Expressions) {
                int column = expr.AggregationNode.Column;
                var methodOffset = -1;
                var methodAgg = true;
                AggregationAccessorSlotPairForge pair = null;

                if (column < methodForgesAll.Length) {
                    methodForges.Add(methodForgesAll[column]);
                    methodFactories.Add(methodFactoriesAll[column]);
                    methodOffset = methodFactories.Count - 1;
                }
                else {
                    // slot gives us the number of the state factory
                    int absoluteSlot = accessors[column - methodForgesAll.Length].Slot;
                    AggregationAccessorForge accessor = accessors[column - methodForgesAll.Length].AccessorForge;
                    var factory = accessForges[absoluteSlot];
                    var relativeSlot = stateFactories.IndexOf(factory);
                    if (relativeSlot == -1) {
                        stateFactories.Add(factory);
                        relativeSlot = stateFactories.Count - 1;
                    }

                    methodAgg = false;
                    pair = new AggregationAccessorSlotPairForge(relativeSlot, accessor);
                }

                columns[column] = new AggregationLocalGroupByColumnForge(
                    defaultLevel,
                    partitionExpr,
                    methodOffset,
                    methodAgg,
                    pair,
                    levelNumber);
            }

            var forge = new AggregationLocalGroupByLevelForge(
                methodForges.ToArray(),
                methodFactories.ToArray(),
                stateFactories.ToArray(),
                partitionExpr,
                multiKeyPlan.ClassRef,
                defaultLevel);

            // NOTE: The original code tests for multiKeyPlan being null, but if it was null it would have caused
            // a null pointer exception on the previous statement since it dereferences ClassRef.
            var additionalForgeables = multiKeyPlan?.MultiKeyForgeables ?? EmptyList<StmtClassForgeableFactory>.Instance;
            
            return new AggregationGroupByLocalGroupLevelDesc(forge, additionalForgeables);
        }