Пример #1
0
        public PlanFragment(
            PlanFragmentId id,
            PlanNode root,
            IDictionary <string, string> symbols,
            PartitioningHandle partitioning,
            IEnumerable <PlanNodeId> partitionedSources,
            PartitioningScheme partitioningScheme,
            PipelineExecutionStrategy pipelineExecutionStrategy
            )
        {
            this.Id                        = id ?? throw new ArgumentNullException("id");
            this.Root                      = root ?? throw new ArgumentNullException("root");
            this.Symbols                   = symbols ?? throw new ArgumentNullException("symbols");
            this.Partitioning              = partitioning ?? throw new ArgumentNullException("partitioning");
            this.PartitionedSources        = partitionedSources ?? throw new ArgumentNullException("partitionedSources");
            this.PipelineExecutionStrategy = pipelineExecutionStrategy;
            this.PartitioningScheme        = partitioningScheme ?? throw new ArgumentNullException("partitioningScheme");

            ParameterCheck.Check(this.PartitionedSources.Distinct().Count() == this.PartitionedSources.Count(), "PartitionedSources contains duplicates.");

            this.Types = this.PartitioningScheme.OutputLayout.Select(x => x.ToString());
            // Materialize this during construction
            this.PartionedSourceNodes = new HashSet <PlanNode>(FindSources(this.Root, this.PartitionedSources));
            this.RemoteSourceNodes    = FindRemoteSourceNodes(this.Root).ToList();
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JToken Tokens = JToken.Load(reader);

            // These two are native to the flattened plan
            string TextPlan = Tokens["textPlan"].ToString();
            IEnumerable <FlattenedNode> Nodes = Tokens["nodes"].ToObject <IEnumerable <FlattenedNode> >();

            // These properties are derived from the PlanFragment
            PlanFragmentId Id   = new PlanFragmentId(Tokens["id"].ToObject <string>(serializer));
            PlanNode       Root = Tokens["tree"].ToObject <PlanNode>(serializer);
            IDictionary <string, string> Symbols            = Tokens["symbols"].ToObject <Dictionary <string, string> >(serializer);
            PartitioningHandle           Partitioning       = Tokens["partitioning"].ToObject <PartitioningHandle>(serializer);
            IEnumerable <PlanNodeId>     PartitionedSources = Tokens["partitionedSources"].ToObject <IEnumerable <PlanNodeId> >(serializer);
            PartitioningScheme           PartitioningScheme = Tokens["partitioningScheme"].ToObject <PartitioningScheme>(serializer);

            // The pipeline execution strategy doesn't really matter because the flattened plan doesn't expose it
            PlanFragment Fragment = new PlanFragment(Id, Root, Symbols, Partitioning, PartitionedSources, PartitioningScheme, PipelineExecutionStrategy.UNGROUPED_EXECUTION);

            return(new FlattenedPlanFragment(TextPlan, Fragment, Nodes));
        }