Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HDFS, mail # user - RE: objects as key/values


Copy link to this message
-
RE: objects as key/values
Devaraj k 2013-07-30, 02:43
You can write custom key/value classes by implementing org.apache.hadoop.io.Writable interface for your Job.

http://hadoop.apache.org/docs/current/api/org/apache/hadoop/io/Writable.html

Thanks
Devaraj k

From: jamal sasha [mailto:[EMAIL PROTECTED]]
Sent: 30 July 2013 10:27
To: [EMAIL PROTECTED]
Subject: objects as key/values

Ok.
  A very basic (stupid) question.
I am trying to compute mean using hadoop.

So my implementation is like this:

public class Mean
 public static class Pair{
  //simple class to create object
}
 public class MeanMapper<LongWritable, Text,Text, Pair>
   emit(text,pair) //where pair is (local sum, count)

 public class MeanReducer<Text, Pair, Text DoubleWritable>
    emit (text, mean)

Unfortunately such approach of creating custom class types are not working
since in job I have to set the output type for mapper/reducer...
How are custom key values pair implemented in hadoop?