static INodesInPath fromComponents(byte[][] components) { return new INodesInPath(new INode[components.length], components); }
/** * @param length number of ancestral INodes in the returned INodesInPath * instance * @return the INodesInPath instance containing ancestral INodes. Note that * this method only handles non-snapshot paths. */ private INodesInPath getAncestorINodesInPath(int length) { Preconditions.checkArgument(length >= 0 && length < inodes.length); Preconditions.checkState(isDotSnapshotDir() || !isSnapshot()); final INode[] anodes = new INode[length]; final byte[][] apath = new byte[length][]; System.arraycopy(this.inodes, 0, anodes, 0, length); System.arraycopy(this.path, 0, apath, 0, length); return new INodesInPath(anodes, apath, isRaw, false, snapshotId); }
/** * Construct {@link INodesInPath} from {@link INode}. * * @param inode to construct from * @return INodesInPath */ static INodesInPath fromINode(INode inode) { INode[] inodes = getINodes(inode); byte[][] paths = getPaths(inodes); return new INodesInPath(inodes, paths); }
/** * Replace an inode of the given INodesInPath in the given position. We do a * deep copy of the INode array. * @param pos the position of the replacement * @param inode the new inode * @return a new INodesInPath instance */ public static INodesInPath replace(INodesInPath iip, int pos, INode inode) { Preconditions.checkArgument(iip.length() > 0 && pos > 0 // no for root && pos < iip.length()); if (iip.getINode(pos) == null) { Preconditions.checkState(iip.getINode(pos - 1) != null); } INode[] inodes = new INode[iip.inodes.length]; System.arraycopy(iip.inodes, 0, inodes, 0, inodes.length); inodes[pos] = inode; return new INodesInPath(inodes, iip.path, iip.isRaw, iip.isSnapshot, iip.snapshotId); }
/** * Extend a given INodesInPath with a child INode. The child INode will be * appended to the end of the new INodesInPath. */ public static INodesInPath append(INodesInPath iip, INode child, byte[] childName) { Preconditions.checkArgument(iip.length() > 0); Preconditions.checkArgument(iip.getLastINode() != null && iip .getLastINode().isDirectory()); INode[] inodes = new INode[iip.length() + 1]; System.arraycopy(iip.inodes, 0, inodes, 0, inodes.length - 1); inodes[inodes.length - 1] = child; byte[][] path = new byte[iip.path.length + 1][]; System.arraycopy(iip.path, 0, path, 0, path.length - 1); path[path.length - 1] = childName; return new INodesInPath(inodes, path, iip.isRaw, iip.isSnapshot, iip.snapshotId); }
static INodesInPath fromComponents(byte[][] components) { return new INodesInPath(new INode[components.length], components); }
static INodesInPath fromComponents(byte[][] components) { return new INodesInPath(new INode[components.length], components); }
return new INodesInPath(inodes, components, isRaw, isSnapshot, snapshotId);
/** * @param length number of ancestral INodes in the returned INodesInPath * instance * @return the INodesInPath instance containing ancestral INodes. Note that * this method only handles non-snapshot paths. */ private INodesInPath getAncestorINodesInPath(int length) { Preconditions.checkArgument(length >= 0 && length < inodes.length); Preconditions.checkState(!isSnapshot()); final INode[] anodes = new INode[length]; final byte[][] apath = new byte[length][]; System.arraycopy(this.inodes, 0, anodes, 0, length); System.arraycopy(this.path, 0, apath, 0, length); return new INodesInPath(anodes, apath, false, snapshotId); }
/** * @return a new INodesInPath instance that only contains exisitng INodes. * Note that this method only handles non-snapshot paths. */ public INodesInPath getExistingINodes() { Preconditions.checkState(!isSnapshot()); int i = 0; for (; i < inodes.length; i++) { if (inodes[i] == null) { break; } } INode[] existing = new INode[i]; byte[][] existingPath = new byte[i][]; System.arraycopy(inodes, 0, existing, 0, i); System.arraycopy(path, 0, existingPath, 0, i); return new INodesInPath(existing, existingPath, false, snapshotId); }
/** * @return a new INodesInPath instance that only contains exisitng INodes. * Note that this method only handles non-snapshot paths. */ public INodesInPath getExistingINodes() { Preconditions.checkState(!isSnapshot()); int i = 0; for (; i < inodes.length; i++) { if (inodes[i] == null) { break; } } INode[] existing = new INode[i]; byte[][] existingPath = new byte[i][]; System.arraycopy(inodes, 0, existing, 0, i); System.arraycopy(path, 0, existingPath, 0, i); return new INodesInPath(existing, existingPath, false, snapshotId); }
/** * @param length number of ancestral INodes in the returned INodesInPath * instance * @return the INodesInPath instance containing ancestral INodes. Note that * this method only handles non-snapshot paths. */ private INodesInPath getAncestorINodesInPath(int length) { Preconditions.checkArgument(length >= 0 && length < inodes.length); Preconditions.checkState(!isSnapshot()); final INode[] anodes = new INode[length]; final byte[][] apath = new byte[length][]; System.arraycopy(this.inodes, 0, anodes, 0, length); System.arraycopy(this.path, 0, apath, 0, length); return new INodesInPath(anodes, apath, false, snapshotId); }
/** * Extend a given INodesInPath with a child INode. The child INode will be * appended to the end of the new INodesInPath. */ public static INodesInPath append(INodesInPath iip, INode child, byte[] childName) { Preconditions.checkArgument(iip.length() > 0); Preconditions.checkArgument(iip.getLastINode() != null && iip .getLastINode().isDirectory()); INode[] inodes = new INode[iip.length() + 1]; System.arraycopy(iip.inodes, 0, inodes, 0, inodes.length - 1); inodes[inodes.length - 1] = child; byte[][] path = new byte[iip.path.length + 1][]; System.arraycopy(iip.path, 0, path, 0, path.length - 1); path[path.length - 1] = childName; return new INodesInPath(inodes, path, iip.isSnapshot, iip.snapshotId); }
/** * Replace an inode of the given INodesInPath in the given position. We do a * deep copy of the INode array. * @param pos the position of the replacement * @param inode the new inode * @return a new INodesInPath instance */ public static INodesInPath replace(INodesInPath iip, int pos, INode inode) { Preconditions.checkArgument(iip.length() > 0 && pos > 0 // no for root && pos < iip.length()); if (iip.getINode(pos) == null) { Preconditions.checkState(iip.getINode(pos - 1) != null); } INode[] inodes = new INode[iip.inodes.length]; System.arraycopy(iip.inodes, 0, inodes, 0, inodes.length); inodes[pos] = inode; return new INodesInPath(inodes, iip.path, iip.isSnapshot, iip.snapshotId); }
static INodesInPath fromINode(INode inode) { int depth = 0, index; INode tmp = inode; while (tmp != null) { depth++; tmp = tmp.getParent(); } final byte[][] path = new byte[depth][]; final INode[] inodes = new INode[depth]; tmp = inode; index = depth; while (tmp != null) { index--; path[index] = tmp.getKey(); inodes[index] = tmp; tmp = tmp.getParent(); } return new INodesInPath(inodes, path); }
static INodesInPath fromINode(INode inode) { int depth = 0, index; INode tmp = inode; while (tmp != null) { depth++; tmp = tmp.getParent(); } final byte[][] path = new byte[depth][]; final INode[] inodes = new INode[depth]; tmp = inode; index = depth; while (tmp != null) { index--; path[index] = tmp.getKey(); inodes[index] = tmp; tmp = tmp.getParent(); } return new INodesInPath(inodes, path); }
/** * Extend a given INodesInPath with a child INode. The child INode will be * appended to the end of the new INodesInPath. */ public static INodesInPath append(INodesInPath iip, INode child, byte[] childName) { Preconditions.checkArgument(iip.length() > 0); Preconditions.checkArgument(iip.getLastINode() != null && iip .getLastINode().isDirectory()); INode[] inodes = new INode[iip.length() + 1]; System.arraycopy(iip.inodes, 0, inodes, 0, inodes.length - 1); inodes[inodes.length - 1] = child; byte[][] path = new byte[iip.path.length + 1][]; System.arraycopy(iip.path, 0, path, 0, path.length - 1); path[path.length - 1] = childName; return new INodesInPath(inodes, path, iip.isSnapshot, iip.snapshotId); }
/** * Replace an inode of the given INodesInPath in the given position. We do a * deep copy of the INode array. * @param pos the position of the replacement * @param inode the new inode * @return a new INodesInPath instance */ public static INodesInPath replace(INodesInPath iip, int pos, INode inode) { Preconditions.checkArgument(iip.length() > 0 && pos > 0 // no for root && pos < iip.length()); if (iip.getINode(pos) == null) { Preconditions.checkState(iip.getINode(pos - 1) != null); } INode[] inodes = new INode[iip.inodes.length]; System.arraycopy(iip.inodes, 0, inodes, 0, inodes.length); inodes[pos] = inode; return new INodesInPath(inodes, iip.path, iip.isSnapshot, iip.snapshotId); }
inodes = newNodes; return new INodesInPath(inodes, components, isSnapshot, snapshotId);
inodes = newNodes; return new INodesInPath(inodes, components, isSnapshot, snapshotId);