Пример #1
0
 /// <summary>
 /// <pre>
 /// 1 take median element
 /// 2 insert the median in the parent  (shifting necessary elements)
 /// 3 create a new node with right part elements (moving keys and values and children)
 /// 4 set this new node as a child of parent
 /// </pre>
 /// </summary>
 public virtual void Split(NeoDatis.Btree.IBTreeNode parent, NeoDatis.Btree.IBTreeNode
                           node2Split, int childIndex)
 {
     // BTreeValidator.validateNode(parent, parent == root);
     // BTreeValidator.validateNode(node2Split, false);
     // 1
     NeoDatis.Btree.IKeyAndValue median = node2Split.GetMedian();
     // 2
     parent.SetKeyAndValueAt(median, childIndex, true, true);
     // 3
     NeoDatis.Btree.IBTreeNode rightPart = node2Split.ExtractRightPart();
     // 4
     parent.SetChildAt(rightPart, childIndex + 1);
     parent.SetChildAt(node2Split, childIndex);
     parent.IncrementNbChildren();
     persister.SaveNode(parent);
     persister.SaveNode(rightPart);
     persister.SaveNode(node2Split);
     if (NeoDatis.Btree.Tool.BTreeValidator.IsOn())
     {
         NeoDatis.Btree.Tool.BTreeValidator.ValidateNode(parent, parent == root);
         NeoDatis.Btree.Tool.BTreeValidator.ValidateNode(rightPart, false);
         NeoDatis.Btree.Tool.BTreeValidator.ValidateNode(node2Split, false);
     }
 }