Custom Input Format in New API (Convert Mahaout XMLInput Format to New API)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Custom Input Format in New API (Convert Mahaout XMLInput Format to New API)

shujamughal
Hi
I am trying to convert Mahout xmlInputFormat to new API but this is not working. The problem which i think is that in old api we have next method which takes key and value and we can set it in the method

    public boolean next(LongWritable key, Text value) throws IOException {

but in new API, the method signature is

public boolean nextKeyValue()

So now i am not sure where i set key and values. Here is the link of xml Input format with old API

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.mahout/mahout-examples/0.2/org/apache/mahout/classifier/bayes/XmlInputFormat.java

and i am attaching what i have done with it to convert it into new API so far.

I am not sure about what i have done so far is correct. Kindly help me out to sort out the problem

Thanks
--
Regards
Shuja-ur-Rehman Baig
http://pk.linkedin.com/in/shujamughal
Cell: +92 3214207445

XmlInputFormat.java (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Custom Input Format in New API (Convert Mahaout XMLInput Format to New API)

Amareshwari Sri Ramadasu
With new api, next method reads key and value into member variables, and the key and value read by next method can read by getCurrentKey() and getCurrentValue(). For example see LineRecoredReader, SequenceFileRecordReader in org.apache.hadoop.mapreduce.lib.input package.

Thanks
Amareshwari

On 8/24/10 5:58 PM, "Robin Anil" <[hidden email]> wrote:

+mahout-user


On Tue, Aug 24, 2010 at 5:37 PM, Shuja Rehman <[hidden email]> wrote:
Hi
I am trying to convert Mahout xmlInputFormat to new API but this is not working. The problem which i think is that in old api we have next method which takes key and value and we can set it in the method

    public boolean next(LongWritable key, Text value) throws IOException {

but in new API, the method signature is

public boolean nextKeyValue()

So now i am not sure where i set key and values. Here is the link of xml Input format with old API

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.mahout/mahout-examples/0.2/org/apache/mahout/classifier/bayes/XmlInputFormat.java

and i am attaching what i have done with it to convert it into new API so far.

I am not sure about what i have done so far is correct. Kindly help me out to sort out the problem

Thanks