hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richards Peter <hbkricha...@gmail.com>
Subject Determine absolute path of a file in hdfs
Date Wed, 09 Dec 2015 08:12:28 GMT
Hi,

I have a situation where I need to determine the absolute path of a file in
hadoop as a String. The path should exclude the schema and authority. Eg:
/mn/op/data/t1.dat

I found the following option in hadoop api:
https://hadoop.apache.org/docs/r2.6.2/api/org/apache/hadoop/fs/Path.html#getPathWithoutSchemeAndAuthority%28org.apache.hadoop.fs.Path%29

The aforementioned api returns a Path object. I do not want a new Path
object. Instead I would like to obtain the path as a String.

If I have the original path stored in a variable path (Path path), will
path.toUri().getPath() be sufficient to retrieve the intended path as a
String? I tried to obtain the path using this approach and I found it to
work fine for the cases that I tested. But I would like to take a
confirmation before I incorporate the code to my project.

Could you please confirm whether my approach is fine?

Thanks,
Richards Peter.

Mime
View raw message