natix.CompactDS.Plain64InvertedIndex.AddItem C# (CSharp) Method

AddItem() public method

public AddItem ( int symbol, long item ) : void
symbol int
item long
return void
        public void AddItem(int symbol, long item)
        {
            try {
                if (this.table [symbol] == null) {
                    this.table [symbol] = new List<long> ();
                }
                this.table [symbol].Add (item);
                ++this.numberOfItems;
            } catch (Exception e){
                Console.WriteLine ("---- symbol: {0}, size: {1}", symbol, this.table.Count);
                throw e;
            }
        }

Usage Example

Ejemplo n.º 1
0
Archivo: LSH.cs Proyecto: sadit/natix
        public virtual void Build(MetricDB db, int width, Random rand, Func<InvertedIndex,InvertedIndex> create_invertedindex = null, Func<int,object> get_item = null)
        {
            this.DB = db;
            this.Width = width;

            int len = this.DB.Count;
            int pc = len / 100 + 1;
            int numbits = width > 32 ? 32 : width;

            Plain64InvertedIndex table = new Plain64InvertedIndex ();
            table.Initialize (1 << numbits);
            int maxhash = 0;

            this.PreBuild (rand, this.DB [0]);
            for (int objID = 0; objID < len; objID++) {
                if (objID % pc == 0) {
                    Console.WriteLine ("Advance: {0:0.00}%, docid: {1}, total: {2}", objID * 100.0 / len, objID, len);
                }
                int hash;
                if (get_item == null) {
                    hash = this.ComputeHash (this.DB [objID]);
                } else {
                    hash = this.ComputeHash (get_item (objID));
                }

                table.AddItem(hash, objID);
                if (hash > maxhash) {
                    maxhash = hash;
                }
            }

            table.Trim (maxhash + 1);
            if (create_invertedindex == null) {
                this.invindex = table;
            } else {
                this.invindex = create_invertedindex (table);
            }
        }