Exemple #1
0
        private string GatherDetailedDebugInfo(TreePage rightPage, Slice currentKey, Slice seperatorKey, int currentIndex, int splitIndex, bool toRight)
        {
            var debugInfo = new StringBuilder();

            debugInfo.AppendFormat("\r\n_tree.Name: {0}\r\n", _tree.Name);
            debugInfo.AppendFormat("_newKey: {0}, _len: {1}, needed space: {2}\r\n", _newKey, _len, _page.GetRequiredSpace(_newKey, _len));
            Slice currentSlice;

            using (_page.GetNodeKey(_tx, _page.LastSearchPosition, out currentSlice))
            {
                debugInfo.AppendFormat("key at LastSearchPosition: {0}, current key: {1}, seperatorKey: {2}\r\n",
                                       currentSlice, currentKey, seperatorKey);
            }
            debugInfo.AppendFormat("currentIndex: {0}\r\n", currentIndex);
            debugInfo.AppendFormat("splitIndex: {0}\r\n", splitIndex);
            debugInfo.AppendFormat("toRight: {0}\r\n", toRight);

            debugInfo.AppendFormat("_page info: flags - {0}, # of entries {1}, size left: {2}, calculated size left: {3}\r\n", _page.TreeFlags, _page.NumberOfEntries, _page.SizeLeft, _page.CalcSizeLeft());

            for (int i = 0; i < _page.NumberOfEntries; i++)
            {
                var   node = _page.GetNode(i);
                Slice key;
                using (TreeNodeHeader.ToSlicePtr(_tx.Allocator, node, out key))
                {
                    debugInfo.AppendFormat("{0} - {2} {1}\r\n", key,
                                           node->DataSize, node->Flags == TreeNodeFlags.Data ? "Size" : "Page");
                }
            }

            debugInfo.AppendFormat("rightPage info: flags - {0}, # of entries {1}, size left: {2}, calculated size left: {3}\r\n", rightPage.TreeFlags, rightPage.NumberOfEntries, rightPage.SizeLeft, rightPage.CalcSizeLeft());

            for (int i = 0; i < rightPage.NumberOfEntries; i++)
            {
                var   node = rightPage.GetNode(i);
                Slice key;
                using (TreeNodeHeader.ToSlicePtr(_tx.Allocator, node, out key))
                {
                    debugInfo.AppendFormat("{0} - {2} {1}\r\n", key,
                                           node->DataSize, node->Flags == TreeNodeFlags.Data ? "Size" : "Page");
                }
            }
            return(debugInfo.ToString());
        }