5 internal class BlockSplitterMiddle : BlockSplitter
9 public BlockSplitterMiddle(
int PayloadSize)
12 this.MiddlePos = PayloadSize / 2 + ObjectBTreeFile.BlockHeaderSize;
15 public override void NextBlock(uint BlockLink,
byte[] Block,
int Pos,
int Len, uint ChildSize)
19 if (!(this.ParentObject is
null))
21 if (this.RightSizeSubtree < uint.MaxValue)
23 this.RightSizeSubtree++;
25 this.RightSizeSubtree += ChildSize;
26 if (this.RightSizeSubtree < ChildSize)
27 this.RightSizeSubtree = uint.MaxValue;
30 Array.Copy(BitConverter.GetBytes(BlockLink), 0, RightBlock, RightPos, 4);
32 Array.Copy(Block, Pos, RightBlock, RightPos, Len);
36 else if (this.TotPos + c <= this.MiddlePos)
38 if (this.LeftSizeSubtree < uint.MaxValue)
40 this.LeftSizeSubtree++;
42 this.LeftSizeSubtree += ChildSize;
43 if (this.LeftSizeSubtree < ChildSize)
44 this.LeftSizeSubtree = uint.MaxValue;
47 Array.Copy(BitConverter.GetBytes(BlockLink), 0, LeftBlock, LeftPos, 4);
49 Array.Copy(Block, Pos, LeftBlock, LeftPos, Len);
55 this.LeftLastBlockIndex = BlockLink;
56 this.LeftSizeSubtree += ChildSize;
57 if (this.LeftSizeSubtree < ChildSize)
58 this.LeftSizeSubtree = uint.MaxValue;
60 this.ParentObject =
new byte[Len];
61 Array.Copy(Block, Pos, this.ParentObject, 0, Len);