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