Skip to content

Commit 1e273bf

Browse files
committed
fix compatibility problem
1 parent 784bcb8 commit 1e273bf

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

src/main/java/com/alipay/oceanbase/rpc/mutation/BatchOperation.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,26 @@ public BatchOperation setTable(String tableName) {
8989
* add queries
9090
*/
9191
public BatchOperation addOperation(TableQuery... queries) {
92-
if (isSameType && lastType != ObTableOperationType.INVALID
93-
&& lastType != ObTableOperationType.GET) {
94-
isSameType = false;
92+
boolean isHBaseQuery = false;
93+
for (TableQuery query : queries) {
94+
if (query.getObTableQuery().isHbaseQuery()) {
95+
isHBaseQuery = true;
96+
}
97+
break;
98+
}
99+
if (isHBaseQuery) {
100+
if (isSameType && lastType != ObTableOperationType.INVALID
101+
&& lastType != ObTableOperationType.SCAN) {
102+
isSameType = false;
103+
}
104+
lastType = ObTableOperationType.SCAN;
105+
} else {
106+
if (isSameType && lastType != ObTableOperationType.INVALID
107+
&& lastType != ObTableOperationType.GET) {
108+
isSameType = false;
109+
}
110+
lastType = ObTableOperationType.GET;
95111
}
96-
97-
lastType = ObTableOperationType.GET;
98112
this.operations.addAll(Arrays.asList(queries));
99113
return this;
100114
}

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/ObTableOperationType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public enum ObTableOperationType {
3434

3535
private int value;
3636
private static Map<Integer, ObTableOperationType> map = new HashMap<Integer, ObTableOperationType>();
37-
private static final List<Boolean> needEncodeQuery = Arrays.asList(true, // GET
37+
private static final List<Boolean> needEncodeQuery = Arrays.asList(false, // GET
3838
false, // INSERT
3939
false, // DEL
4040
false, // UPDATE
4141
false, // INSERT_OR_UPDATE
4242
false, // REPLACE
4343
false, // INCREMENT
4444
false, // APPEND
45-
false, // SCAN
45+
true, // SCAN
4646
false, // TTL
4747
true, // CHECK_AND_INSERT_UP
4848
false, // PUT

src/main/java/com/alipay/oceanbase/rpc/protocol/payload/impl/execute/ObTableSingleOp.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ public void addEntity(ObTableSingleOpEntity entity) {
163163
public List<ObObj> getRowkeyObjs() {
164164
List<ObObj> rowkeyObjs;
165165
if (singleOpType == ObTableOperationType.SCAN) {
166-
throw new IllegalArgumentException("can not get rowkey from scan operation");
166+
if (query.isHbaseQuery()) {
167+
rowkeyObjs = entities.get(0).getRowkey();
168+
} else {
169+
throw new IllegalArgumentException("can not get rowkey from scan operation");
170+
}
167171
} else if (singleOpType == ObTableOperationType.CHECK_AND_INSERT_UP) {
168172
rowkeyObjs = getScanRange().get(0).getStartKey().getObjs();
169173
} else {

src/main/java/com/alipay/oceanbase/rpc/table/ObTableClientLSBatchOpsImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ public void addOperation(TableQuery query) throws Exception {
206206
obTableQuery.isHbaseQuery(), obTableQuery.gethTableFilter(),
207207
obTableQuery.getObKVParams(), obTableQuery.getFilterString());
208208
singleOp.setQuery(singleOpQuery);
209+
singleOp.setSingleOpType(ObTableOperationType.SCAN);
210+
} else {
211+
singleOp.setSingleOpType(ObTableOperationType.GET);
209212
}
210-
singleOp.setSingleOpType(ObTableOperationType.GET);
211213
singleOp.addEntity(entity);
212214
addOperation(singleOp);
213215
}

0 commit comments

Comments
 (0)