Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Hadoop Text datatype mutable or immutable?

In one of the mapreduce program, I was using new Text() during context.write.

context.write(key, new Text(outputRecord.toDelimitedString("|")));

As I am using above statement, I want to know how Text objects are stored and how memory management is being handled. Also want to know about existence of a object value after not referred by any object.

Please let me know about this.

like image 528
Cast_A_Way Avatar asked Dec 04 '25 01:12

Cast_A_Way


1 Answers

No Text in Hadoop is not immutable. It can't be, because Hadoop's serialization process implicitly forbids immutability.

In this particular case, context.write will just serialize the content of Text into a byte buffer directly inside the call, so the Text object will be trashed soon after the method returns.

Keep in mind that there is still a stack reference to the Text object as it is passed into the method, so it won't be eligible for garbage collection.

like image 181
Thomas Jungblut Avatar answered Dec 05 '25 13:12

Thomas Jungblut



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!