natix.SimilaritySearch.PivotGroupIndex.Build C# (CSharp) Method

Build() public method

public Build ( MetricDB db, int num_groups, double alpha, int min_bs, bool do_far = true, int num_build_processors = -1, Func new_pivot_group = null ) : void
db MetricDB
num_groups int
alpha double
min_bs int
do_far bool
num_build_processors int
new_pivot_group Func
return void
        public virtual void Build(MetricDB db, int num_groups, double alpha, int min_bs, bool do_far = true, int num_build_processors = -1, Func<PivotGroup> new_pivot_group = null)
        {
            this.DB = db;
            this.InitGROUPS (num_groups);
            var seeds = new int[ num_groups ];
            for (int i = 0; i < num_groups; ++i) {
                seeds[i] = RandomSets.GetRandomInt();
            }
            ParallelOptions ops = new ParallelOptions ();
            ops.MaxDegreeOfParallelism = num_build_processors;
            // Parallel.For (0, num_groups, ops, (i) => this.GROUPS[i] = this.GetGroup(percentil));
            int I = 0;
            var build_one_group = new Action<int> (delegate(int i) {
                if (new_pivot_group == null) {
                    this.GROUPS[i] = new PivotGroup();
                } else {
                    this.GROUPS[i] = new_pivot_group();
                }
                this.GROUPS[i].Build(this.DB, alpha, min_bs, seeds[i], do_far);
                // this.GROUPS [i] = this.GetGroup (alpha_stddev, min_bs);
                Console.WriteLine ("Advance {0}/{1} (alpha={2}, db={3}, timestamp={4})",
                                   I, num_groups, alpha, db.Name, DateTime.Now);
                I++;
            });

            if (num_build_processors == 1 || num_build_processors == 0) {
                //Parallel.ForEach (new List<int>(RandomSets.GetExpandedRange (num_groups)), ops, build_one);
                for (int i = 0; i < num_groups; ++i) {
                    //this.GROUPS[i] = this.GetGroup(percentil);
                    build_one_group (i);
                    if (i % 5 == 0) {
                        Console.WriteLine ("*** Procesing groups ({0}/{1}) ***", i, num_groups);
                    }
                }
            } else {
                Parallel.For (0, num_groups, ops, build_one_group);
            }
        }

Same methods

PivotGroupIndex::Build ( PivotGroupIndex pgi, int num_groups ) : void