Beispiel #1
0
 public AIRegistrySubqueryEntry(
     AIRegistrySubselectLookup lookupStrategies,
     AIRegistryAggregation aggregationServices,
     AIRegistryPriorEvalStrategy priorEvalStrategies,
     AIRegistryPreviousGetterStrategy previousGetterStrategies)
 {
     LookupStrategies = lookupStrategies;
     AggregationServices = aggregationServices;
     PriorEvalStrategies = priorEvalStrategies;
     PreviousGetterStrategies = previousGetterStrategies;
 }
Beispiel #2
0
        public static StatementAIResourceRegistry AllocateRegistries(
            AIRegistryRequirements registryRequirements,
            AIRegistryFactory factory)
        {
            AIRegistryPriorEvalStrategy[] priorEvalStrategies = null;
            if (registryRequirements.PriorFlagsPerStream != null) {
                bool[] priorFlagPerStream = registryRequirements.PriorFlagsPerStream;
                priorEvalStrategies = new AIRegistryPriorEvalStrategy[priorFlagPerStream.Length];
                for (var i = 0; i < priorEvalStrategies.Length; i++) {
                    if (priorFlagPerStream[i]) {
                        priorEvalStrategies[i] = factory.MakePrior();
                    }
                }
            }

            AIRegistryPreviousGetterStrategy[] previousGetterStrategies = null;
            if (registryRequirements.PreviousFlagsPerStream != null) {
                bool[] previousFlagPerStream = registryRequirements.PreviousFlagsPerStream;
                previousGetterStrategies = new AIRegistryPreviousGetterStrategy[previousFlagPerStream.Length];
                for (var i = 0; i < previousGetterStrategies.Length; i++) {
                    if (previousFlagPerStream[i]) {
                        previousGetterStrategies[i] = factory.MakePrevious();
                    }
                }
            }

            IDictionary<int, AIRegistrySubqueryEntry> subselects = null;
            if (registryRequirements.Subqueries != null) {
                AIRegistryRequirementSubquery[] requirements = registryRequirements.Subqueries;
                subselects = new Dictionary<int, AIRegistrySubqueryEntry>();
                for (var i = 0; i < requirements.Length; i++) {
                    var lookup = factory.MakeSubqueryLookup(requirements[i].LookupStrategyDesc);
                    var aggregation = requirements[i].HasAggregation ? factory.MakeAggregation() : null;
                    var prior = requirements[i].HasPrior ? factory.MakePrior() : null;
                    var prev = requirements[i].HasPrev ? factory.MakePrevious() : null;
                    subselects.Put(i, new AIRegistrySubqueryEntry(lookup, aggregation, prior, prev));
                }
            }

            IDictionary<int, AIRegistryTableAccess> tableAccesses = null;
            if (registryRequirements.TableAccessCount > 0) {
                tableAccesses = new Dictionary<int, AIRegistryTableAccess>();
                for (var i = 0; i < registryRequirements.TableAccessCount; i++) {
                    var strategy = factory.MakeTableAccess();
                    tableAccesses.Put(i, strategy);
                }
            }

            AIRegistryRowRecogPreviousStrategy rowRecogPreviousStrategy = null;
            if (registryRequirements.IsRowRecogWithPrevious) {
                rowRecogPreviousStrategy = factory.MakeRowRecogPreviousStrategy();
            }

            return new StatementAIResourceRegistry(
                factory.MakeAggregation(),
                priorEvalStrategies,
                subselects,
                tableAccesses,
                previousGetterStrategies,
                rowRecogPreviousStrategy);
        }