hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pat Ferrel <pat.fer...@gmail.com>
Subject Re: Hadoop 101
Date Wed, 12 Dec 2012 16:36:53 GMT
Yeah I found the TextInputFormat and TextKeyValueInputFormat and I know how to parse text--I'm
just too lazy. I was hoping there was a Text equivalent of a SequenceFile that was hidden
somewhere. As I said there is no mapper, this is running outside of hadoop M/R. So I at least
need a line reader and not sure how the InputFormat works outside a mapper. But who cares,
parsing is simple enough from scratch. All the TextKeyValueInputFormat gives me is splitting
at the tab afaict.

Actually this convinces me to look further into getting the values from method calls. They
aren't quite what I want to begin with. 

Thanks for saving me more fruitless searches.

On Dec 11, 2012, at 10:04 PM, David Parks <davidparks21@yahoo.com> wrote:

You use TextInputFormat, you'll get the following key<LongWritable>,
value<Text> pairs in your mapper:

file_position, your_input


Then just parse it out in your mapper.

-----Original Message-----
From: Pat Ferrel [mailto:pat.ferrel@gmail.com] 
Sent: Wednesday, December 12, 2012 7:50 AM
To: user@hadoop.apache.org
Subject: Hadoop 101

Stupid question for the day.

I have a file created by a mahout job of the form:


If this were a SequenceFile I could read it and be merrily on my way but
it's a text file. The classes written are key, value pairs <LongWritable,
VectorWritable> but the file is tab delimited text. 

I was hoping to do something like:

SequenceFile.Reader reader = new SequenceFile.Reader(fs, inputFile, conf);
Writable userId = new LongWritable(); VectorWritable recommendations = new
VectorWritable(); while (reader.next(userId, recommendations)) {
	//do something with each pair

But alas Google fails me. How do you read in key, values pairs from text
files outside of a map or reduce? 

View raw message