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

Build() public method

public Build ( MetricDB db, IList sample = null ) : void
db MetricDB
sample IList
return void
        public virtual void Build(MetricDB db, IList<int> sample = null)
        {
            this.DB = db;
            if (sample == null) {
                sample = RandomSets.GetRandomPermutation (this.DB.Count, RandomSets.GetRandom(-1));
            }
            var nsample = sample.Count;
            this.order = new List<int>(nsample);
            for (int i = nsample - 1; i >= 0; --i) {
                this.order.Add(sample[i]);
            }
            this.docs = new HashSet<int>();
            this.removed = new BitStream32();
            this.removed.Write(false, this.DB.Count);
            foreach (var s in sample) {
                this.docs.Add(s);
            }
        }

Same methods

DynamicSequentialOrdered::Build ( MetricDB db, Random rand ) : void

Usage Example

Ejemplo n.º 1
0
Archivo: LC.cs Proyecto: sadit/natix
 /// <summary>
 /// Build the index
 /// </summary>
 public virtual void Build(MetricDB db, int bsize, Random rand)
 {
     this.DB = db;
     var n = this.DB.Count;
     // randomized has very good performance, even compared with more "intelligent" strategies
     var dseq = new DynamicSequentialOrdered ();
     dseq.Build (db, rand);
     this.NODES = new List<Node> (n / bsize + 1);
     var L = new List<ItemPair> (n);
     while (dseq.Count > 0) {
         if (this.NODES.Count % 100 == 0) {
             Console.WriteLine ("XXX {0}, bucketSize: {1}, remain {2}/{3}, db: {4}, date-time: {5}",
                                this, bsize, dseq.Count, db.Count, Path.GetFileName(db.Name), DateTime.Now);
         }
         var refID = dseq.GetAnyItem ();
         dseq.Remove (refID);
         L.Clear ();
         dseq.ComputeDistances (this.DB[refID], L);
         var near = new Result(bsize);
         var far = new Result (1);
         dseq.AppendKExtremes (near, far, L);
         var node = new Node (refID);
         this.NODES.Add (node);
         dseq.Remove (near);
         foreach (var p in near) {
             node.Add(p.ObjID, p.Dist);
         }
     }
 }
All Usage Examples Of natix.SimilaritySearch.DynamicSequentialOrdered::Build