HBASE-21021 Result returned by Append operation should be ordered

Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Nihal Jain 2018-08-07 21:17:11 +05:30 committed by Andrew Purtell
parent 895dac0819
commit 158607bf23
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
2 changed files with 39 additions and 1 deletions

View File

@ -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;

View File

@ -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;
@ -139,6 +140,42 @@ public class TestAtomicOperation {
assertEquals(0, Bytes.compareTo(Bytes.toBytes(v2+v1), result.getValue(fam1, qual2)));
}
@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);