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