Writable type of Hadoop comes with

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.