Example usage for org.apache.hadoop.fs Path depth

List of usage examples for org.apache.hadoop.fs Path depth

Introduction

In this page you can find the example usage for org.apache.hadoop.fs Path depth.

Prototype

public int depth() 

Source Link

Document

Returns the number of elements in this path.

Usage

From source file:org.icgc.dcc.submission.sftp.fs.RootHdfsSshFile.java

License:Open Source License

@Override
public HdfsSshFile getChild(Path filePath) {
    try {/*from   w w  w  .j ava  2s .  c  o m*/
        switch (filePath.depth()) {
        case 0:
            return this;
        case 1:
            return new SubmissionDirectoryHdfsSshFile(context, this, filePath.getName());
        case 2:
            val parentDir = new SubmissionDirectoryHdfsSshFile(context, this, filePath.getParent().getName());
            return new FileHdfsSshFile(context, parentDir, filePath.getName());
        }
    } catch (Exception e) {
        return handleException(HdfsSshFile.class, e);
    }

    return handleException(HdfsSshFile.class, "Invalid file path: %s%s", getAbsolutePath(),
            filePath.toString());
}