예제 #1
0
        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);
        }
예제 #2
0
        public void InsertRouting(NativeRow key, NativeRowTreeNode node, int entryNumber)
        {
            RoutingNode.Insert(key, node, entryNumber);

            Tree.RowsMoved(Node, entryNumber, Node.EntryCount - 2, Node, 1);
        }