how to create custom key and custom value in MapReduce Job

Free Online Certification Courses – Learn Today. Lead Tomorrow. Forums Apache Hadoop how to create custom key and custom value in MapReduce Job

Viewing 1 reply thread
  • Author
    Posts
    • #4682
      DataFlair TeamDataFlair Team
      Spectator

      I want to send more than one value from Mapper to reducer, I can do the same by creating custom key / value. How to create custom key and value ?

    • #4683
      DataFlair TeamDataFlair Team
      Spectator

      In Hadoop, data types to be used as the key must implement WritableComparable interface and data types to be used as value must implement Writable interface.
      If your custom key/value are of the same type then you can write one custom datatype for both the key/value which implements WritableComparable otherwise you need to implement two different data types. One for the key which implements the WritableComparable interface and other for value which implements Writable interface.

      //Custom Data-Type
      public class MyCustomeKey implements WritableComparable
      {}

      //Create Mapper with Custome Key
      public class MyMapper extends Mapper
      {
      }

      For more details, please follow:
      http://data-flair.training/blogs/hadoop-mapreduce-introduction-tutorial-comprehensive-guide/

Viewing 1 reply thread
  • You must be logged in to reply to this topic.