You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ec...@apache.org on 2015/06/01 23:00:47 UTC
hbase git commit: HBASE-13638 Put copy constructor is shallow
Repository: hbase
Updated Branches:
refs/heads/branch-1.0 77740289a -> 064c5aa88
HBASE-13638 Put copy constructor is shallow
Deep copy the cell list
Signed-off-by: Elliott Clark <ec...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/064c5aa8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/064c5aa8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/064c5aa8
Branch: refs/heads/branch-1.0
Commit: 064c5aa8883a3bd092fc3f1edfa599f0a1e5a601
Parents: 7774028
Author: Changgeng Li <ch...@fb.com>
Authored: Mon Jun 1 10:27:44 2015 -0700
Committer: Elliott Clark <ec...@apache.org>
Committed: Mon Jun 1 14:00:28 2015 -0700
----------------------------------------------------------------------
.../org/apache/hadoop/hbase/client/Put.java | 2 +-
.../org/apache/hadoop/hbase/client/TestPut.java | 43 ++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/064c5aa8/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
index d72492c..1fdc4e2 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
@@ -123,7 +123,7 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
this(putToCopy.getRow(), putToCopy.ts);
this.familyMap = new TreeMap<byte [], List<Cell>>(Bytes.BYTES_COMPARATOR);
for(Map.Entry<byte [], List<Cell>> entry: putToCopy.getFamilyCellMap().entrySet()) {
- this.familyMap.put(entry.getKey(), entry.getValue());
+ this.familyMap.put(entry.getKey(), new ArrayList<Cell>(entry.getValue()));
}
this.durability = putToCopy.durability;
for (Map.Entry<String, byte[]> entry : putToCopy.getAttributesMap().entrySet()) {
http://git-wip-us.apache.org/repos/asf/hbase/blob/064c5aa8/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPut.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPut.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPut.java
new file mode 100644
index 0000000..3a877dc
--- /dev/null
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPut.java
@@ -0,0 +1,43 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hbase.client;
+
+import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+public class TestPut {
+ @Test
+ public void testCopyConstructor() {
+ Put origin = new Put(Bytes.toBytes("ROW-01"));
+ byte[] family = Bytes.toBytes("CF-01");
+ byte[] qualifier = Bytes.toBytes("Q-01");
+
+ origin.addColumn(family, qualifier, Bytes.toBytes("V-01"));
+ Put clone = new Put(origin);
+
+ assertEquals(origin.getCellList(family), clone.getCellList(family));
+ origin.addColumn(family, qualifier, Bytes.toBytes("V-02"));
+
+ //They should have different cell lists
+ assertNotEquals(origin.getCellList(family), clone.getCellList(family));
+
+ }
+}