コード例 #1
0
        public TableDef(string tabName, List <ColumnDef> columns, string distributedBy)
        {
            int npart = 1;
            Dictionary <string, ColumnDef> cols = new Dictionary <string, ColumnDef>();

            foreach (var c in columns)
            {
                cols.Add(c.name_, c);
            }
            name_ = tabName; columns_ = cols;

            if (distributedBy != null)
            {
                cols.TryGetValue(distributedBy, out var partcol);
                if (partcol is null)
                {
                    throw new SemanticAnalyzeException($"can't find distribution column '{distributedBy}'");
                }
                distributedBy_ = partcol;
                npart          = QueryOption.num_machines_;
            }
            for (int i = 0; i < npart; i++)
            {
                distributions_.Add(new Distribution());
            }
        }
コード例 #2
0
ファイル: Catalog.cs プロジェクト: pkommoju/qpmodel
        public TableDef(TableSource source, string tabName, List <ColumnDef> columns, string distributedBy)
        {
            int npart = 1;
            Dictionary <string, ColumnDef> cols = new Dictionary <string, ColumnDef>();

            foreach (var c in columns)
            {
                cols.Add(c.name_, c);
            }
            source_  = source;
            name_    = Utils.normalizeName(tabName);
            columns_ = cols;
            Debug.Assert(distMethod_ == DistributionMethod.NonDistributed);

            if (distributedBy != null)
            {
                ColumnDef partcol;
                if (distributedBy == "REPLICATED")
                {
                    distMethod_ = DistributionMethod.Replicated;
                }
                else if (distributedBy == "ROUNDROBIN")
                {
                    distMethod_ = DistributionMethod.Roundrobin;
                }
                else
                {
                    cols.TryGetValue(distributedBy, out partcol);
                    if (partcol is null)
                    {
                        throw new SemanticAnalyzeException($"can't find distribution column '{distributedBy}'");
                    }

                    distMethod_    = DistributionMethod.Distributed;
                    distributedBy_ = partcol;
                }
                npart = QueryOption.num_machines_;
            }
            for (int i = 0; i < npart; i++)
            {
                distributions_.Add(new Distribution());
            }
            Debug.Assert(distributedBy_ is null || distMethod_ == DistributionMethod.Distributed);
        }