public string NextKey(string afterThisKey) { XBucket bucket; string prefix; string result = null; bool found = FindBucketForPrefix(afterThisKey, out bucket, out prefix, false); if (found) { result = bucket.NextKey(afterThisKey); if (result != null) { return(result); } } // otherwise look in the next bucket string nextprefix = this.tree.NextKey(prefix); if (nextprefix == null) { return(null); } byte[] databytes = this.tree[nextprefix]; bucket = new XBucket(this); bucket.Load(databytes); if (bucket.Count() < 1) { throw new BplusTreeException("empty bucket loaded"); } return(bucket.FirstKey()); }
public bool FindBucketForPrefix(string key, out XBucket bucket, out string prefix, bool keyIsPrefix) { bucket = null; prefix = key; if (!keyIsPrefix) { prefix = PrefixForByteCount(key, this.PrefixLength); } object datathing = this.tree.Get(prefix, ""); if (datathing is byte[]) { byte[] databytes = (byte[])datathing; bucket = new XBucket(this); bucket.Load(databytes); if (bucket.Count() < 1) { throw new BplusTreeException("empty bucket loaded"); } return(true); } return(false); // default }