Return-Path: X-Original-To: apmail-hadoop-common-dev-archive@www.apache.org Delivered-To: apmail-hadoop-common-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BAAC09D85 for ; Thu, 12 Apr 2012 17:21:48 +0000 (UTC) Received: (qmail 35274 invoked by uid 500); 12 Apr 2012 17:21:44 -0000 Delivered-To: apmail-hadoop-common-dev-archive@hadoop.apache.org Received: (qmail 35203 invoked by uid 500); 12 Apr 2012 17:21:44 -0000 Mailing-List: contact common-dev-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-dev@hadoop.apache.org Received: (qmail 35167 invoked by uid 99); 12 Apr 2012 17:21:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 17:21:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2012 17:21:43 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 3C5CC367EBE for ; Thu, 12 Apr 2012 17:21:23 +0000 (UTC) Date: Thu, 12 Apr 2012 17:21:23 +0000 (UTC) From: "Todd Lipcon (Resolved) (JIRA)" To: common-dev@hadoop.apache.org Message-ID: <1640604095.18128.1334251283272.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1548652738.17984.1334249717190.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Resolved] (HADOOP-8272) BytesWritable length problem MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HADOOP-8272?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Todd Lipcon resolved HADOOP-8272. --------------------------------- Resolution: Invalid This is not a bug - this is the expected behavior of getBytes(). Please refer to the javadoc: {code} /** * Get the data backing the BytesWritable. Please use {@link #copyBytes()} * if you need the returned array to be precisely the length of the data. * @return The data is only valid between 0 and getLength() - 1. */ {code} > 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 > Labels: hadoop > Original Estimate: 1h > Remaining Estimate: 1h > > 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