private TreeReportNode CreateDiagnosticRootGraph(Key leftKey, NodeId id) { // The node being returned TreeReportNode node; // Open the area IArea area = nodeStore.GetArea(ToInt64StoreAddress(id)); // What type of node is this? short nodeType = area.ReadInt2(); // The version short ver = area.ReadInt2(); if (nodeType == StoreLeafType) { // Read the reference count, long refCount = area.ReadInt4(); // The number of bytes in the leaf int leafSize = area.ReadInt4(); // Set up the leaf node object node = new TreeReportNode("leaf", id); node.SetProperty("VER", ver); node.SetProperty("key", leftKey.ToString()); node.SetProperty("reference_count", refCount); node.SetProperty("leaf_size", leafSize); } else if (nodeType == StoreBranchType) { // The data size area containing the children information int childDataSize = area.ReadInt4(); long[] dataArr = new long[childDataSize]; for (int i = 0; i < childDataSize; ++i) { dataArr[i] = area.ReadInt8(); } // Create the TreeBranch object to query it TreeBranch branch = new TreeBranch(id, dataArr, childDataSize); // Set up the branch node object node = new TreeReportNode("branch", id); node.SetProperty("VER", ver); node.SetProperty("key", leftKey.ToString()); node.SetProperty("branch_size", branch.ChildCount); // Recursively add each child into the tree for (int i = 0; i < branch.ChildCount; ++i) { NodeId childId = branch.GetChild(i); // If the id is a special node, skip it if (childId.IsSpecial) { // Should we record special nodes? } else { Key newLeftKey = (i > 0) ? branch.GetKey(i) : leftKey; TreeReportNode bn = new TreeReportNode("child_meta", id); bn.SetProperty("extent", branch.GetChildLeafElementCount(i)); node.ChildNodes.Add(bn); node.ChildNodes.Add(CreateDiagnosticRootGraph(newLeftKey, childId)); } } } else { throw new IOException("Unknown node type: " + nodeType); } return(node); }
private TreeReportNode CreateDiagnosticRootGraph(Key leftKey, NodeId id) { // The node being returned TreeReportNode node; // Open the area IArea area = nodeStore.GetArea(ToInt64StoreAddress(id)); // What type of node is this? short nodeType = area.ReadInt2(); // The version short ver = area.ReadInt2(); if (nodeType == StoreLeafType) { // Read the reference count, long refCount = area.ReadInt4(); // The number of bytes in the leaf int leafSize = area.ReadInt4(); // Set up the leaf node object node = new TreeReportNode("leaf", id); node.SetProperty("VER", ver); node.SetProperty("key", leftKey.ToString()); node.SetProperty("reference_count", refCount); node.SetProperty("leaf_size", leafSize); } else if (nodeType == StoreBranchType) { // The data size area containing the children information int childDataSize = area.ReadInt4(); long[] dataArr = new long[childDataSize]; for (int i = 0; i < childDataSize; ++i) { dataArr[i] = area.ReadInt8(); } // Create the TreeBranch object to query it TreeBranch branch = new TreeBranch(id, dataArr, childDataSize); // Set up the branch node object node = new TreeReportNode("branch", id); node.SetProperty("VER", ver); node.SetProperty("key", leftKey.ToString()); node.SetProperty("branch_size", branch.ChildCount); // Recursively add each child into the tree for (int i = 0; i < branch.ChildCount; ++i) { NodeId childId = branch.GetChild(i); // If the id is a special node, skip it if (childId.IsSpecial) { // Should we record special nodes? } else { Key newLeftKey = (i > 0) ? branch.GetKey(i) : leftKey; TreeReportNode bn = new TreeReportNode("child_meta", id); bn.SetProperty("extent", branch.GetChildLeafElementCount(i)); node.ChildNodes.Add(bn); node.ChildNodes.Add(CreateDiagnosticRootGraph(newLeftKey, childId)); } } } else { throw new IOException("Unknown node type: " + nodeType); } return node; }
public TreeReportNode CreateDiagnosticGraph() { CheckErrorState(); // Create the header node TreeReportNode headerNode = new TreeReportNode("header", headerId); // Get the header area IArea headerArea = nodeStore.GetArea(headerId); headerArea.Position = 8; // Read the versions list, long versionListRef = headerArea.ReadInt8(); // Create the version node TreeReportNode versionsNode = new TreeReportNode("versions list", versionListRef); // Set this as a child to the header headerNode.ChildNodes.Add(versionsNode); // Read the versions list area // magic(int), versions count(int), list of version id objects. IArea versionsArea = nodeStore.GetArea(versionListRef); if (versionsArea.ReadInt4() != 0x01433) { throw new IOException("Incorrect magic value 0x01433"); } int versCount = versionsArea.ReadInt4(); // For each id from the versions area, read in the associated VersionInfo // object into the 'vers' array. for (int i = 0; i < versCount; ++i) { long vInfoRef = versionsArea.ReadInt8(); // Set up the information in our node TreeReportNode vInfoNode = new TreeReportNode("version", vInfoRef); // Read in the version information node IArea vInfoArea = nodeStore.GetArea(vInfoRef); int magic = vInfoArea.ReadInt4(); int ver = vInfoArea.ReadInt4(); long versionId = vInfoArea.ReadInt8(); long rnrHigh = vInfoArea.ReadInt8(); long rnrLow = vInfoArea.ReadInt8(); NodeId rootNodeId = new NodeId(rnrHigh, rnrLow); vInfoNode.SetProperty("MAGIC", magic); vInfoNode.SetProperty("VER", ver); vInfoNode.SetProperty("version_id", versionId); // Make the deleted area list into a property int deletedAreaCount = vInfoArea.ReadInt4(); if (deletedAreaCount > 0) { for (int n = 0; n < deletedAreaCount; ++n) { long delnHigh = vInfoArea.ReadInt8(); long delnLow = vInfoArea.ReadInt8(); NodeId delNodeId = new NodeId(delnHigh, delnLow); vInfoNode.ChildNodes.Add(new TreeReportNode("delete", delNodeId)); } } // Add the child node (the root node of the version graph). vInfoNode.ChildNodes.Add(CreateDiagnosticRootGraph(Key.Head, rootNodeId)); // Add this to the version list node versionsNode.ChildNodes.Add(vInfoNode); } // Return the header node return(headerNode); }
public TreeReportNode CreateDiagnosticGraph() { CheckErrorState(); // Create the header node TreeReportNode headerNode = new TreeReportNode("header", headerId); // Get the header area IArea headerArea = nodeStore.GetArea(headerId); headerArea.Position = 8; // Read the versions list, long versionListRef = headerArea.ReadInt8(); // Create the version node TreeReportNode versionsNode = new TreeReportNode("versions list", versionListRef); // Set this as a child to the header headerNode.ChildNodes.Add(versionsNode); // Read the versions list area // magic(int), versions count(int), list of version id objects. IArea versionsArea = nodeStore.GetArea(versionListRef); if (versionsArea.ReadInt4() != 0x01433) throw new IOException("Incorrect magic value 0x01433"); int versCount = versionsArea.ReadInt4(); // For each id from the versions area, read in the associated VersionInfo // object into the 'vers' array. for (int i = 0; i < versCount; ++i) { long vInfoRef = versionsArea.ReadInt8(); // Set up the information in our node TreeReportNode vInfoNode = new TreeReportNode("version", vInfoRef); // Read in the version information node IArea vInfoArea = nodeStore.GetArea(vInfoRef); int magic = vInfoArea.ReadInt4(); int ver = vInfoArea.ReadInt4(); long versionId = vInfoArea.ReadInt8(); long rnrHigh = vInfoArea.ReadInt8(); long rnrLow = vInfoArea.ReadInt8(); NodeId rootNodeId = new NodeId(rnrHigh, rnrLow); vInfoNode.SetProperty("MAGIC", magic); vInfoNode.SetProperty("VER", ver); vInfoNode.SetProperty("version_id", versionId); // Make the deleted area list into a property int deletedAreaCount = vInfoArea.ReadInt4(); if (deletedAreaCount > 0) { for (int n = 0; n < deletedAreaCount; ++n) { long delnHigh = vInfoArea.ReadInt8(); long delnLow = vInfoArea.ReadInt8(); NodeId delNodeId = new NodeId(delnHigh, delnLow); vInfoNode.ChildNodes.Add(new TreeReportNode("delete", delNodeId)); } } // Add the child node (the root node of the version graph). vInfoNode.ChildNodes.Add(CreateDiagnosticRootGraph(Key.Head, rootNodeId)); // Add this to the version list node versionsNode.ChildNodes.Add(vInfoNode); } // Return the header node return headerNode; }