public void SetNewHashFunction(LSHashFunction hashFunction) { lock (accessLock) { Dictionary<CustomBitArray, LSHashTableCell> oldValues = _values; _values = new Dictionary<CustomBitArray, LSHashTableCell>(); _hashFunction = hashFunction; //Re-hash all the old tweets using the new hash function foreach (LSHashTableCell oldCell in oldValues.Values) { foreach (LSHashTweet tweet in oldCell.GetTweets()) { bool anyTrue = false; CustomBitArray hash = _hashFunction.CalculateHashScore(tweet.Vector, out anyTrue); LSHashTableCell cell; if (_values.TryGetValue(hash, out cell)) { cell.Add(tweet); } else { cell = new LSHashTableCell(_cellCapacity); cell.Add(tweet); _values.Add(hash, cell); } } } } }
public void SetNewHashFunction(LSHashFunction hashFunction) { lock (accessLock) { Dictionary <CustomBitArray, LSHashTableCell> oldValues = _values; _values = new Dictionary <CustomBitArray, LSHashTableCell>(); _hashFunction = hashFunction; //Re-hash all the old tweets using the new hash function foreach (LSHashTableCell oldCell in oldValues.Values) { foreach (LSHashTweet tweet in oldCell.GetTweets()) { bool anyTrue = false; CustomBitArray hash = _hashFunction.CalculateHashScore(tweet.Vector, out anyTrue); LSHashTableCell cell; if (_values.TryGetValue(hash, out cell)) { cell.Add(tweet); } else { cell = new LSHashTableCell(_cellCapacity); cell.Add(tweet); _values.Add(hash, cell); } } } } }
public void UpdateOldestHashFunction() { //Create a hash function and hash table LSHashFunction hashFunc = GetNewHashFunction(); _tables[_nextTableRehashIndex].SetNewHashFunction(hashFunc); _nextTableRehashIndex = (_nextTableRehashIndex + 1) % Settings.TweetClusterer_TCW_HashTableCount; }
public void CreateHashTables() { for (int i = 0; i < Settings.TweetClusterer_TCW_HashTableCount; i++) { Console.Write("Making new hash table"); LSHashFunction hashFunc = GetNewHashFunction(); _tables.Add(new LSHashTable(hashFunc, Settings.TweetClusterer_TCW_HashBinSize)); Console.WriteLine(" done"); } }
public LSHashTable(LSHashFunction hashFunction, int cellCapacity) { _hashFunction = hashFunction; _cellCapacity = cellCapacity; }
public LSHashTable(LSHashFunction hashFunction, int cellCapacity) { _hashFunction = hashFunction; _cellCapacity = cellCapacity; }