File tree Expand file tree Collapse file tree 3 files changed +97
-93
lines changed
main/java/com/alipay/oceanbase/rpc/mutation
test/java/com/alipay/oceanbase/rpc Expand file tree Collapse file tree 3 files changed +97
-93
lines changed Original file line number Diff line number Diff line change 1717
1818package com .alipay .oceanbase .rpc .mutation ;
1919
20- import com .alipay .oceanbase .rpc .ObClusterTableQuery ;
20+ import com .alipay .oceanbase .rpc .ObTableClient ;
2121import com .alipay .oceanbase .rpc .exception .ObTableException ;
2222import com .alipay .oceanbase .rpc .mutation .result .BatchOperationResult ;
2323import com .alipay .oceanbase .rpc .protocol .payload .impl .execute .ObTableOperationType ;
24- import com .alipay .oceanbase .rpc .table .ObTableClientQueryImpl ;
2524import com .alipay .oceanbase .rpc .table .api .Table ;
2625import com .alipay .oceanbase .rpc .table .api .TableBatchOps ;
2726import com .alipay .oceanbase .rpc .table .api .TableQuery ;
@@ -97,11 +96,17 @@ public BatchOperation addOperation(List<Mutation> mutations) {
9796 }
9897
9998 public BatchOperationResult execute () throws Exception {
99+ // add rowkeyElement
100+ boolean hasSetRowkeyElement = false ;
100101 TableBatchOps batchOps = client .batch (tableName );
101102
102103 for (Object operation : operations ) {
103104 if (operation instanceof Mutation ) {
104105 Mutation mutation = (Mutation ) operation ;
106+ if (!hasSetRowkeyElement && mutation .getRowKeyNames () != null ) {
107+ ((ObTableClient ) client ).addRowKeyElement (tableName , (String []) mutation .getRowKeyNames ().toArray (new String [0 ]));
108+ hasSetRowkeyElement = true ;
109+ }
105110 ObTableOperationType type = mutation .getOperationType ();
106111 switch (type ) {
107112 case GET :
Original file line number Diff line number Diff line change 2626import com .alipay .oceanbase .rpc .table .api .TableQuery ;
2727
2828import java .util .ArrayList ;
29- import java .util .Arrays ;
3029import java .util .List ;
3130import java .util .Map ;
3231
@@ -36,7 +35,7 @@ public class Mutation<T> {
3635 protected Object [] rowKey ;
3736 private TableQuery query ;
3837 private boolean hasSetRowKey = false ;
39- protected List <String > rowKeyNames = null ; // for removeRowkeyFromMutateColval
38+ protected List <String > rowKeyNames = null ;
4039
4140 /*
4241 * default constructor
@@ -111,6 +110,13 @@ public ObTableOperationType getOperationType() {
111110 return null ;
112111 }
113112
113+ /*
114+ * get rowkey names
115+ */
116+ public List <String > getRowKeyNames () {
117+ return rowKeyNames ;
118+ }
119+
114120 /*
115121 * set client
116122 */
You can’t perform that action at this time.
0 commit comments