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


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/Msck.java:
##########
@@ -240,6 +246,76 @@ 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 = new ArrayList<>(partsNotInMs.size());
+          for (CheckResult.PartitionResult pr : partsNotInMs) {
+            final String name = pr.getPartitionName();
+            if (name != null && !name.isEmpty()) {
+              names.add(name);
+            }
+          }
+
+          // Batch over the names to limit single-RPC payload.
+          final int BATCH = 1000;
+          final Map<String, Partition> byName = new HashMap<>(names.size() * 
2);
+
+          for (int i = 0; i < names.size(); i += BATCH) {
+            final List<String> batch = names.subList(i, Math.min(i + BATCH, 
names.size()));
+            final GetPartitionsByNamesRequest req = new 
GetPartitionsByNamesRequest(table.getDbName(), table.getTableName());
+            req.setNames(batch);
+
+            // In this branch, getPartitionsByNames returns List<Partition>
+            List<Partition> plist;
+            try {
+              @SuppressWarnings("unchecked")
+              List<Partition> tmp = (List<Partition>) 
getMsc().getPartitionsByNames(req);
+              plist = (tmp != null) ? tmp : Collections.emptyList();
+            } catch (NoSuchObjectException e) {
+              plist = Collections.emptyList();
+            }
+
+            for (Partition p : plist) {
+              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) {

Review Comment:
   They are pretty much the same. 
   We need to do `smallFilesStats.put(pName, "avgBytes=" + avg + ", partition 
total files=" + numFiles + ", totalBytes=" + totalSize);` later, so it's easier 
to use pName to iterate.



-- 
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