Return-Path: Delivered-To: apmail-hadoop-hbase-commits-archive@minotaur.apache.org Received: (qmail 37703 invoked from network); 28 Jul 2009 20:00:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Jul 2009 20:00:57 -0000 Received: (qmail 84908 invoked by uid 500); 28 Jul 2009 20:00:57 -0000 Delivered-To: apmail-hadoop-hbase-commits-archive@hadoop.apache.org Received: (qmail 84861 invoked by uid 500); 28 Jul 2009 20:00:57 -0000 Mailing-List: contact hbase-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-dev@hadoop.apache.org Delivered-To: mailing list hbase-commits@hadoop.apache.org Received: (qmail 84826 invoked by uid 99); 28 Jul 2009 20:00:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 20:00:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2009 20:00:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A3F8123888E7; Tue, 28 Jul 2009 20:00:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r798693 - /hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java Date: Tue, 28 Jul 2009 20:00:34 -0000 To: hbase-commits@hadoop.apache.org From: jgray@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090728200034.A3F8123888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jgray Date: Tue Jul 28 20:00:34 2009 New Revision: 798693 URL: http://svn.apache.org/viewvc?rev=798693&view=rev Log: HBASE-1717 Put on client-side uses passed-in byte[]s rather than always using copies Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java?rev=798693&r1=798692&r2=798693&view=diff ============================================================================== --- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java (original) +++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java Tue Jul 28 20:00:34 2009 @@ -23,6 +23,7 @@ import java.io.DataOutput; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -77,7 +78,7 @@ if(row == null || row.length > HConstants.MAX_ROW_LENGTH) { throw new IllegalArgumentException("Row key is invalid"); } - this.row = row; + this.row = Arrays.copyOf(row, row.length); if(rowLock != null) { this.lockId = rowLock.getLockId(); } @@ -136,12 +137,14 @@ KeyValue kv = new KeyValue(this.row, family, qualifier, ts, KeyValue.Type.Put, value); list.add(kv); - familyMap.put(family, list); + familyMap.put(kv.getFamily(), list); return this; } /** - * Add the specified KeyValue to this Put operation. + * Add the specified KeyValue to this Put operation. Operation assumes that + * the passed KeyValue is immutable and its backing array will not be modified + * for the duration of this Put. * @param kv */ public Put add(KeyValue kv) throws IOException{ @@ -152,7 +155,7 @@ } //Checking that the row of the kv is the same as the put int res = Bytes.compareTo(this.row, 0, row.length, - kv.getBuffer(), kv.getRowOffset(), kv.getRowLength()); + kv.getBuffer(), kv.getRowOffset(), kv.getRowLength()); if(res != 0) { throw new IOException("The row in the recently added KeyValue " + Bytes.toStringBinary(kv.getBuffer(), kv.getRowOffset(),