Skip to content

Commit c48dadb

Browse files
committed
query refresh partitionTables
1 parent f0de20d commit c48dadb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
129129
}
130130
tryTimes++;
131131
try {
132-
// 重试时重新 getTable
133132
if (tryTimes > 1) {
134133
if (client.isOdpMode()) {
135134
subObTable = client.getOdpTable();
@@ -273,7 +272,6 @@ protected ObPayload commonExecute(ObTableClient client, Logger logger,
273272
/*
274273
* Next.
275274
*/
276-
// 这个函数中,任何的计算结果都会填充到cacheRows
277275
public boolean next() throws Exception {
278276
checkStatus();
279277
lock.lock();
@@ -325,7 +323,7 @@ public boolean next() throws Exception {
325323

326324
} catch (Exception e) {
327325
if (e instanceof ObTableNeedFetchAllException) {
328-
// Adjust the start key and refresh the expectant
326+
// Adjust the start key and refresh the expectant
329327
this.tableQuery.adjustStartKey(currentStartKey);
330328
setExpectant(refreshPartition(tableQuery, tableName));
331329

@@ -408,7 +406,6 @@ protected Map<Long, ObPair<Long, ObTableParam>> buildPartitions(ObTableClient cl
408406
return partitionObTables;
409407
}
410408

411-
// 上层会不断的调getRow, 也就是不断的取出缓存,所以可以在这里给row赋值的时候顺便把这个row记录下来,用来作为最后拿到的key
412409
protected void nextRow() {
413410
rowIndex = rowIndex + 1;
414411
row = cacheRows.poll();

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,27 @@ public class ObTableQuery extends AbstractPayload {
7676
public void adjustStartKey(List<ObObj> key) throws IllegalArgumentException {
7777
List<ObNewRange> keyRanges = getKeyRanges();
7878
for (ObNewRange range : keyRanges) {
79-
if (isKeyInRange(range, key)) {
79+
if (key != null && isKeyInRange(range, key)) {
8080
byte[] bytes = parseStartKeyToBytes(key);
81+
ObRowKey newStartKey;
8182
if (getScanOrder() == ObScanOrder.Forward) {
82-
ObRowKey newStartKey = ObRowKey.getInstance(new Object[]{incrementByteArray(bytes), ObObj.getMin(), ObObj.getMin()});
83-
range.setStartKey(newStartKey);
83+
newStartKey = ObRowKey.getInstance(new Object[]{incrementByteArray(bytes), ObObj.getMin(), ObObj.getMin()});
8484
} else {
85-
ObRowKey newStartKey = ObRowKey.getInstance(new Object[]{decrementByteArray(bytes), ObObj.getMax(), ObObj.getMax()});
86-
range.setEndKey(newStartKey);
85+
newStartKey = ObRowKey.getInstance(new Object[]{decrementByteArray(bytes), ObObj.getMax(), ObObj.getMax()});
8786
}
87+
range.setStartKey(newStartKey);
8888
return;
8989
}
9090
}
91-
throw new IllegalArgumentException("Key not found in any KeyRange.");
91+
/* keyRanges not changed */
9292
}
9393

9494
private byte[] parseStartKeyToBytes(List<ObObj> key) {
95-
ObObj obObjKey = key.get(0);
96-
return obObjKey.encode();
95+
if (key != null) {
96+
ObObj obObjKey = key.get(0);
97+
return obObjKey.encode();
98+
}
99+
return new byte[0];
97100
}
98101

99102
private boolean isKeyInRange(ObNewRange range, List<ObObj> key) {

0 commit comments

Comments
 (0)