DanielZhu58 commented on code in PR #5950:
URL: https://github.com/apache/hive/pull/5950#discussion_r2443868205


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/Msck.java:
##########
@@ -240,6 +248,74 @@ public int repair(MsckInfo msckInfo) throws TException, 
MetastoreException, IOEx
           }
         }
 
+        // Generate small files warnings only for partsNotInMs
+        try {
+          // Threshold in bytes for average file size considered "small"
+          final long threshold =
+                  MetastoreConf.getLongVar(getConf(), 
MetastoreConf.ConfVars.MSCK_SMALLFILES_AVG_SIZE);
+
+          // Collect partition names
+          final List<String> names = partsNotInMs.stream()
+                  .map(CheckResult.PartitionResult::getPartitionName)
+                  .filter(Objects::nonNull)
+                  .filter(s -> !s.isEmpty())
+                  .collect(Collectors.toList());
+
+          // Batch over the names to limit single-RPC payload.
+          final int PART_FETCH_BATCH = 1000;
+          final Map<String, Partition> byName = new HashMap<>(names.size() * 
2);
+          List<Partition> allParts = Batchable.runBatched(
+            PART_FETCH_BATCH,
+            names,
+            new Batchable<String, Partition>() {
+              @Override
+              public List<Partition> run(List<String> batch) throws Exception {
+                final GetPartitionsByNamesRequest req =
+                    new GetPartitionsByNamesRequest(table.getDbName(), 
table.getTableName());
+                req.setNames(batch);
+                try {
+                  @SuppressWarnings("unchecked")
+                  List<Partition> plist = (List<Partition>) 
getMsc().getPartitionsByNames(req);
+                  return (plist != null) ? plist : Collections.emptyList();
+                } catch (NoSuchObjectException e) {
+                  return Collections.emptyList();
+                }
+              }
+            });
+
+          for (Partition p : allParts) {
+            final String pName = 
Warehouse.makePartName(table.getPartitionKeys(), p.getValues());
+            byName.put(pName, p);
+          }
+
+          // Build small-files stats for partitions that have quick HMS stats.
+          final Map<String, String> smallFilesStats = new TreeMap<>();
+
+          for (String pName : names) {
+            final Partition p = byName.get(pName);
+            if (p == null) {

Review Comment:
   Acknowledged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to