@@ -700,7 +700,7 @@ private <T> T executeMutation(String tableName, MutationExecuteCallback<T> callb
700700 tableEntryRefreshIntervalWait , route );
701701 } else if (null != callback .getKeyRanges ()) {
702702 // using scan range
703- obPair = getTable (tableName , callback .getKeyRanges (),
703+ obPair = getTable (tableName , new ObTableQuery (), callback .getKeyRanges (),
704704 needRefreshTableEntry , tableEntryRefreshIntervalWait , route );
705705 } else {
706706 throw new ObTableException ("rowkey and scan range are null in mutation" );
@@ -1359,18 +1359,18 @@ private long getPartition(TableEntry tableEntry, Object[] rowKey) {
13591359 /*
13601360 * Get logicId(partition id in 3.x) from giving range
13611361 */
1362- private List <Long > getPartitionsForLevelTwo (TableEntry tableEntry , Object [] start ,
1363- boolean startIncluded , Object [] end ,
1364- boolean endIncluded ) throws Exception {
1362+ private List <Long > getPartitionsForLevelTwo (TableEntry tableEntry , List < String > scanRangeColumns ,
1363+ Object [] start , boolean startIncluded ,
1364+ Object [] end , boolean endIncluded ) throws Exception {
13651365 if (tableEntry .getPartitionInfo ().getLevel () != ObPartitionLevel .LEVEL_TWO ) {
13661366 RUNTIME .error ("getPartitionsForLevelTwo need ObPartitionLevel LEVEL_TWO" );
13671367 throw new Exception ("getPartitionsForLevelTwo need ObPartitionLevel LEVEL_TWO" );
13681368 }
13691369
13701370 List <Long > partIds1 = tableEntry .getPartitionInfo ().getFirstPartDesc ()
1371- .getPartIds (start , startIncluded , end , endIncluded );
1371+ .getPartIds (scanRangeColumns , start , startIncluded , end , endIncluded );
13721372 List <Long > partIds2 = tableEntry .getPartitionInfo ().getSubPartDesc ()
1373- .getPartIds (start , startIncluded , end , endIncluded );
1373+ .getPartIds (scanRangeColumns , start , startIncluded , end , endIncluded );
13741374
13751375 List <Long > partIds = new ArrayList <Long >();
13761376 if (partIds1 .isEmpty ()) {
@@ -1478,7 +1478,7 @@ public ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey, bo
14781478 * @return ObPair of partId and table
14791479 * @throws Exception exception
14801480 */
1481- public ObPair <Long , ObTableParam > getTable (String tableName , List <ObNewRange > keyRanges , boolean refresh ,
1481+ public ObPair <Long , ObTableParam > getTable (String tableName , ObTableQuery query , List <ObNewRange > keyRanges , boolean refresh ,
14821482 boolean waitForRefresh , ObServerRoute route )
14831483 throws Exception {
14841484 Map <Long , ObTableParam > partIdMapObTable = new HashMap <Long , ObTableParam >();
@@ -1497,7 +1497,7 @@ public ObPair<Long, ObTableParam> getTable(String tableName, List<ObNewRange> ke
14971497 end [i ] = endKey .getObj (i ).getValue ();
14981498 }
14991499 ObBorderFlag borderFlag = rang .getBorderFlag ();
1500- List <ObPair <Long , ObTableParam >> pairList = getTables (tableName , start ,
1500+ List <ObPair <Long , ObTableParam >> pairList = getTables (tableName , query , start ,
15011501 borderFlag .isInclusiveStart (), end , borderFlag .isInclusiveEnd (), false ,
15021502 false );
15031503 for (ObPair <Long , ObTableParam > pair : pairList ) {
@@ -1605,6 +1605,7 @@ public ObPair<Long, ObTableParam> getTable(String tableName, TableEntry tableEnt
16051605 * @throws Exception
16061606 */
16071607 private List <ObPair <Long , ReplicaLocation >> getPartitionReplica (TableEntry tableEntry ,
1608+ List <String > scanRangeColumns ,
16081609 Object [] start ,
16091610 boolean startIncluded ,
16101611 Object [] end ,
@@ -1620,13 +1621,13 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
16201621 return replicas ;
16211622 } else if (tableEntry .getPartitionInfo ().getLevel () == ObPartitionLevel .LEVEL_ONE ) {
16221623 List <Long > partIds = tableEntry .getPartitionInfo ().getFirstPartDesc ()
1623- .getPartIds (start , startIncluded , end , endIncluded );
1624+ .getPartIds (scanRangeColumns , start , startIncluded , end , endIncluded );
16241625 for (Long partId : partIds ) {
16251626 replicas .add (new ObPair <Long , ReplicaLocation >(partId , getPartitionLocation (
16261627 tableEntry , partId , route )));
16271628 }
16281629 } else if (tableEntry .getPartitionInfo ().getLevel () == ObPartitionLevel .LEVEL_TWO ) {
1629- List <Long > partIds = getPartitionsForLevelTwo (tableEntry , start , startIncluded , end ,
1630+ List <Long > partIds = getPartitionsForLevelTwo (tableEntry , scanRangeColumns , start , startIncluded , end ,
16301631 endIncluded );
16311632 for (Long partId : partIds ) {
16321633 replicas .add (new ObPair <Long , ReplicaLocation >(partId , getPartitionLocation (
@@ -1652,11 +1653,11 @@ private List<ObPair<Long, ReplicaLocation>> getPartitionReplica(TableEntry table
16521653 * @return list of ObPair of partId(logicId) and table obTableParams
16531654 * @throws Exception exception
16541655 */
1655- public List <ObPair <Long , ObTableParam >> getTables (String tableName , Object [] start ,
1656+ public List <ObPair <Long , ObTableParam >> getTables (String tableName , ObTableQuery query , Object [] start ,
16561657 boolean startInclusive , Object [] end ,
16571658 boolean endInclusive , boolean refresh ,
16581659 boolean waitForRefresh ) throws Exception {
1659- return getTables (tableName , start , startInclusive , end , endInclusive , refresh ,
1660+ return getTables (tableName , query , start , startInclusive , end , endInclusive , refresh ,
16601661 waitForRefresh , getRoute (false ));
16611662 }
16621663
@@ -1673,18 +1674,27 @@ public List<ObPair<Long, ObTableParam>> getTables(String tableName, Object[] sta
16731674 * @return list of ObPair of partId(logicId) and tableParam
16741675 * @throws Exception exception
16751676 */
1676- public List <ObPair <Long , ObTableParam >> getTables (String tableName , Object [] start ,
1677+ public List <ObPair <Long , ObTableParam >> getTables (String tableName , ObTableQuery query , Object [] start ,
16771678 boolean startInclusive , Object [] end ,
16781679 boolean endInclusive , boolean refresh ,
16791680 boolean waitForRefresh , ObServerRoute route )
16801681 throws Exception {
16811682
16821683 // 1. get TableEntry information
16831684 TableEntry tableEntry = getOrRefreshTableEntry (tableName , refresh , waitForRefresh );
1685+
1686+ List <String > scanRangeColumns = query .getScanRangeColumns ();
1687+ if (scanRangeColumns == null || scanRangeColumns .size () == 0 ) {
1688+ Map <String , Integer > tableRowKeyElement = tableEntry .getRowKeyElement ();
1689+ if (tableRowKeyElement != null ) {
1690+ scanRangeColumns = new ArrayList <>(tableRowKeyElement .keySet ());
1691+ }
1692+ }
1693+
16841694 // 2. get replica location
16851695 // partIdWithReplicaList -> List<pair<logicId(partition id in 3.x), replica>>
16861696 List <ObPair <Long , ReplicaLocation >> partIdWithReplicaList = getPartitionReplica (tableEntry ,
1687- start , startInclusive , end , endInclusive , route );
1697+ scanRangeColumns , start , startInclusive , end , endInclusive , route );
16881698
16891699 // obTableParams -> List<Pair<logicId, obTableParams>>
16901700 List <ObPair <Long , ObTableParam >> obTableParams = new ArrayList <ObPair <Long , ObTableParam >>();
@@ -2774,7 +2784,7 @@ public ObPayload execute(final ObTableAbstractOperationRequest request) throws E
27742784 end [i ] = endKey .getObj (i ).getValue ();
27752785 }
27762786 ObBorderFlag borderFlag = rang .getBorderFlag ();
2777- List <ObPair <Long , ObTableParam >> pairList = getTables (request .getTableName (),
2787+ List <ObPair <Long , ObTableParam >> pairList = getTables (request .getTableName (), tableQuery ,
27782788 start , borderFlag .isInclusiveStart (), end , borderFlag .isInclusiveEnd (),
27792789 false , false );
27802790 for (ObPair <Long , ObTableParam > pair : pairList ) {
@@ -3150,7 +3160,7 @@ public void addRowKeyElement(String tableName, String[] columns) {
31503160 if (tableName == null || tableName .length () == 0 ) {
31513161 throw new IllegalArgumentException ("table name is null" );
31523162 }
3153- Map <String , Integer > rowKeyElement = new HashMap < String , Integer >();
3163+ Map <String , Integer > rowKeyElement = new LinkedHashMap < >();
31543164 for (int i = 0 ; i < columns .length ; i ++) {
31553165 rowKeyElement .put (columns [i ], i );
31563166 }
0 commit comments