private TreeGraph CreateRootGraph(Key leftKey, long reference) { // The node being returned TreeGraph graph; // Open the area IArea area = store.GetArea(reference); // What type of node is this? short nodeType = area.ReadInt2(); // The version short ver = area.ReadInt2(); if (nodeType == LeafType) { // 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 graph = new TreeGraph("leaf", reference); graph.SetProperty("ver", ver); graph.SetProperty("key", leftKey.ToString()); graph.SetProperty("reference_count", refCount); graph.SetProperty("leaf_size", leafSize); } else if (nodeType == BranchType) { // The data size area containing the children information int childDataSize = area.ReadInt4(); long[] data = new long[childDataSize]; for (int i = 0; i < childDataSize; ++i) { data[i] = area.ReadInt8(); } // Create the TreeBranch object to query it TreeBranch branch = new TreeBranch(reference, data, childDataSize); // Set up the branch node object graph = new TreeGraph("branch", reference); graph.SetProperty("ver", ver); graph.SetProperty("key", leftKey.ToString()); graph.SetProperty("branch_size", branch.ChildCount); // Recursively add each child into the tree for (int i = 0; i < branch.ChildCount; ++i) { long child_ref = branch.GetChild(i); // If the ref is a special node, skip it if ((child_ref & 0x01000000000000000L) != 0) { // Should we record special nodes? } else { Key newLeftKey = (i > 0) ? branch.GetKey(i) : leftKey; TreeGraph bn = new TreeGraph("child_meta", reference); bn.SetProperty("extent", branch.GetChildLeafElementCount(i)); graph.AddChild(bn); graph.AddChild(CreateRootGraph(newLeftKey, child_ref)); } } } else { throw new IOException("Unknown node type: " + nodeType); } return graph; }
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; }