public bool Get(Guid key, out byte[] val) { val = null; var bkey = key.ToByteArray(); int hc = (int)Helper.Murmur.Hash(bkey); if (_db.Get(hc, out val)) { // unpack data byte[] g; if (UnpackData(val, out val, out g)) { if (!Helper.BytewiseEquals(bkey, g)) { // if data not equal check duplicates (hash conflict) var ints = new List <int>(_db.GetDuplicates(hc)); ints.Reverse(); foreach (int i in ints) { var bb = _db.FetchRecordBytes(i); if (UnpackData(bb, out val, out g)) { if (Helper.BytewiseEquals(bkey, g)) { return(true); } } } return(false); } return(true); } } return(false); }
public bool Get(string key, out byte[] val) { string str = (_caseSensitive ? key : key.ToLower()); val = null; var bkey = Encoding.Unicode.GetBytes(str); int hc = (int)Helper.Murmur.Hash(bkey); if (_db.Get(hc, out val)) { // unpack data byte[] g; if (UnpackData(val, out val, out g)) { if (!Helper.BytewiseEquals(bkey, g)) { // if data not equal check duplicates (hash conflict) var ints = new List <int>(_db.GetDuplicates(hc)); ints.Reverse(); foreach (int i in ints) { var bb = _db.FetchRecordBytes(i); if (UnpackData(bb, out val, out g)) { if (Helper.BytewiseEquals(bkey, g)) { return(true); } } } return(false); } return(true); } } return(false); }