@@ -1839,14 +1839,20 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
18391839 ObServerRoute route ) throws Exception {
18401840 ReplicaLocation replica = null ;
18411841 long tabletId = getTabletIdByPartId (tableEntry , partId );
1842+ long partitionId = partId ;
18421843 ObPartitionLocationInfo obPartitionLocationInfo = null ;
18431844 if (ObGlobal .obVsnMajor () >= 4 ) {
18441845
18451846 obPartitionLocationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
18461847
18471848 replica = getPartitionLocation (obPartitionLocationInfo , route );
18481849 } else {
1849- ObPair <Long , ReplicaLocation > partitionReplica = getPartitionReplica (tableEntry , partId ,
1850+ if (tableEntry .isPartitionTable ()
1851+ && null != tableEntry .getPartitionInfo ().getSubPartDesc ()) {
1852+ partitionId = ObPartIdCalculator .getPartIdx (partId , tableEntry
1853+ .getPartitionInfo ().getSubPartDesc ().getPartNum ());
1854+ }
1855+ ObPair <Long , ReplicaLocation > partitionReplica = getPartitionReplica (tableEntry , partitionId ,
18501856 route );
18511857 replica = partitionReplica .getRight ();
18521858 }
@@ -1871,7 +1877,7 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
18711877 replica = getPartitionLocation (obPartitionLocationInfo , route );
18721878 } else {
18731879 tableEntry = getOrRefreshTableEntry (tableName , true , waitForRefresh , false );
1874- replica = getPartitionReplica (tableEntry , partId , route ).getRight ();
1880+ replica = getPartitionReplica (tableEntry , partitionId , route ).getRight ();
18751881 }
18761882
18771883 addr = replica .getAddr ();
@@ -1882,9 +1888,8 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
18821888 throw new ObTableGetException ("Cannot get table by addr: " + addr );
18831889 }
18841890 }
1885- ObTableParam param = null ;
1891+ ObTableParam param = createTableParam ( obTable , tableEntry , obPartitionLocationInfo , partId , tabletId ) ;
18861892 if (ObGlobal .obVsnMajor () >= 4 ) {
1887- param = createTableParam (obTable , tableEntry , obPartitionLocationInfo , partId , tabletId );
18881893 } else {
18891894 param .setPartId (partId );
18901895 param .setTableId (tableEntry .getTableId ());
@@ -1900,7 +1905,9 @@ private ObPartitionLocationInfo getOrRefreshPartitionInfo(TableEntry tableEntry,
19001905 ObPartitionLocationInfo obPartitionLocationInfo = tableEntry .getPartitionEntry ()
19011906 .getPartitionInfo (tabletId );
19021907 if (!obPartitionLocationInfo .initialized .get ()) {
1903- tableEntry = refreshTableLocationByTabletId (tableEntry , tableName , tabletId );
1908+ if (ObGlobal .obVsnMajor () >= 4 ) {
1909+ tableEntry = refreshTableLocationByTabletId (tableEntry , tableName , tabletId );
1910+ }
19041911 obPartitionLocationInfo = tableEntry .getPartitionEntry ().getPartitionInfo (tabletId );
19051912 obPartitionLocationInfo .initializationLatch .await ();
19061913 }
@@ -1950,10 +1957,19 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
19501957 ObPartitionLevel partitionLevel = tableEntry .getPartitionInfo ().getLevel ();
19511958 List <Long > partIds = getPartitionTablePartitionIds (tableEntry , startRow , startIncluded , endRow , endIncluded , partitionLevel );
19521959
1953- for (Long partId : partIds ) {
1954- long tabletId = getTabletIdByPartId (tableEntry , partId );
1955- ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
1956- replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
1960+ if (ObGlobal .obVsnMajor () >= 4 ) {
1961+ for (Long partId : partIds ) {
1962+ long tabletId = getTabletIdByPartId (tableEntry , partId );
1963+ ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
1964+ replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
1965+ }
1966+ } else {
1967+ for (Long partId : partIds ) {
1968+ long partitionId = ObPartIdCalculator .getPartIdx (partId , tableEntry
1969+ .getPartitionInfo ().getSubPartDesc ().getPartNum ());
1970+ replicas .add (new ObPair <Long , ReplicaLocation >(partId , getPartitionLocation (
1971+ tableEntry , partitionId , route )));
1972+ }
19571973 }
19581974
19591975 return replicas ;
0 commit comments