hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Parks" <davidpark...@yahoo.com>
Subject RE: Hadoop 101
Date Thu, 13 Dec 2012 04:16:21 GMT
Nothing that I'm aware of for text files, I'd just use standard unix utils
to process it outside of Hadoop.

As to getting a reader from any of the Input Formats, here's the typical
example you'd follow to get the reader for a sequence file, you could
extrapolate the example to access whichever reader you're interested in.


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

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