In Hadoop, there is no basic type class (Integer, float, etc.) that comes with Java, but instead uses the classes that you have developed. Hadoop comes with a number of serialization types, roughly divided into the following two categories:
- Classes that implement the Writablecomparable interface
Base: booleanwritable | Bytewritable
Numbers: intwritable | vintwritable | floatwritable | longwritable | vlongwritable | Doublewritable
Advanced: nullwritable | Text | byteswritable | Mdshash | objectwritable | Genericwritable
- Classes that implement only the writable interface
Array: arraywritable | Twodarraywritable
Mapping: abstractmapwritable | mapwritable | Sortedmapwritable
To facilitate understanding of the writable types that Hadoop comes with, we use the following table to demonstrate the correspondence between Java primitives and writable
Ja VA basic type |
writable implementation |
strong> bytes |
Boolean |
booleanwritable |
1 / td> |
Byte |
bytewritable |
1 |
I NT |
intwritable |
4 |
Float |
Floatwri Table |
4 |
Long |
longwritable |
8 |
Double |
doublewritable |
8 |
for the writable types in Hadoop above, we'll just briefly introduce Text. The Text class is a writable type in the UTF-8 format. It can be understood as a type of writable similar to java.lang.String. Text uses the int type to store the number of bytes in the character encoding, and the maximum value is 2GB. It has a find () method, equivalent to the IndexOf () method in Java's String. The Text instance is reused primarily through the set (byte[] utf8) method, as follows
Text text = new text ("Hadoop");//Construct a text object
Text.set ("AutoNavi");//re-assign value
Writable type of Hadoop comes with