@@ -815,7 +815,9 @@ private <T> T executeMutation(String tableName, MutationExecuteCallback<T> callb
815815 if (tryTimes > 1 ) {
816816 TableEntry entry = getOrRefreshTableEntry (tableName , false , false , false );
817817 Long partId = getPartition (entry , callback .getRowKey ());
818- refreshTableLocationByTabletId (entry , tableName , getTabletIdByPartId (entry , partId ));
818+ if (ObGlobal .obVsnMajor () >= 4 ) {
819+ refreshTableLocationByTabletId (entry , tableName , getTabletIdByPartId (entry , partId ));
820+ }
819821 }
820822 // using row key
821823 obPair = getTable (tableName , callback .getRowKey (), needRefreshTableEntry , tableEntryRefreshIntervalWait , false , route );
@@ -1672,8 +1674,7 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
16721674 TableEntry tableEntry = getOrRefreshTableEntry (tableName , refresh , waitForRefresh ,
16731675 needFetchAll );
16741676 Row row = new Row ();
1675- if (tableEntry .isPartitionTable ()
1676- && tableEntry .getPartitionInfo ().getLevel () != ObPartitionLevel .LEVEL_ZERO ) {
1677+ if (tableEntry .isPartitionTable ()) {
16771678 List <String > curTableRowKeyNames = new ArrayList <String >();
16781679 Map <String , Integer > tableRowKeyEle = getRowKeyElement (tableName );
16791680 if (tableRowKeyEle != null ) {
@@ -1694,7 +1695,7 @@ private ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey,
16941695 }
16951696
16961697 long partId = getPartition (tableEntry , row ); // partition id in 3.x, origin partId in 4.x, logicId
1697- if (refresh ) {
1698+ if (refresh && ObGlobal . obVsnMajor () >= 4 ) {
16981699 refreshTableLocationByTabletId (tableEntry , tableName , getTabletIdByPartId (tableEntry , partId ));
16991700 }
17001701 return getTableInternal (tableName , tableEntry , partId , waitForRefresh , route );
@@ -1929,14 +1930,20 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
19291930 ObServerRoute route ) throws Exception {
19301931 ReplicaLocation replica = null ;
19311932 long tabletId = getTabletIdByPartId (tableEntry , partId );
1933+ long partitionId = partId ;
19321934 ObPartitionLocationInfo obPartitionLocationInfo = null ;
19331935 if (ObGlobal .obVsnMajor () >= 4 ) {
19341936
19351937 obPartitionLocationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
19361938
19371939 replica = getPartitionLocation (obPartitionLocationInfo , route );
19381940 } else {
1939- ObPair <Long , ReplicaLocation > partitionReplica = getPartitionReplica (tableEntry , partId ,
1941+ if (tableEntry .isPartitionTable ()
1942+ && null != tableEntry .getPartitionInfo ().getSubPartDesc ()) {
1943+ partitionId = ObPartIdCalculator .getPartIdx (partId , tableEntry
1944+ .getPartitionInfo ().getSubPartDesc ().getPartNum ());
1945+ }
1946+ ObPair <Long , ReplicaLocation > partitionReplica = getPartitionReplica (tableEntry , partitionId ,
19401947 route );
19411948 replica = partitionReplica .getRight ();
19421949 }
@@ -1961,7 +1968,7 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
19611968 replica = getPartitionLocation (obPartitionLocationInfo , route );
19621969 } else {
19631970 tableEntry = getOrRefreshTableEntry (tableName , true , waitForRefresh , false );
1964- replica = getPartitionReplica (tableEntry , partId , route ).getRight ();
1971+ replica = getPartitionReplica (tableEntry , partitionId , route ).getRight ();
19651972 }
19661973
19671974 addr = replica .getAddr ();
@@ -1972,9 +1979,8 @@ public ObPair<Long, ObTableParam> getTableInternal(String tableName, TableEntry
19721979 throw new ObTableGetException ("Cannot get table by addr: " + addr );
19731980 }
19741981 }
1975- ObTableParam param = null ;
1982+ ObTableParam param = createTableParam ( obTable , tableEntry , obPartitionLocationInfo , partId , tabletId ) ;
19761983 if (ObGlobal .obVsnMajor () >= 4 ) {
1977- param = createTableParam (obTable , tableEntry , obPartitionLocationInfo , partId , tabletId );
19781984 } else {
19791985 param .setPartId (partId );
19801986 param .setTableId (tableEntry .getTableId ());
@@ -2047,19 +2053,36 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
20472053 List <ObPair <Long , ReplicaLocation >> replicas = new ArrayList <>();
20482054
20492055 if (!tableEntry .isPartitionTable () || tableEntry .getPartitionInfo ().getLevel () == ObPartitionLevel .LEVEL_ZERO ) {
2050- long tabletId = getTabletIdByPartId (tableEntry , 0L );
2051- ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
2052- replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
2056+ if (ObGlobal .obVsnMajor () >= 4 ) {
2057+ long tabletId = getTabletIdByPartId (tableEntry , 0L );
2058+ ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
2059+ replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
2060+ } else {
2061+ replicas .add (new ObPair <Long , ReplicaLocation >(0L , getPartitionLocation (tableEntry , 0L ,
2062+ route )));
2063+ }
20532064 return replicas ;
20542065 }
20552066
20562067 ObPartitionLevel partitionLevel = tableEntry .getPartitionInfo ().getLevel ();
20572068 List <Long > partIds = getPartitionTablePartitionIds (tableEntry , startRow , startIncluded , endRow , endIncluded , partitionLevel );
20582069
2059- for (Long partId : partIds ) {
2060- long tabletId = getTabletIdByPartId (tableEntry , partId );
2061- ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
2062- replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
2070+ if (ObGlobal .obVsnMajor () >= 4 ) {
2071+ for (Long partId : partIds ) {
2072+ long tabletId = getTabletIdByPartId (tableEntry , partId );
2073+ ObPartitionLocationInfo locationInfo = getOrRefreshPartitionInfo (tableEntry , tableName , tabletId );
2074+ replicas .add (new ObPair <>(tabletId , getPartitionLocation (locationInfo , route )));
2075+ }
2076+ } else {
2077+ for (Long partId : partIds ) {
2078+ long partitionId = partId ;
2079+ if (tableEntry .getPartitionInfo ().getLevel () == ObPartitionLevel .LEVEL_TWO ) {
2080+ partitionId = ObPartIdCalculator .getPartIdx (partId , tableEntry
2081+ .getPartitionInfo ().getSubPartDesc ().getPartNum ());
2082+ }
2083+ replicas .add (new ObPair <Long , ReplicaLocation >(partId , getPartitionLocation (
2084+ tableEntry , partitionId , route )));
2085+ }
20632086 }
20642087
20652088 return replicas ;
@@ -2182,8 +2205,7 @@ public List<ObPair<Long, ObTableParam>> getTables(String tableName, ObTableQuery
21822205 Row startRow = new Row ();
21832206 Row endRow = new Row ();
21842207 // ensure the format of column names and values if the current table is a table with partition
2185- if (tableEntry .isPartitionTable ()
2186- && tableEntry .getPartitionInfo ().getLevel () != ObPartitionLevel .LEVEL_ZERO ) {
2208+ if (tableEntry .isPartitionTable ()) {
21872209 if ((scanRangeColumns == null || scanRangeColumns .isEmpty ()) && start .length == 1
21882210 && start [0 ] instanceof ObObj && ((ObObj ) start [0 ]).isMinObj () && end .length == 1
21892211 && end [0 ] instanceof ObObj && ((ObObj ) end [0 ]).isMaxObj ()) {
@@ -3599,11 +3621,21 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
35993621 Object [] start = new Object [startKeySize ];
36003622 Object [] end = new Object [endKeySize ];
36013623 for (int i = 0 ; i < startKeySize ; i ++) {
3602- start [i ] = startKey .getObj (i ).getValue ();
3624+ ObObj curStart = startKey .getObj (i );
3625+ if (curStart .isMinObj ()) {
3626+ start [i ] = curStart ;
3627+ } else {
3628+ start [i ] = curStart .getValue ();
3629+ }
36033630 }
36043631
36053632 for (int i = 0 ; i < endKeySize ; i ++) {
3606- end [i ] = endKey .getObj (i ).getValue ();
3633+ ObObj curEnd = endKey .getObj (i );
3634+ if (curEnd .isMaxObj ()) {
3635+ end [i ] = curEnd ;
3636+ } else {
3637+ end [i ] = curEnd .getValue ();
3638+ }
36073639 }
36083640 ObBorderFlag borderFlag = rang .getBorderFlag ();
36093641 List <ObPair <Long , ObTableParam >> pairList = getTables (request .getTableName (),
0 commit comments