BplusDotNet.xBucket.Load C# (CSharp) Метод

Load() публичный Метод

public Load ( byte serialization ) : void
serialization byte
Результат void
        public void Load(byte[] serialization)
        {
            int index = 0;
            int byteCount = serialization.Length;
            if (this.values.Count!=0 || this.keys.Count!=0)
            {
                throw new BplusTreeException("load into nonempty xBucket not permitted");
            }
            while (index<byteCount)
            {
                // get key prefix and key
                int keylength = BufferFile.Retrieve(serialization, index);
                index += BufferFile.INTSTORAGE;
                byte[] keybytes = new byte[keylength];
                Array.Copy(serialization, index, keybytes, 0, keylength);
                string keystring = BplusTree.BytesToString(keybytes);
                index+= keylength;
                // get value prefix and value
                int valuelength = BufferFile.Retrieve(serialization, index);
                index += BufferFile.INTSTORAGE;
                byte[] valuebytes = new byte[valuelength];
                Array.Copy(serialization, index, valuebytes, 0, valuelength);
                // record new key and value
                this.keys.Add(keystring);
                this.values.Add(valuebytes);
                index+= valuelength;
            }
            if (index!=byteCount)
            {
                throw new BplusTreeException("bad byte count in serialization "+byteCount);
            }
        }

Usage Example

Пример #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());
        }
All Usage Examples Of BplusDotNet.xBucket::Load