Esempio n. 1
0
 /// <summary>
 /// Generates a user-defined type (UDT) or user-defined aggregate from its binary form.
 /// </summary>
 /// <param name="r">The <see cref="T:System.IO.BinaryReader"/> stream from which the object is deserialized.</param>
 public void Read(BinaryReader r)
 {
     PlainIndex.Clear();
     RootBucket = new BTreeBucket <TKey, TKeyData, TData> {
         Index = this
     };
     RootBucket.Read(r);
     RootBucketId             = RootBucket.Id;
     PlainIndex[RootBucketId] = RootBucket;
 }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BTreeBucket <TKey, TKeyData, TData> LoadBucket(int id)
        {
            if (null == Storage)
            {
                throw new Exception("no storage configured");
            }
            var bucket = new BTreeBucket <TKey, TKeyData, TData> {
                Id = id, Index = this
            };

            PlainIndex[id] = bucket;
            Storage.ReadBucket(id, bucket);
            return(bucket);
        }
Esempio n. 3
0
        /// <summary>
        /// Создает новый букет
        /// </summary>
        /// <returns></returns>
        public BTreeBucket <TKey, TKeyData, TData> CreateBucket()
        {
            if (null == Storage)
            {
                throw new Exception("no storage configured");
            }
            var uid    = Storage.CreateBucket(BucketSize);
            var bucket = new BTreeBucket <TKey, TKeyData, TData> {
                Id = uid, Index = this
            };

            PlainIndex[uid] = bucket;
            return(bucket);
        }
Esempio n. 4
0
        private void DoSplitUp()
        {
            MarkChanged();
            var mediana = Values[Index.BucketSize / 2];

            mediana.ContainingBucket = null;
            mediana.BucketBeforeId   = Id;
            mediana.BucketBefore     = this;
            var rightBucket = Index.CreateBucket();

            rightBucket.MarkChanged();
            mediana.BucketAfterId = rightBucket.Id;
            mediana.BucketAfter   = rightBucket;
            var rest = Values.Skip(Index.BucketSize / 2 + 1).ToArray();

            if (mediana.Value == null)
            {
                throw new Exception("here!!");
            }
            Values.Remove(mediana);
            foreach (var value in rest)
            {
                rightBucket.Values.Add(value);
                value.ContainingBucket = rightBucket;
                Values.Remove(value);
            }
            BTreeBucket <TKey, TKeyData, TData> target = Parent;

            if (IsRoot)
            {
                target = Index.CreateBucket();
                mediana.ContainingBucket = target;
                target.IsRoot            = true;
                Index.RootBucket         = target;
                Index.RootBucketId       = target.Id;
                this.IsRoot = false;
                target.MarkChanged();
                target.Values.Add(mediana);
                Parent = target;
            }
            else
            {
                mediana.ContainingBucket = target;
                Parent.StoreValueAfterSplit(mediana);
            }
            rightBucket.Parent = target;
            target.MarkChanged();
        }
Esempio n. 5
0
 private void CheckRoot()
 {
     if (null == RootBucket)
     {
         if (0 == RootBucketId)
         {
             RootBucketId = Storage.GetRoot();
         }
         if (0 == RootBucketId)
         {
             RootBucketId = Storage.CreateBucket(BucketSize);
         }
         RootBucket        = LoadBucket(RootBucketId);
         RootBucket.IsRoot = true;
     }
 }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="uid"></param>
 /// <param name="size"></param>
 /// <param name="targetBucket"></param>
 public void WriteBucket(int uid, int size, BTreeBucket <TKey, TKeyData, TData> targetBucket)
 {
 }
Esempio n. 7
0
 /// <summary>
 /// Загрузить букет
 /// </summary>
 /// <param name="uid"></param>
 /// <param name="targetBucket"></param>
 public void ReadBucket(int uid, BTreeBucket <TKey, TKeyData, TData> targetBucket)
 {
 }