Skip to content

Commit 7babeae

Browse files
committed
compatbile to original hbase checkandmutate different row operations
1 parent d4e53e4 commit 7babeae

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/main/java/com/alipay/oceanbase/hbase/OHTable.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,6 @@ private boolean checkAndMutation(byte[] row, byte[] family, byte[] qualifier,
13241324
RowMutations rowMutations) throws Exception {
13251325
checkArgument(row != null, "row is null");
13261326
checkArgument(isNotBlank(Bytes.toString(family)), "family is blank");
1327-
checkArgument(Bytes.equals(row, rowMutations.getRow()),
1328-
"mutation row is not equal check row");
13291327
checkArgument(!rowMutations.getMutations().isEmpty(), "mutation is empty");
13301328
List<Mutation> mutations = rowMutations.getMutations();
13311329
// only one family operation is allowed

src/test/java/com/alipay/oceanbase/hbase/HTableTestBase.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4942,6 +4942,7 @@ public void testCheckAndDelete() throws IOException {
49424942
public void testCheckAndMutate() throws IOException {
49434943
// Mutate 只支持操作一行数据
49444944
String key = "checkAndMutateKey";
4945+
String key1 = "checkAndMutateKey1";
49454946
String column1 = "checkAndMutateColumn";
49464947
String column2 = "checkAndMutateColumn2";
49474948
String value1 = "value1";
@@ -5080,6 +5081,36 @@ public void testCheckAndMutate() throws IOException {
50805081
get.setMaxVersions(Integer.MAX_VALUE);
50815082
r = hTable.get(get);
50825083
Assert.assertEquals(10, r.raw().length);
5084+
5085+
// test different row operations
5086+
put1 = new Put(key1.getBytes());
5087+
put1.add(family.getBytes(), column1.getBytes(), t, value1.getBytes());
5088+
put1.add(family.getBytes(), column2.getBytes(), t, value2.getBytes());
5089+
5090+
put2 = new Put(key1.getBytes());
5091+
put2.add(family.getBytes(), column1.getBytes(), t + 3, value2.getBytes());
5092+
put2.add(family.getBytes(), column2.getBytes(), t + 3, value1.getBytes());
5093+
5094+
put3 = new Put(key1.getBytes());
5095+
put3.add(family.getBytes(), column1.getBytes(), t + 5, value1.getBytes());
5096+
put3.add(family.getBytes(), column2.getBytes(), t + 5, value2.getBytes());
5097+
5098+
rowMutations = new RowMutations(key1.getBytes());
5099+
rowMutations.add(put1);
5100+
rowMutations.add(put2);
5101+
rowMutations.add(put3);
5102+
// check specific row in server and execute different row operations
5103+
assertTrue(hTable.checkAndMutate(key.getBytes(), family.getBytes(), column1.getBytes(),
5104+
CompareFilter.CompareOp.EQUAL, value1.getBytes(), rowMutations));
5105+
5106+
assertTrue(hTable.checkAndMutate(key.getBytes(), family.getBytes(), column2.getBytes(),
5107+
CompareFilter.CompareOp.GREATER, value1.getBytes(), rowMutations));
5108+
5109+
assertFalse(hTable.checkAndMutate(key.getBytes(), family.getBytes(), column1.getBytes(),
5110+
CompareFilter.CompareOp.LESS, value1.getBytes(), rowMutations));
5111+
5112+
assertFalse(hTable.checkAndMutate(key.getBytes(), family.getBytes(), column2.getBytes(),
5113+
CompareFilter.CompareOp.GREATER, value2.getBytes(), rowMutations));
50835114
}
50845115

50855116
@Test

0 commit comments

Comments
 (0)