@@ -1509,11 +1509,13 @@ public ObPair<Long, ObTableParam> getTable(String tableName, Object[] rowKey, bo
15091509 *
15101510 * @param tableName table want to get
15111511 * @param rowKey row key values
1512+ * @param needRenew flag to re-fetch partition meta information
15121513 * @return ODP ObPair of partId and table
15131514 * @throws Exception exception
15141515 */
1515- public ObPair <Long , ObTableParam > getODPTableWithRowKeyValue (String tableName , Object [] rowKey , boolean needRenew )
1516- throws Exception {
1516+ public ObPair <Long , ObTableParam > getODPTableWithRowKeyValue (String tableName , Object [] rowKey ,
1517+ boolean needRenew )
1518+ throws Exception {
15171519 TableEntry odpTableEntry = getOrFetchODPPartitionMeta (tableName , needRenew );
15181520 Row row = new Row ();
15191521 if (odpTableEntry .isPartitionTable ()
@@ -1543,6 +1545,7 @@ public ObPair<Long, ObTableParam> getODPTableWithRowKeyValue(String tableName, O
15431545 /**
15441546 * For mutation (queryWithFilter)
15451547 * @param tableName table want to get
1548+ * @param query query
15461549 * @param keyRanges key
15471550 * @param refresh whether to refresh
15481551 * @param waitForRefresh whether wait for refresh
@@ -1644,6 +1647,7 @@ private ObPair<Long, ObTableParam> getODPTableWithRowKey(String tableName, Row r
16441647 * @param partId partId of table (logicId, partition id in 3.x)
16451648 * @param refresh whether to refresh
16461649 * @param waitForRefresh whether wait for refresh
1650+ * @param needFetchAll flag to fetch all
16471651 * @param route ObServer route
16481652 * @return ObPair of partId and table
16491653 * @throws Exception exception
@@ -1823,6 +1827,7 @@ private List<Long> getOdpPartIds(TableEntry odpTableEntry, Row startRow, boolean
18231827 /**
18241828 * 根据 start-end 获取 partition ids 和 addrs
18251829 * @param tableName table want to get
1830+ * @param query query
18261831 * @param start start key
18271832 * @param startInclusive whether include start key
18281833 * @param end end key
@@ -1844,6 +1849,7 @@ public List<ObPair<Long, ObTableParam>> getTables(String tableName, ObTableQuery
18441849 /**
18451850 * 根据 start-end 获取 partition id 和 addr
18461851 * @param tableName table want to get
1852+ * @param query query
18471853 * @param start start key
18481854 * @param startInclusive whether include start key
18491855 * @param end end key
@@ -1972,40 +1978,40 @@ private List<ObPair<Long, ObTableParam>> getODPTables(String tableName, ObTableQ
19721978 if (odpTableEntry .isPartitionTable ()
19731979 && odpTableEntry .getPartitionInfo ().getLevel () != ObPartitionLevel .LEVEL_ZERO ) {
19741980 if ((scanRangeColumns == null || scanRangeColumns .isEmpty ()) && start .length == 1
1975- && start [0 ] instanceof ObObj && ((ObObj ) start [0 ]).isMinObj () && end .length == 1
1976- && end [0 ] instanceof ObObj && ((ObObj ) end [0 ]).isMaxObj ()) {
1981+ && start [0 ] instanceof ObObj && ((ObObj ) start [0 ]).isMinObj () && end .length == 1
1982+ && end [0 ] instanceof ObObj && ((ObObj ) end [0 ]).isMaxObj ()) {
19771983 // for getPartition to query all partitions
19781984 scanRangeColumns = new ArrayList <String >(Collections .nCopies (start .length ,
1979- "partition" ));
1985+ "partition" ));
19801986 }
19811987 // scanRangeColumn may be longer than start/end in prefix scanning situation
19821988 if (scanRangeColumns == null || scanRangeColumns .size () < start .length ) {
19831989 throw new IllegalArgumentException (
1984- "length of key and scan range columns do not match, please use addRowKeyElement or set scan range columns" );
1990+ "length of key and scan range columns do not match, please use addRowKeyElement or set scan range columns" );
19851991 }
19861992 for (int i = 0 ; i < start .length ; i ++) {
19871993 startRow .add (scanRangeColumns .get (i ), start [i ]);
19881994 endRow .add (scanRangeColumns .get (i ), end [i ]);
19891995 }
19901996 }
19911997
1992- List <Long > partIds = getOdpPartIds (odpTableEntry , startRow , startInclusive , endRow ,
1993- endInclusive );
1994- for (Long partId : partIds ) {
1995- ObTable obTable = odpTable ;
1996- ObTableParam param = new ObTableParam (obTable );
1997- Long tabletId = partId ;
1998- if (ObGlobal .obVsnMajor () >= 4 ) {
1999- long partIdx = odpTableEntry .getPartIdx (partId );
2000- tabletId = odpTableEntry .isPartitionTable () ? odpTableEntry .getPartitionInfo ()
2001- .getPartTabletIdMap ().get (partIdx ) : partId ;
2002- param .setLsId (odpTableEntry .getPartitionEntry ().getLsId (tabletId ));
2003- }
2004- param .setTableId (odpTableEntry .getTableId ());
2005- // real partition(tablet) id
2006- param .setPartitionId (tabletId );
2007- obTableParams .add (new ObPair <Long , ObTableParam >(partId , param ));
1998+ List <Long > partIds = getOdpPartIds (odpTableEntry , startRow , startInclusive , endRow ,
1999+ endInclusive );
2000+ for (Long partId : partIds ) {
2001+ ObTable obTable = odpTable ;
2002+ ObTableParam param = new ObTableParam (obTable );
2003+ Long tabletId = partId ;
2004+ if (ObGlobal .obVsnMajor () >= 4 ) {
2005+ long partIdx = odpTableEntry .getPartIdx (partId );
2006+ tabletId = odpTableEntry .isPartitionTable () ? odpTableEntry .getPartitionInfo ()
2007+ .getPartTabletIdMap ().get (partIdx ) : partId ;
2008+ param .setLsId (odpTableEntry .getPartitionEntry ().getLsId (tabletId ));
20082009 }
2010+ param .setTableId (odpTableEntry .getTableId ());
2011+ // real partition(tablet) id
2012+ param .setPartitionId (tabletId );
2013+ obTableParams .add (new ObPair <Long , ObTableParam >(partId , param ));
2014+ }
20092015
20102016 return obTableParams ;
20112017 }
@@ -2809,8 +2815,7 @@ public BatchOperation batchOperation(String tableName) {
28092815 */
28102816 public Partition getPartition (String tableName , Object [] rowKey ) throws Exception {
28112817 if (rowKey == null ) {
2812- throw new Exception (
2813- "The input row key value can not be empty" );
2818+ throw new Exception ("The input row key value can not be empty" );
28142819 }
28152820 Map <String , Integer > rowKeyElements = getRowKeyElement (tableName );
28162821 if (rowKeyElements == null ) {
@@ -2862,7 +2867,7 @@ private Partition getSinglePartitionInternal(String tableName, Row rowKey) throw
28622867 /**
28632868 * get all partition information from table
28642869 * @param tableName table name to query
2865- * @return List<Partition> partitions
2870+ * @return partitions
28662871 * @throws Exception Exception
28672872 */
28682873 public List <Partition > getPartition (String tableName ) throws Exception {
@@ -2955,8 +2960,8 @@ private TableEntry getOrFetchODPPartitionMeta(String tableName, boolean needRene
29552960 do {
29562961 try {
29572962 ObFetchPartitionMetaRequest request = ObFetchPartitionMetaRequest .getInstance (
2958- ObFetchPartitionMetaType .GET_PARTITION_META .getIndex (),
2959- tableName , clusterName , tenantName , database , forceRenew ,
2963+ ObFetchPartitionMetaType .GET_PARTITION_META .getIndex (), tableName ,
2964+ clusterName , tenantName , database , forceRenew ,
29602965 odpTable .getObTableOperationTimeout ()); // TODO: timeout setting need to be verified
29612966 ObPayload result = odpTable .execute (request );
29622967 checkObFetchPartitionMetaResult (lastOdpRefreshTimeMills , request , result );
@@ -2983,7 +2988,8 @@ private TableEntry getOrFetchODPPartitionMeta(String tableName, boolean needRene
29832988 }
29842989 }
29852990
2986- private void checkObFetchPartitionMetaResult (Long lastOdpRefreshTimeMills , ObFetchPartitionMetaRequest request ,
2991+ private void checkObFetchPartitionMetaResult (Long lastOdpRefreshTimeMills ,
2992+ ObFetchPartitionMetaRequest request ,
29872993 ObPayload result ) {
29882994 if (result == null ) {
29892995 RUNTIME .error ("client get unexpected NULL result" );
@@ -3002,7 +3008,6 @@ private void checkObFetchPartitionMetaResult(Long lastOdpRefreshTimeMills, ObFet
30023008 }
30033009 }
30043010
3005-
30063011 }
30073012
30083013 /**
0 commit comments