2727import com .alipay .oceanbase .rpc .mutation .*;
2828import com .alipay .oceanbase .rpc .protocol .payload .ObPayload ;
2929import com .alipay .oceanbase .rpc .protocol .payload .Pcodes ;
30+ import com .alipay .oceanbase .rpc .protocol .payload .impl .ObObj ;
3031import com .alipay .oceanbase .rpc .protocol .payload .impl .ObRowKey ;
3132import com .alipay .oceanbase .rpc .protocol .payload .impl .execute .*;
3233import com .alipay .oceanbase .rpc .protocol .payload .impl .execute .aggregation .ObTableAggregation ;
@@ -1829,14 +1830,20 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
18291830 ObServerRoute route ) throws Exception {
18301831 ReplicaLocation replica = null ;
18311832 long tabletId = getTabletIdByPartId (tableEntry , partId );
1833+ long partitionId = partId ;
18321834 ObPartitionLocationInfo obPartitionLocationInfo = null ;
18331835 if (ObGlobal .obVsnMajor () >= 4 ) {
18341836
18351837 obPartitionLocationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
18361838
18371839 replica = getPartitionLocation (obPartitionLocationInfo , route );
18381840 } else {
1839- ObPair <Long , ReplicaLocation > partitionReplica = getPartitionReplica (tableEntry , partId ,
1841+ if (tableEntry .isPartitionTable ()
1842+ && null != tableEntry .getPartitionInfo ().getSubPartDesc ()) {
1843+ partitionId = ObPartIdCalculator .getPartIdx (partId , tableEntry
1844+ .getPartitionInfo ().getSubPartDesc ().getPartNum ());
1845+ }
1846+ ObPair <Long , ReplicaLocation > partitionReplica = getPartitionReplica (tableEntry , partitionId ,
18401847 route );
18411848 replica = partitionReplica .getRight ();
18421849 }
@@ -1861,7 +1868,7 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
18611868 replica = getPartitionLocation (obPartitionLocationInfo , route );
18621869 } else {
18631870 tableEntry = getOrRefreshTableEntry (tableName , true , waitForRefresh , false );
1864- replica = getPartitionReplica (tableEntry , partId , route ).getRight ();
1871+ replica = getPartitionReplica (tableEntry , partitionId , route ).getRight ();
18651872 }
18661873
18671874 addr = replica .getAddr ();
@@ -1872,9 +1879,8 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
18721879 throw new ObTableGetException ("Cannot get table by addr: " + addr );
18731880 }
18741881 }
1875- ObTableParam param = null ;
1882+ ObTableParam param = createTableParam ( obTable , tableEntry , obPartitionLocationInfo , partId , tabletId ) ;
18761883 if (ObGlobal .obVsnMajor () >= 4 ) {
1877- param = createTableParam (obTable , tableEntry , obPartitionLocationInfo , partId , tabletId );
18781884 } else {
18791885 param .setPartId (partId );
18801886 param .setTableId (tableEntry .getTableId ());
@@ -1890,7 +1896,9 @@ private ObPartitionLocationInfo getOrRefreshPartitionInfo(TableEntry tableEntry,
18901896 ObPartitionLocationInfo obPartitionLocationInfo = tableEntry .getPartitionEntry ()
18911897 .getPartitionInfo (tabletId );
18921898 if (!obPartitionLocationInfo .initialized .get ()) {
1893- tableEntry = refreshTableLocationByTabletId (tableEntry , tableName , tabletId );
1899+ if (ObGlobal .obVsnMajor () >= 4 ) {
1900+ tableEntry = refreshTableLocationByTabletId (tableEntry , tableName , tabletId );
1901+ }
18941902 obPartitionLocationInfo = tableEntry .getPartitionEntry ().getPartitionInfo (tabletId );
18951903 obPartitionLocationInfo .initializationLatch .await ();
18961904 }
@@ -1940,10 +1948,19 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
19401948 ObPartitionLevel partitionLevel = tableEntry .getPartitionInfo ().getLevel ();
19411949 List <Long > partIds = getPartitionTablePartitionIds (tableEntry , startRow , startIncluded , endRow , endIncluded , partitionLevel );
19421950
1943- for (Long partId : partIds ) {
1944- long tabletId = getTabletIdByPartId (tableEntry , partId );
1945- ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
1946- replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
1951+ if (ObGlobal .obVsnMajor () >= 4 ) {
1952+ for (Long partId : partIds ) {
1953+ long tabletId = getTabletIdByPartId (tableEntry , partId );
1954+ ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
1955+ replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
1956+ }
1957+ } else {
1958+ for (Long partId : partIds ) {
1959+ long partitionId = ObPartIdCalculator .getPartIdx (partId , tableEntry
1960+ .getPartitionInfo ().getSubPartDesc ().getPartNum ());
1961+ replicas .add (new ObPair <Long , ReplicaLocation >(partId , getPartitionLocation (
1962+ tableEntry , partitionId , route )));
1963+ }
19471964 }
19481965
19491966 return replicas ;
@@ -3136,7 +3153,7 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
31363153 request .setTimeout (getOdpTable ().getObTableOperationTimeout ());
31373154 return getOdpTable ().execute (request );
31383155 } else {
3139- int maxRetries = getRuntimeRetryTimes (); // Define the maximum number of retries
3156+ int maxRetries = getRuntimeRetryTimes (); // Define the maximum number of retries
31403157 int tryTimes = 0 ;
31413158 long startExecute = System .currentTimeMillis ();
31423159 boolean needRefreshTableEntry = false ;
@@ -3158,7 +3175,7 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
31583175 try {
31593176 // Recalculate partIdMapObTable
31603177 // Clear the map before recalculating
3161- partIdMapObTable .clear ();
3178+ partIdMapObTable .clear ();
31623179 for (ObNewRange rang : tableQuery .getKeyRanges ()) {
31633180 ObRowKey startKey = rang .getStartKey ();
31643181 int startKeySize = startKey .getObjs ().size ();
@@ -3167,11 +3184,21 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
31673184 Object [] start = new Object [startKeySize ];
31683185 Object [] end = new Object [endKeySize ];
31693186 for (int i = 0 ; i < startKeySize ; i ++) {
3170- start [i ] = startKey .getObj (i ).getValue ();
3187+ ObObj curStart = startKey .getObj (i );
3188+ if (curStart .isMinObj ()) {
3189+ start [i ] = curStart ;
3190+ } else {
3191+ start [i ] = curStart .getValue ();
3192+ }
31713193 }
31723194
31733195 for (int i = 0 ; i < endKeySize ; i ++) {
3174- end [i ] = endKey .getObj (i ).getValue ();
3196+ ObObj curEnd = endKey .getObj (i );
3197+ if (curEnd .isMaxObj ()) {
3198+ end [i ] = curEnd ;
3199+ } else {
3200+ end [i ] = curEnd .getValue ();
3201+ }
31753202 }
31763203 ObBorderFlag borderFlag = rang .getBorderFlag ();
31773204 List <ObPair <Long , ObTableParam >> pairList = getTables (request .getTableName (),
@@ -3182,7 +3209,7 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
31823209 }
31833210 }
31843211
3185- // Check if partIdMapObTable size is greater than 1
3212+ // Check if partIdMapObTable size is greater than 1
31863213 if (partIdMapObTable .size () > 1 ) {
31873214 throw new ObTablePartitionConsistentException (
31883215 "query and mutate must be a atomic operation" );
@@ -3195,7 +3222,7 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
31953222 request .setTimeout (tableParam .getObTable ().getObTableOperationTimeout ());
31963223 ObTable obTable = tableParam .getObTable ();
31973224
3198- // Attempt to execute the operation
3225+ // Attempt to execute the operation
31993226 return executeWithRetry (obTable , request , request .getTableName ());
32003227 } catch (Exception ex ) {
32013228 tryTimes ++;
@@ -3212,7 +3239,7 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
32123239 tryTimes , ex );
32133240
32143241 if (ex instanceof ObTableNeedFetchAllException ) {
3215- // Refresh table info
3242+ // Refresh table info
32163243 getOrRefreshTableEntry (request .getTableName (), needRefreshTableEntry , isTableEntryRefreshIntervalWait (), true );
32173244 }
32183245 } else {
0 commit comments