Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread Keith Wiley
In the first example you want it to chop off the /sub/ directory. Why? What is the indicator as to how many lower directories you want chopped off? In the second example, how can it turn a relative path into an absolute path considering that there may be multiple top directories scattered

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread W.P. McNeill
I want to normalize the paths. I don't actually care about the specific string representations, just that two paths that point to the same location in HDFS could be recognized as equivalent. Usually the way you do this in file systems is get an absolute path, so that's why I'm looking for one

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread Harsh J
Hi, Looking up the FileStatus has worked for me before: fs.getFileStatus(new Path(.)).getPath() On Tue, Mar 13, 2012 at 2:50 AM, W.P. McNeill bill...@gmail.com wrote: Is there an API that returns absolute HDFS paths? So something that would turn /user/myname/top/sub/.. into /user/myname/top

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread Keith Wiley
Hmmm, that's interesting. Unless I'm misunderstanding you, the associated operation in conventional file systems (such as the pwd) command only work because something already knows the absolute path and can produce it on demand. If all you have is a relative path (such as top/sub in your

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread W.P. McNeill
That works. Note that this returns the full HDFS URI. If you want to remove protocol and server information you must do something like: Path p = fs.getFileStatus(new Path(.)).getPath(); URI(p.toString()).getPath();

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread W.P. McNeill
HDFS always translates non-absolute paths like top/sub into absolute paths of the form /user/USERNAME/top/sub. So in HDFS top/sub is unambiguous.

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread Harsh J
Why retranslate? Even better is to instead do: p.toUri().getPath() On Tue, Mar 13, 2012 at 3:52 AM, W.P. McNeill bill...@gmail.com wrote: That works. Note that this returns the full HDFS URI. If you want to remove protocol and server information you must do something like: Path p =

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread W.P. McNeill
Yep, that's better. I just got turned around in all the format conversions.

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread Keith Wiley
So, you're say that hadoop assumes there is a specific directory hierarchy on HDFS? Namely that there exists a top-level directory /user/ and that there exist various username directories under /user/? I only ask because I've never bothered to configure an HDFS system that specific way? I

Re: Is there a way to get an absolute HDFS path?

2012-03-12 Thread Joey Echeverria
HDFS has the notion of a working directory which defaults to /user/username. Check out: http://hadoop.apache.org/common/docs/r1.0.1/api/org/apache/hadoop/fs/FileSystem.html#getWorkingDirectory() and