public void DeleteData(int entryNumber) { Tree.DisposeData(Manager, DataNode.Rows[entryNumber]); Tree.DisposeKey(Manager, DataNode.Keys[entryNumber]); DataNode.Delete(entryNumber); Tree.RowDeleted(Node, entryNumber); Tree.RowsMoved(Node, entryNumber + 1, Node.EntryCount, Node, -1); }
private int Split(NativeRowTreeNode sourceNode, NativeRowTreeNode targetNode) { int entryCount = sourceNode.EntryCount; int entryPivot = entryCount / 2; if (sourceNode.NodeType == NativeRowTreeNodeType.Data) { NativeRowTreeDataNode sourceDataNode = (NativeRowTreeDataNode)sourceNode; NativeRowTreeDataNode targetDataNode = (NativeRowTreeDataNode)targetNode; // Insert the upper half of the entries from ASourceNode into ATargetNode for (int entryIndex = entryPivot; entryIndex < entryCount; entryIndex++) { targetDataNode.Insert(sourceDataNode.Keys[entryIndex], sourceDataNode.Rows[entryIndex], entryIndex - entryPivot); } // Remove the upper half of the entries from ASourceNode for (int entryIndex = entryCount - 1; entryIndex >= entryPivot; entryIndex--) { sourceDataNode.Delete(entryIndex); // Don't dispose the values here, this is a move } } else { NativeRowTreeRoutingNode sourceRoutingNode = (NativeRowTreeRoutingNode)sourceNode; NativeRowTreeRoutingNode targetRoutingNode = (NativeRowTreeRoutingNode)targetNode; // Insert the upper half of the entries from ASourceNode into ATargetNode for (int entryIndex = entryPivot; entryIndex < entryCount; entryIndex++) { targetRoutingNode.Insert(sourceRoutingNode.Keys[entryIndex], sourceRoutingNode.Nodes[entryIndex], entryIndex - entryPivot); } // Remove the upper half of the entries from ASourceNode for (int entryIndex = entryCount - 1; entryIndex >= entryPivot; entryIndex--) { sourceRoutingNode.Delete(entryIndex); } } // Notify index clients of the data change RowsMoved(sourceNode, entryPivot, entryCount - 1, targetNode, -entryPivot); return(entryPivot); }