Beispiel #1
0
 /// <exception cref="System.IO.IOException"></exception>
 private void AddIfNotNull(FanoutBucket b, int cell, NoteBucket child)
 {
     if (child == null)
     {
         return;
     }
     if (child is InMemoryNoteBucket)
     {
         b.SetBucket(cell, ((InMemoryNoteBucket)child).WriteTree(inserter));
     }
     else
     {
         b.SetBucket(cell, child.GetTreeId());
     }
 }
Beispiel #2
0
        private FanoutBucket ParseFanoutTree()
        {
            FanoutBucket fanout = new FanoutBucket(prefixLen);

            for (; !Eof; Next(1))
            {
                int cell = ParseFanoutCell();
                if (0 <= cell)
                {
                    fanout.SetBucket(cell, EntryObjectId);
                }
                else
                {
                    StoreNonNote();
                }
            }
            return(fanout);
        }
Beispiel #3
0
        /// <exception cref="System.IO.IOException"></exception>
        private InMemoryNoteBucket MergeFanoutBucket(int treeDepth, FanoutBucket @base, FanoutBucket
                                                     ours, FanoutBucket theirs)
        {
            FanoutBucket result = new FanoutBucket(treeDepth * 2);

            // walking through entries of base, ours, theirs
            for (int i = 0; i < 256; i++)
            {
                NoteBucket b = @base.GetBucket(i);
                NoteBucket o = ours.GetBucket(i);
                NoteBucket t = theirs.GetBucket(i);
                if (Equals(o, t))
                {
                    AddIfNotNull(result, i, o);
                }
                else
                {
                    if (Equals(b, o))
                    {
                        AddIfNotNull(result, i, t);
                    }
                    else
                    {
                        if (Equals(b, t))
                        {
                            AddIfNotNull(result, i, o);
                        }
                        else
                        {
                            objectIdPrefix.SetByte(treeDepth, i);
                            InMemoryNoteBucket mergedBucket = Merge(treeDepth + 1, FanoutBucket.LoadIfLazy(b,
                                                                                                           objectIdPrefix, reader), FanoutBucket.LoadIfLazy(o, objectIdPrefix, reader), FanoutBucket
                                                                    .LoadIfLazy(t, objectIdPrefix, reader));
                            result.SetBucket(i, mergedBucket);
                        }
                    }
                }
            }
            return(result.ContractIfTooSmall(objectIdPrefix, reader));
        }