Skip to content

Commit

Permalink
Get partitions by batch of size 5k per RPC
Browse files Browse the repository at this point in the history
Signed-off-by: Letian Jiang <[email protected]>
  • Loading branch information
letian-jiang committed Mar 9, 2023
1 parent ee640ef commit 73be4ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fe/fe-core/src/main/java/com/starrocks/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ public class Config extends ConfigBase {
* The maximum number of partitions to fetch from the metastore in one RPC.
*/
@ConfField
public static int max_hive_partitions_per_rpc = 1000;
public static int max_hive_partitions_per_rpc = 5000;

/**
* The interval of lazy refreshing remote file's metadata cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.thrift.transport.TTransportException;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -219,7 +220,7 @@ public Partition getPartition(String dbName, String tableName, List<String> part
*/
public List<Partition> getPartitionsByNames(String dbName, String tblName, List<String> partitionNames) {
int size = partitionNames.size();
List<Partition> partitions;
List<Partition> partitions = new ArrayList<>();
PlannerProfile.addCustomProperties("HMS.PARTITIONS.getPartitionsByNames." + tblName,
String.format("%s partitions", size));

Expand All @@ -228,7 +229,12 @@ public List<Partition> getPartitionsByNames(String dbName, String tblName, List<
StarRocksConnectorException connectionException = null;
try {
client = getClient();
partitions = client.hiveClient.getPartitionsByNames(dbName, tblName, partitionNames);
for (int start = 0; start < partitionNames.size(); start += Config.max_hive_partitions_per_rpc) {
int end = Math.min(start + Config.max_hive_partitions_per_rpc, partitionNames.size());
List<String> namesPerRPC = partitionNames.subList(start, end);
List<Partition> partsPerRPC = client.hiveClient.getPartitionsByNames(dbName, tblName, namesPerRPC);
partitions.addAll(partsPerRPC);
}
if (partitions.size() != partitionNames.size()) {
LOG.warn("Expect to fetch {} partition on [{}.{}], but actually fetched {} partition",
partitionNames.size(), dbName, tblName, partitions.size());
Expand Down

0 comments on commit 73be4ec

Please sign in to comment.