|
46 | 46 | import java.util.concurrent.atomic.AtomicReference; |
47 | 47 | import java.util.concurrent.locks.ReentrantLock; |
48 | 48 |
|
| 49 | +import static com.alipay.oceanbase.rpc.protocol.payload.Constants.INVALID_TABLET_ID; |
49 | 50 | import static com.alipay.oceanbase.rpc.util.TableClientLoggerFactory.RUNTIME; |
50 | 51 |
|
51 | 52 | public abstract class AbstractQueryStreamResult extends AbstractPayload implements |
@@ -412,7 +413,7 @@ public boolean next() throws Exception { |
412 | 413 | } |
413 | 414 | } |
414 | 415 |
|
415 | | - protected Map<Long, ObPair<Long, ObTableParam>> buildPartitions(ObTableClient client, ObTableQuery tableQuery, String tableName) throws Exception { |
| 416 | + protected Map<Long, ObPair<Long, ObTableParam>> buildAllPartitions(ObTableClient client, ObTableQuery tableQuery, String tableName) throws Exception { |
416 | 417 | Map<Long, ObPair<Long, ObTableParam>> partitionObTables = new LinkedHashMap<>(); |
417 | 418 | String indexName = tableQuery.getIndexName(); |
418 | 419 | if (!client.isOdpMode()) { |
@@ -456,6 +457,40 @@ protected Map<Long, ObPair<Long, ObTableParam>> buildPartitions(ObTableClient cl |
456 | 457 | return partitionObTables; |
457 | 458 | } |
458 | 459 |
|
| 460 | + protected Map<Long, ObPair<Long, ObTableParam>> buildFirstPartitions(ObTableClient client, ObTableQuery tableQuery, String tableName) throws Exception { |
| 461 | + Map<Long, ObPair<Long, ObTableParam>> partitionObTables = new LinkedHashMap<>(); |
| 462 | + String indexName = tableQuery.getIndexName(); |
| 463 | + |
| 464 | + if (!this.client.isOdpMode()) { |
| 465 | + indexTableName = client.getIndexTableName(tableName, indexName, tableQuery.getScanRangeColumns(), false); |
| 466 | + } |
| 467 | + |
| 468 | + if (tableQuery.getKeyRanges().isEmpty()) { |
| 469 | + throw new IllegalArgumentException("query ranges is empty"); |
| 470 | + } else { |
| 471 | + ObNewRange range = tableQuery.getKeyRanges().get(0); |
| 472 | + ObRowKey startKey = range.getStartKey(); |
| 473 | + int startKeySize = startKey.getObjs().size(); |
| 474 | + Object[] start = new Object[startKeySize]; |
| 475 | + |
| 476 | + for (int i = 0; i < startKeySize; i++) { |
| 477 | + start[i] = startKey.getObj(i).isMinObj() || startKey.getObj(i).isMaxObj() ? |
| 478 | + startKey.getObj(i) : startKey.getObj(i).getValue(); |
| 479 | + } |
| 480 | + |
| 481 | + if (this.entityType == ObTableEntityType.HKV && client.isTableGroupName(tableName)) { |
| 482 | + indexTableName = client.tryGetTableNameFromTableGroupCache(tableName, false); |
| 483 | + } |
| 484 | + ObBorderFlag borderFlag = range.getBorderFlag(); |
| 485 | + List<ObTableParam> params = this.client.getTableParams(indexTableName, tableQuery, start, |
| 486 | + borderFlag.isInclusiveStart(), start, borderFlag.isInclusiveEnd()); |
| 487 | + |
| 488 | + partitionObTables.put(INVALID_TABLET_ID, new ObPair<>(params.get(0).getPartId(), params.get(0))); |
| 489 | + } |
| 490 | + |
| 491 | + return partitionObTables; |
| 492 | + } |
| 493 | + |
459 | 494 | protected void nextRow() { |
460 | 495 | rowIndex = rowIndex + 1; |
461 | 496 | row = cacheRows.poll(); |
|
0 commit comments