|
@@ -133,7 +133,6 @@ public class INodesInPath {
|
|
|
* be thrown when the path refers to a symbolic link.
|
|
|
* @return the specified number of existing INodes in the path
|
|
|
*/
|
|
|
- // TODO: Eliminate null elements from inodes (to be provided by HDFS-7104)
|
|
|
static INodesInPath resolve(final INodeDirectory startingDir,
|
|
|
final byte[][] components, final int numOfINodes,
|
|
|
final boolean resolveLink) throws UnresolvedLinkException {
|
|
@@ -262,7 +261,8 @@ public class INodesInPath {
|
|
|
*/
|
|
|
private boolean isSnapshot;
|
|
|
/**
|
|
|
- * Index of {@link INodeDirectoryWithSnapshot} for snapshot path, else -1
|
|
|
+ * index of the {@link Snapshot.Root} node in the inodes array,
|
|
|
+ * -1 for non-snapshot paths.
|
|
|
*/
|
|
|
private int snapshotRootIndex;
|
|
|
/**
|
|
@@ -312,15 +312,20 @@ public class INodesInPath {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return the inodes array excluding the null elements.
|
|
|
+ * @return a new array of inodes excluding the null elements introduced by
|
|
|
+ * snapshot path elements. E.g., after resolving path "/dir/.snapshot",
|
|
|
+ * {@link #inodes} is {/, dir, null}, while the returned array only contains
|
|
|
+ * inodes of "/" and "dir". Note the length of the returned array is always
|
|
|
+ * equal to {@link #capacity}.
|
|
|
*/
|
|
|
INode[] getINodes() {
|
|
|
- if (capacity < inodes.length) {
|
|
|
- INode[] newNodes = new INode[capacity];
|
|
|
- System.arraycopy(inodes, 0, newNodes, 0, capacity);
|
|
|
- inodes = newNodes;
|
|
|
+ if (capacity == inodes.length) {
|
|
|
+ return inodes;
|
|
|
}
|
|
|
- return inodes;
|
|
|
+
|
|
|
+ INode[] newNodes = new INode[capacity];
|
|
|
+ System.arraycopy(inodes, 0, newNodes, 0, capacity);
|
|
|
+ return newNodes;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -341,8 +346,8 @@ public class INodesInPath {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return index of the {@link INodeDirectoryWithSnapshot} in
|
|
|
- * {@link #inodes} for snapshot path, else -1.
|
|
|
+ * @return index of the {@link Snapshot.Root} node in the inodes array,
|
|
|
+ * -1 for non-snapshot paths.
|
|
|
*/
|
|
|
int getSnapshotRootIndex() {
|
|
|
return this.snapshotRootIndex;
|