Why does Hadoop need classes like Text or IntWritable instead of String or Integer?

后端 未结 4 1345
名媛妹妹
名媛妹妹 2020-12-23 16:38

Why does Hadoop need to introduce these new classes? They just seem to complicate the interface

4条回答
  •  抹茶落季
    2020-12-23 17:36

    In order to handle the Objects in Hadoop way. For example, hadoop uses Text instead of java's String. The Text class in hadoop is similar to a java String, however, Text implements interfaces like Comparable, Writable and WritableComparable.

    These interfaces are all necessary for MapReduce; the Comparable interface is used for comparing when the reducer sorts the keys, and Writable can write the result to the local disk. It does not use the java Serializable because java Serializable is too big or too heavy for hadoop, Writable can serializable the hadoop Object in a very light way.

提交回复
热议问题