public virtual void Build(MetricDB db, int num_pairs, int maxCandidates = -1) { this.DB = db; this.Fingerprints = new BinQ8HammingSpace (1); this.Sample = new SampleSpace("", this.DB, num_pairs * 2); this.MaxCandidates = maxCandidates; var n = this.DB.Count; var A = new byte[n][]; int pc = this.DB.Count / 100 + 1; int advance = 0; var create_one = new Action<int> (delegate(int i) { var fp = this.GetFP(this.DB[i]); A[i] = fp; if (advance % pc == 0) { Console.WriteLine ("DEBUG {0} ({1}/{2}), db: {3}, num_pairs: {4}, timestamp: {5}", this, advance, n, db.Name, num_pairs, DateTime.Now); } advance++; }); ParallelOptions ops = new ParallelOptions(); ops.MaxDegreeOfParallelism = -1; Parallel.For (0, n, create_one); foreach (var fp in A) { this.Fingerprints.Add( fp ); } var s = new Sequential (); s.Build (this.Fingerprints); this.InternalIndex = s; }
public virtual void Build(MetricDB original, MetricDB pairs) { this.Fingerprints = new BinQ8HammingSpace (1); this.Pairs = pairs; var n = original.Count; var A = new byte[n][]; int blocksize = 1000; int pc = original.Count / 100 + 1; int advance = 0; var create_block = new Action<int> (delegate(int blockID) { var sp = blockID * blocksize; var ep = Math.Min (n, sp + blocksize); for (; sp < ep; ++sp) { var fp = this.GetFP(original[sp]); A[sp] = fp; if (advance % pc == 0) { Console.WriteLine ("DEBUG {0} ({1}/{2}), db: {3}, num_pairs: {4}, timestamp: {5}", this, advance, n, original.Name, this.Pairs.Count/2, DateTime.Now); } advance++; } }); ParallelOptions ops = new ParallelOptions(); ops.MaxDegreeOfParallelism = 1; Parallel.For (0, 1 + n/blocksize, create_block); foreach (var fp in A) { this.Fingerprints.Add( fp ); } }
public override void Load(BinaryReader Input) { base.Load (Input); this.Sample = SpaceGenericIO.SmartLoad (Input, false); this.InternalIndex = IndexGenericIO.Load (Input); this.Fingerprints = this.InternalIndex.DB as BinQ8HammingSpace; }
public void Load(BinaryReader Input) { this.Name = Input.ReadString (); this.Pairs = SpaceGenericIO.SmartLoad (Input, false); this.Fingerprints = SpaceGenericIO.SmartLoad(Input, false) as BinQ8HammingSpace; }