|
32 | 32 | import com.alipay.oceanbase.rpc.table.api.TableQuery; |
33 | 33 | import com.alipay.oceanbase.rpc.util.MonitorUtil; |
34 | 34 |
|
35 | | -import java.util.HashMap; |
| 35 | +import java.util.LinkedHashMap; |
36 | 36 | import java.util.List; |
37 | 37 | import java.util.Map; |
38 | 38 |
|
@@ -153,7 +153,7 @@ private AbstractQueryStreamResult commonExecute(InitQueryResultCallback<Abstract |
153 | 153 | checkArgumentBeforeExec(); |
154 | 154 |
|
155 | 155 | final long startTime = System.currentTimeMillis(); |
156 | | - this.partitionObTables = new HashMap<Long, ObPair<Long, ObTableParam>>(); // partitionObTables -> Map<logicId, Pair<logicId, param>> |
| 156 | + this.partitionObTables = new LinkedHashMap<Long, ObPair<Long, ObTableParam>>(); // partitionObTables -> Map<logicId, Pair<logicId, param>> |
157 | 157 |
|
158 | 158 | // fill a whole range if no range is added explicitly. |
159 | 159 | if (tableQuery.getKeyRanges().isEmpty()) { |
@@ -276,8 +276,14 @@ public void initPartitions() throws Exception { |
276 | 276 | List<ObPair<Long, ObTableParam>> pairs = this.obTableClient.getTables(indexTableName, |
277 | 277 | tableQuery, start, borderFlag.isInclusiveStart(), end, borderFlag.isInclusiveEnd(), false, |
278 | 278 | false); |
279 | | - for (ObPair<Long, ObTableParam> pair : pairs) { |
280 | | - this.partitionObTables.put(pair.getLeft(), pair); |
| 279 | + if (this.tableQuery.getScanOrder() == ObScanOrder.Reverse) { |
| 280 | + for (int i = pairs.size() - 1; i >= 0; i--) { |
| 281 | + this.partitionObTables.put(pairs.get(i).getLeft(), pairs.get(i)); |
| 282 | + } |
| 283 | + } else { |
| 284 | + for (ObPair<Long, ObTableParam> pair : pairs) { |
| 285 | + this.partitionObTables.put(pair.getLeft(), pair); |
| 286 | + } |
281 | 287 | } |
282 | 288 | } |
283 | 289 | } |
|
0 commit comments