hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jg...@apache.org
Subject svn commit: r798693 - /hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/Put.java
Date Tue, 28 Jul 2009 20:00:34 GMT
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(), 



Mime
View raw message