You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by y_...@tsmc.com on 2010/10/04 09:39:07 UTC

How to get file name

Hi,
I am using hadoop0.20.1
Try to get the filename, but it didn't work by following codes.
Any suggestion?

FileSplit fileSplit = (FileSplit) context.getInputSplit();
String fileName = fileSplit.getPath().getName();

Error message
cannot be cast to org.apache.hadoop.mapred.FileSplit


Fleming Chiu(邱宏明)
TEL: 707-2260
Be Veg! Go Green! Save the planet!

 --------------------------------------------------------------------------- 
                                                         TSMC PROPERTY       
 This email communication (and any attachments) is proprietary information   
 for the sole use of its                                                     
 intended recipient. Any unauthorized review, use or distribution by anyone  
 other than the intended                                                     
 recipient is strictly prohibited.  If you are not the intended recipient,   
 please notify the sender by                                                 
 replying to this email, and then delete this email and any copies of it     
 immediately. Thank you.                                                     
 --------------------------------------------------------------------------- 




Re: How to get file name

Posted by Harsh J <qw...@gmail.com>.
There is a newer FileSplit class in mapreduce.lib.input, you should cast it
to that I believe, not the mapred, deprecated one since you are using the
unstable API as per your code snippet.

On Oct 4, 2010 1:10 PM, <y_...@tsmc.com> wrote:


Hi,
I am using hadoop0.20.1
Try to get the filename, but it didn't work by following codes.
Any suggestion?

FileSplit fileSplit = (FileSplit) context.getInputSplit();
String fileName = fileSplit.getPath().getName();

Error message
cannot be cast to org.apache.hadoop.mapred.FileSplit


Fleming Chiu(邱宏明)
TEL: 707-2260
Be Veg! Go Green! Save the planet!

 ---------------------------------------------------------------------------
                                                        TSMC PROPERTY
 This email communication (and any attachments) is proprietary information
 for the sole use of its
 intended recipient. Any unauthorized review, use or distribution by anyone
 other than the intended
 recipient is strictly prohibited.  If you are not the intended recipient,
 please notify the sender by
 replying to this email, and then delete this email and any copies of it
 immediately. Thank you.
 ---------------------------------------------------------------------------