示例#1
0
 /// <summary>Extend a given INodesInPath with a child INode.</summary>
 /// <remarks>
 /// Extend a given INodesInPath with a child INode. The child INode will be
 /// appended to the end of the new INodesInPath.
 /// </remarks>
 public static Org.Apache.Hadoop.Hdfs.Server.Namenode.INodesInPath Append(Org.Apache.Hadoop.Hdfs.Server.Namenode.INodesInPath
                                                                          iip, INode child, byte[] childName)
 {
     Preconditions.CheckArgument(!iip.isSnapshot && iip.Length() > 0);
     Preconditions.CheckArgument(iip.GetLastINode() != null && iip.GetLastINode().IsDirectory
                                     ());
     INode[] inodes = new INode[iip.Length() + 1];
     System.Array.Copy(iip.inodes, 0, inodes, 0, inodes.Length - 1);
     inodes[inodes.Length - 1] = child;
     byte[][] path = new byte[iip.path.Length + 1][];
     System.Array.Copy(iip.path, 0, path, 0, path.Length - 1);
     path[path.Length - 1] = childName;
     return(new Org.Apache.Hadoop.Hdfs.Server.Namenode.INodesInPath(inodes, path, false
                                                                    , iip.snapshotId));
 }
示例#2
0
 /// <summary>Replace an inode of the given INodesInPath in the given position.</summary>
 /// <remarks>
 /// Replace an inode of the given INodesInPath in the given position. We do a
 /// deep copy of the INode array.
 /// </remarks>
 /// <param name="pos">the position of the replacement</param>
 /// <param name="inode">the new inode</param>
 /// <returns>a new INodesInPath instance</returns>
 public static Org.Apache.Hadoop.Hdfs.Server.Namenode.INodesInPath Replace(Org.Apache.Hadoop.Hdfs.Server.Namenode.INodesInPath
                                                                           iip, int pos, INode inode)
 {
     Preconditions.CheckArgument(iip.Length() > 0 && pos > 0 && pos < iip.Length());
     // no for root
     if (iip.GetINode(pos) == null)
     {
         Preconditions.CheckState(iip.GetINode(pos - 1) != null);
     }
     INode[] inodes = new INode[iip.inodes.Length];
     System.Array.Copy(iip.inodes, 0, inodes, 0, inodes.Length);
     inodes[pos] = inode;
     return(new Org.Apache.Hadoop.Hdfs.Server.Namenode.INodesInPath(inodes, iip.path,
                                                                    iip.isSnapshot, iip.snapshotId));
 }