Beispiel #1
0
 public SupportReferenceCountedMapRCMFunctionHandler(
     AggregationMultiFunctionStateKey sharedStateKey,
     ExprNode[] parameterExpressions)
 {
     AggregationStateUniqueKey = sharedStateKey;
     this.parameterExpressions = parameterExpressions;
 }
 internal AggregationMFIdentifier(
     AggregationMultiFunctionStateKey aggregationStateKey,
     ExprAggregateLocalGroupByDesc optionalLocalGroupBy,
     int slot)
 {
     AggregationStateKey = aggregationStateKey;
     OptionalLocalGroupBy = optionalLocalGroupBy;
     Slot = slot;
 }
Beispiel #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;
 }
Beispiel #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);
        }
        private static AggregationMFIdentifier FindExisting(
            Deque<AggregationMFIdentifier> accessProviderSlots,
            AggregationMultiFunctionStateKey providerKey,
            ExprAggregateLocalGroupByDesc optionalOver,
            ExprNode[] groupByNodes)
        {
            foreach (var ident in accessProviderSlots) {
                if (!providerKey.Equals(ident.AggregationStateKey)) {
                    continue;
                }

                // if there is no local-group by, but there is group-by-clause, and the ident-over matches, use that
                if (optionalOver == null &&
                    groupByNodes.Length > 0 &&
                    ident.OptionalLocalGroupBy != null &&
                    ExprNodeUtilityCompare.DeepEqualsIgnoreDupAndOrder(
                        groupByNodes,
                        ident.OptionalLocalGroupBy.PartitionExpressions)) {
                    return ident;
                }

                if (optionalOver == null && ident.OptionalLocalGroupBy == null) {
                    return ident;
                }

                if (optionalOver != null &&
                    ident.OptionalLocalGroupBy != null &&
                    ExprNodeUtilityCompare.DeepEqualsIgnoreDupAndOrder(
                        optionalOver.PartitionExpressions,
                        ident.OptionalLocalGroupBy.PartitionExpressions)) {
                    return ident;
                }
            }

            return null;
        }