简体   繁体   中英

Using Hadoop Text Object toString() Method

I understood the difference between String & Text. Difference between Text and String in Hadoop

Question is If we are saying that String maximum storage size is 32767 bytes.

Text t = new Text("Hadoo... 2GB of content");
...
String c = t.toString();

How "c" will hold 2GB of data if it has size limitation?

What am I missing here?

The maximum size of a Java String is not 32k bytes. It is the size needed to store Integer.MAX_VALUE characters, which is 2^31 - 1 (~2 Billion), which is around 4GB (see this post ).

The post that you mention, refers to the size limit of the deprecated UTF-8 class , not Java's String class.

Anyway, if you need so much space for a single Text instance, I would advise you to reconsider your algorithm. As Peter Lawrey says in the afforementioned post "I suspect all the works of JK Rowling would fit into one string."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM