You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2018/09/11 22:10:56 UTC

[3/3] hbase git commit: HBASE-21021 Result returned by Append operation should be ordered

HBASE-21021 Result returned by Append operation should be ordered

Signed-off-by: Andrew Purtell <ap...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/158607bf
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/158607bf
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/158607bf

Branch: refs/heads/branch-1
Commit: 158607bf239367df6364db60297af0aac4f66925
Parents: 895dac0
Author: Nihal Jain <ni...@gmail.com>
Authored: Tue Aug 7 21:17:11 2018 +0530
Committer: Andrew Purtell <ap...@apache.org>
Committed: Tue Sep 11 15:04:50 2018 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegion.java      |  3 +-
 .../hbase/regionserver/TestAtomicOperation.java | 37 ++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/158607bf/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index d333619..b682b50 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -48,6 +48,7 @@ import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -7735,7 +7736,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
     boolean writeToWAL = durability != Durability.SKIP_WAL;
     WALEdit walEdits = null;
     List<Cell> allKVs = new ArrayList<Cell>(mutate.size());
-    Map<Store, List<Cell>> tempMemstore = new HashMap<Store, List<Cell>>();
+    Map<Store, List<Cell>> tempMemstore = new LinkedHashMap<Store, List<Cell>>();
     Map<Store, List<Cell>> removedCellsForMemStore = new HashMap<>();
     long size = 0;
     long txid = 0;

http://git-wip-us.apache.org/repos/asf/hbase/blob/158607bf/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java
index b9f2290..cc5f5fc 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.regionserver;
 import static org.apache.hadoop.hbase.HBaseTestingUtility.fam1;
 import static org.apache.hadoop.hbase.HBaseTestingUtility.fam2;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -140,6 +141,42 @@ public class TestAtomicOperation {
   }
 
   @Test
+  public void testAppendWithMultipleFamilies() throws IOException {
+    final byte[] fam3 = Bytes.toBytes("colfamily31");
+    initHRegion(tableName, name.getMethodName(), fam1, fam2, fam3);
+    String v1 = "Appended";
+    String v2 = "Value";
+
+    Append a = new Append(row);
+    a.setReturnResults(false);
+    a.add(fam1, qual1, Bytes.toBytes(v1));
+    a.add(fam2, qual2, Bytes.toBytes(v2));
+    assertNull(region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE));
+
+    a = new Append(row);
+    a.add(fam2, qual2, Bytes.toBytes(v1));
+    a.add(fam1, qual1, Bytes.toBytes(v2));
+    a.add(fam3, qual3, Bytes.toBytes(v2));
+    a.add(fam1, qual2, Bytes.toBytes(v1));
+
+    Result result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
+
+    byte[] actualValue1 = result.getValue(fam1, qual1);
+    byte[] actualValue2 = result.getValue(fam2, qual2);
+    byte[] actualValue3 = result.getValue(fam3, qual3);
+    byte[] actualValue4 = result.getValue(fam1, qual2);
+
+    assertNotNull("Value1 should bot be null", actualValue1);
+    assertNotNull("Value2 should bot be null", actualValue2);
+    assertNotNull("Value3 should bot be null", actualValue3);
+    assertNotNull("Value4 should bot be null", actualValue4);
+    assertEquals(0, Bytes.compareTo(Bytes.toBytes(v1 + v2), actualValue1));
+    assertEquals(0, Bytes.compareTo(Bytes.toBytes(v2 + v1), actualValue2));
+    assertEquals(0, Bytes.compareTo(Bytes.toBytes(v2), actualValue3));
+    assertEquals(0, Bytes.compareTo(Bytes.toBytes(v1), actualValue4));
+  }
+
+  @Test
   public void testAppendWithNonExistingFamily() throws IOException {
     initHRegion(tableName, name.getMethodName(), fam1);
     final String v1 = "Value";