Bucket for elements with same prefix -- designed for small buckets.
Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        public void Set(string key, object map)
        {
            xBucket bucket;
            string  prefix;
            bool    found = FindBucketForPrefix(key, out bucket, out prefix, false);

            if (!found)
            {
                bucket = new xBucket(this);
            }
            if (!(map is byte[]))
            {
                throw new BplusTreeBadKeyValue("xBplus only accepts byte array values");
            }
            bucket.Add(key, (byte[])map);
            this.tree[prefix] = bucket.dump();
        }
Exemplo n.º 3
0
        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
        }
Exemplo n.º 4
0
 public void Set(string key, object map)
 {
     xBucket bucket;
     string prefix;
     bool found = FindBucketForPrefix(key, out bucket, out prefix, false, true);
     if (!found)
     {
         bucket = new xBucket(this);
     }
     if (!(map is byte[]))
     {
         throw new BplusTreeBadKeyValue("xBplus only accepts byte array values");
     }
     bucket.Add(key, (byte[]) map);
     this.tree[prefix] = bucket.dump();
 }
Exemplo n.º 5
0
 public string NextKey(string AfterThisKey, bool caseSensitive)
 {
     xBucket bucket;
     string prefix;
     string result = null;
     bool found = FindBucketForPrefix(AfterThisKey, out bucket, out prefix, false, caseSensitive);
     if (found)
     {
         result = bucket.NextKey(AfterThisKey, caseSensitive);
         if (result!=null)
         {
             return result;
         }
     }
     // otherwise look in the next bucket
     string nextprefix = this.tree.NextKey(prefix, caseSensitive);
     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();
 }
Exemplo n.º 6
0
 public bool FindBucketForPrefix(string key, out xBucket bucket, out string prefix, bool keyIsPrefix, bool caseSensitive)
 {
     bucket = null;
     prefix = key;
     if (!keyIsPrefix)
     {
         prefix = PrefixForByteCount(key, this.prefixLength);
     }
     object datathing = this.tree.Get(prefix, "", caseSensitive);
     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
 }