// Commented by Olivier 05/11/2007 // persister.flush(); /// <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(IBTreeNode parent, IBTreeNode node2Split, int childIndex) { // BTreeValidator.validateNode(parent, parent == root); // BTreeValidator.validateNode(node2Split, false); // 1 var medianValue = node2Split.GetMedian(); // 2 parent.SetKeyAndValueAt(medianValue, childIndex, true, true); // 3 var rightPartTreeNode = node2Split.ExtractRightPart(); // 4 parent.SetChildAt(rightPartTreeNode, childIndex + 1); parent.SetChildAt(node2Split, childIndex); parent.IncrementNbChildren(); _persister.SaveNode(parent); _persister.SaveNode(rightPartTreeNode); _persister.SaveNode(node2Split); if (!OdbConfiguration.IsBTreeValidationEnabled()) { return; } BTreeValidator.ValidateNode(parent, parent == _root); BTreeValidator.ValidateNode(rightPartTreeNode, false); BTreeValidator.ValidateNode(node2Split, false); }