@@ -4942,6 +4942,7 @@ public void testCheckAndDelete() throws IOException {
4942
4942
public void testCheckAndMutate () throws IOException {
4943
4943
// Mutate 只支持操作一行数据
4944
4944
String key = "checkAndMutateKey" ;
4945
+ String key1 = "checkAndMutateKey1" ;
4945
4946
String column1 = "checkAndMutateColumn" ;
4946
4947
String column2 = "checkAndMutateColumn2" ;
4947
4948
String value1 = "value1" ;
@@ -5080,6 +5081,36 @@ public void testCheckAndMutate() throws IOException {
5080
5081
get .setMaxVersions (Integer .MAX_VALUE );
5081
5082
r = hTable .get (get );
5082
5083
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 ));
5083
5114
}
5084
5115
5085
5116
@ Test
0 commit comments