HBASE-1717 Put on client-side uses passed-in byte[]s rather than always using copies

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@798693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Gray 2009-07-28 20:00:34 +00:00
parent 3c8db4d968
commit fbf3924236

View File

@ -23,6 +23,7 @@ import java.io.DataInput;
import java.io.DataOutput; import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -77,7 +78,7 @@ public class Put implements HeapSize, Writable, Comparable<Put> {
if(row == null || row.length > HConstants.MAX_ROW_LENGTH) { if(row == null || row.length > HConstants.MAX_ROW_LENGTH) {
throw new IllegalArgumentException("Row key is invalid"); throw new IllegalArgumentException("Row key is invalid");
} }
this.row = row; this.row = Arrays.copyOf(row, row.length);
if(rowLock != null) { if(rowLock != null) {
this.lockId = rowLock.getLockId(); this.lockId = rowLock.getLockId();
} }
@ -136,12 +137,14 @@ public class Put implements HeapSize, Writable, Comparable<Put> {
KeyValue kv = new KeyValue(this.row, family, qualifier, ts, KeyValue kv = new KeyValue(this.row, family, qualifier, ts,
KeyValue.Type.Put, value); KeyValue.Type.Put, value);
list.add(kv); list.add(kv);
familyMap.put(family, list); familyMap.put(kv.getFamily(), list);
return this; 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 * @param kv
*/ */
public Put add(KeyValue kv) throws IOException{ public Put add(KeyValue kv) throws IOException{