HDFS-10772. Reduce byte/string conversions for get listing. Contributed by Daryn Sharp.
(cherry picked from commit a1f3293762
)
This commit is contained in:
parent
e31745e281
commit
ba3257baf5
|
@ -23,6 +23,7 @@ import org.apache.hadoop.fs.ContentSummary;
|
||||||
import org.apache.hadoop.fs.DirectoryListingStartAfterNotFoundException;
|
import org.apache.hadoop.fs.DirectoryListingStartAfterNotFoundException;
|
||||||
import org.apache.hadoop.fs.FileEncryptionInfo;
|
import org.apache.hadoop.fs.FileEncryptionInfo;
|
||||||
import org.apache.hadoop.fs.InvalidPathException;
|
import org.apache.hadoop.fs.InvalidPathException;
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.permission.FsAction;
|
import org.apache.hadoop.fs.permission.FsAction;
|
||||||
import org.apache.hadoop.fs.permission.FsPermission;
|
import org.apache.hadoop.fs.permission.FsPermission;
|
||||||
import org.apache.hadoop.fs.QuotaUsage;
|
import org.apache.hadoop.fs.QuotaUsage;
|
||||||
|
@ -50,7 +51,6 @@ import static org.apache.hadoop.util.Time.now;
|
||||||
class FSDirStatAndListingOp {
|
class FSDirStatAndListingOp {
|
||||||
static DirectoryListing getListingInt(FSDirectory fsd, final String srcArg,
|
static DirectoryListing getListingInt(FSDirectory fsd, final String srcArg,
|
||||||
byte[] startAfter, boolean needLocation) throws IOException {
|
byte[] startAfter, boolean needLocation) throws IOException {
|
||||||
final String startAfterString = DFSUtil.bytes2String(startAfter);
|
|
||||||
String src = null;
|
String src = null;
|
||||||
|
|
||||||
final INodesInPath iip;
|
final INodesInPath iip;
|
||||||
|
@ -63,16 +63,20 @@ class FSDirStatAndListingOp {
|
||||||
iip = fsd.getINodesInPath(src, true);
|
iip = fsd.getINodesInPath(src, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file name when startAfter is an INodePath
|
// Get file name when startAfter is an INodePath. This is not the
|
||||||
if (FSDirectory.isReservedName(startAfterString)) {
|
// common case so avoid any unnecessary processing unless required.
|
||||||
try {
|
if (startAfter.length > 0 && startAfter[0] == Path.SEPARATOR_CHAR) {
|
||||||
String tmp = FSDirectory.resolvePath(startAfterString, fsd);
|
final String startAfterString = DFSUtil.bytes2String(startAfter);
|
||||||
byte[][] regularPath = INode.getPathComponents(tmp);
|
if (FSDirectory.isReservedName(startAfterString)) {
|
||||||
startAfter = regularPath[regularPath.length - 1];
|
try {
|
||||||
} catch (IOException e) {
|
byte[][] components = INode.getPathComponents(startAfterString);
|
||||||
// Possibly the inode is deleted
|
components = FSDirectory.resolveComponents(components, fsd);
|
||||||
throw new DirectoryListingStartAfterNotFoundException(
|
startAfter = components[components.length - 1];
|
||||||
"Can't find startAfter " + startAfterString);
|
} catch (IOException e) {
|
||||||
|
// Possibly the inode is deleted
|
||||||
|
throw new DirectoryListingStartAfterNotFoundException(
|
||||||
|
"Can't find startAfter " + startAfterString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue