HBASE-21021 Result returned by Append operation should be ordered
Signed-off-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
parent
2ab8122a24
commit
c372175da4
|
@ -20,6 +20,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.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -150,6 +151,44 @@ 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.addColumn(fam1, qual1, Bytes.toBytes(v1));
|
||||
a.addColumn(fam2, qual2, Bytes.toBytes(v2));
|
||||
Result result = region.append(a, HConstants.NO_NONCE, HConstants.NO_NONCE);
|
||||
assertTrue("Expected an empty result but result contains " + result.size() + " keys",
|
||||
result.isEmpty());
|
||||
|
||||
a = new Append(row);
|
||||
a.addColumn(fam2, qual2, Bytes.toBytes(v1));
|
||||
a.addColumn(fam1, qual1, Bytes.toBytes(v2));
|
||||
a.addColumn(fam3, qual3, Bytes.toBytes(v2));
|
||||
a.addColumn(fam1, qual2, Bytes.toBytes(v1));
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue