You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Robin Anil <ro...@gmail.com> on 2010/08/24 14:28:02 UTC

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

+mahout-user


On Tue, Aug 24, 2010 at 5:37 PM, Shuja Rehman <sh...@gmail.com> 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
> --
> Regards
> Shuja-ur-Rehman Baig
> http://pk.linkedin.com/in/shujamughal
> Cell: +92 3214207445
>

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

Posted by Amareshwari Sri Ramadasu <am...@yahoo-inc.com>.
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" <ro...@gmail.com> wrote:

+mahout-user


On Tue, Aug 24, 2010 at 5:37 PM, Shuja Rehman <sh...@gmail.com> 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

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

Posted by Amareshwari Sri Ramadasu <am...@yahoo-inc.com>.
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" <ro...@gmail.com> wrote:

+mahout-user


On Tue, Aug 24, 2010 at 5:37 PM, Shuja Rehman <sh...@gmail.com> 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