BytesWritable length problem
----------------------------

                 Key: HADOOP-8272
                 URL: https://issues.apache.org/jira/browse/HADOOP-8272
             Project: Hadoop Common
          Issue Type: Bug
          Components: io
    Affects Versions: 0.20.205.0
            Reporter: Simon Gilliot


I tried to create my own Writable which contains a BytesWritable.

In my conctructor, I tried to create an empty BytesWritable :
BytesWritable key = new BytesWritable();

Next, in my readFields, I did :
key.readFields(in); LOG.debug(Bytes.toString(key.getBytes()));

The key contains much more bytes than I had wrote.
In fact, if my BytesWritable contains 100 bytes, I thing that the readFields() 
of BytesWritable call :
* setSize(0) (which seems useless since the values in the old range are 
preserved and any new values are undefined). * setSize(100) which extends the 
bytes array (by setCapacity) to 1.5 * the size (so 150) without initalizing it
* readFully(bytes, 0, 100) which fill the bytes array from '0' to '100' offsets.

And when I call getBytes() on it, the bytes array of 150 bytes is returned 
without any control.

That seems possible that the same problem happens in other conditions, when we 
increase ths bytes array size.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to