Esempio n. 1
0
        private void DoReachCheck(TextWriter warning_log, long node, IIndex node_list, int cur_depth)
        {
            // Is the node in the list?
            bool inserted = node_list.InsertUnique(node, node, SortedIndex.KeyComparer);

            if (inserted) {
                // Fetch the node,
                try {
                    ITreeNode tree_node = FetchNodes(new long[] { node })[0];
                    if (tree_node is TreeBranch) {
                        // Get the child nodes,
                        TreeBranch branch = (TreeBranch)tree_node;
                        int children_count = branch.ChildCount;
                        for (int i = 0; i < children_count; ++i) {
                            long child_node_ref = branch.GetChild(i);
                            // Recurse,
                            if (cur_depth + 1 == reachability_tree_depth) {
                                // It's a known leaf node, so insert now without traversing
                                node_list.InsertUnique(child_node_ref, child_node_ref, SortedIndex.KeyComparer);
                            } else {
                                // Recurse,
                                DoReachCheck(warning_log, child_node_ref, node_list, cur_depth + 1);
                            }
                        }
                    } else if (tree_node is TreeLeaf) {
                        reachability_tree_depth = cur_depth;
                    } else {
                        throw new IOException("Unknown node class: " + tree_node);
                    }
                } catch (InvalidDataState e) {
                    // Report the error,
                    warning_log.WriteLine("Invalid Data Set (msg: " + e.Message + ")");
                    warning_log.WriteLine("Block: " + e.Address.BlockId);
                    warning_log.WriteLine("Data:  " + e.Address.DataId);
                }
            }
        }