hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Carey (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HADOOP-6868) Text class should provide method to return byte array of getLength()
Date Tue, 20 Jul 2010 18:27:49 GMT

    [ https://issues.apache.org/jira/browse/HADOOP-6868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12890374#action_12890374
] 

Scott Carey commented on HADOOP-6868:
-------------------------------------


I don't think that is a bug.  Passing around byte arrays larger than the valid data is common
practice in Java for performance reasons.  Hence, the common method signature containing 
(byte[] bytes, int len, int offset) and similar.   Creating a new byte array for each resize
defeats the purpose of re-using the byte array and the Text object -- lower memory allocation
and improved CPU cache locality. The byte array here is a buffer, it does not represent the
entire string.

Instead, use the 'helper' method, toString(). 



> Text class should provide method to return byte array of getLength()
> --------------------------------------------------------------------
>
>                 Key: HADOOP-6868
>                 URL: https://issues.apache.org/jira/browse/HADOOP-6868
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: util
>    Affects Versions: 0.20.2
>            Reporter: Ted Yu
>
> People would use the following code to convert Text to String:
> String valueString = new String(valueText.getBytes(), "UTF-8");
> However, if Text is reused, the above call would return String of monotonically increasing
length.
> From 'Hadoop and XML' discussion thread:
> The problem I am seeing is between the Map phase and the
> Reduce phase, the XML is getting munged.  For Example:
>  </PrivateRate>
>  </PrivateRateSet>te>
> Text should provide method to return byte array of getLength() length.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message