private ParallelMultiCountTableBuilder(IHostEnvironment env, MultiCountTable table, DataViewSchema.Column[] inputCols, long labelCardinality)
        {
            Contracts.AssertValue(env, nameof(env));
            env.AssertValue(table, nameof(table));
            _host = env.Register(RegistrationName);

            var n = table.ColCount;

            _host.Check(Utils.Size(inputCols) == n, "Inconsistent number of columns");
            _countTableBuilders = new InternalCountTableBuilderBase[n][];
            var slotCounts = table.SlotCount;

            for (int i = 0; i < _countTableBuilders.Length; i++)
            {
                var size = slotCounts[i];
                _host.Assert(size > 0);
                _host.Check(size == inputCols[i].Type.GetValueCount(), "Inconsistent number of slots");
                _countTableBuilders[i] = new InternalCountTableBuilderBase[size];

                for (int j = 0; j < size; j++)
                {
                    _countTableBuilders[i][j] = ((CountTableBase)table[i, j]).ToBuilder(labelCardinality);
                }
            }
        }
        public ParallelMultiCountTableBuilder(IHostEnvironment env,
                                              DataViewSchema.Column[] inputColumns,
                                              CountTableBuilderBase[] builders,
                                              long labelCardinality)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(inputColumns, nameof(inputColumns));
            _host = env.Register(RegistrationName);

            var n = inputColumns.Length;

            _countTableBuilders = new InternalCountTableBuilderBase[n][];
            for (int i = 0; i < _countTableBuilders.Length; i++)
            {
                var col  = inputColumns[i];
                var size = col.Type.GetValueCount();
                _host.Check(size > 0, "vectors of unknown length are not supported");
                _countTableBuilders[i] = new InternalCountTableBuilderBase[size];

                for (int j = 0; j < size; j++)
                {
                    _countTableBuilders[i][j] = builders[i].GetInternalBuilder(labelCardinality);
                }
            }
        }
        public BagMultiCountTableBuilder(IHostEnvironment env, MultiCountTable table, DataViewSchema.Column[] inputCols, long labelCardinality)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(table, nameof(table));
            _host = env.Register(LoaderSignature);
            _host.Check(Utils.Size(inputCols) == table.ColCount, "Inconsistent number of columns");
            _host.Check(table.SlotCount.Zip(inputCols, (count, col) => (count, col)).
                        All(pair => pair.col.Type.GetValueCount() == pair.count), "Inconsistent number of slots");

            _builder   = table.BaseTable.ToBuilder(labelCardinality);
            _colCount  = table.ColCount;
            _slotCount = new int[_colCount];
            table.SlotCount.CopyTo(_slotCount, 0);
        }
        public BagMultiCountTableBuilder(IHostEnvironment env, DataViewSchema.Column[] inputColumns, CountTableBuilderBase builder, long labelCardinality)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckNonEmpty(inputColumns, nameof(inputColumns));
            _host = env.Register(LoaderSignature);

            // REVIEW: how to disallow non-zero garbage bin for bag dict count table? Or maybe just ignore?
            _builder   = builder.GetInternalBuilder(labelCardinality);
            _colCount  = inputColumns.Length;
            _slotCount = new int[_colCount];
            for (int i = 0; i < _colCount; i++)
            {
                _slotCount[i] = inputColumns[i].Type.GetValueCount();
            }
        }