deniskuzZ commented on code in PR #3712:
URL: https://github.com/apache/hive/pull/3712#discussion_r1019978889


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/storage/compact/AlterTableCompactOperation.java:
##########
@@ -126,16 +126,11 @@ private void waitForCompactionToFinish(CompactionResponse 
resp) throws HiveExcep
         context.getConsole().printInfo("Interrupted while waiting for 
compaction with id=" + resp.getId());
         break;
       }
-
-      //this could be expensive when there are a lot of compactions....
-      //todo: update to search by ID once HIVE-13353 is done
-      ShowCompactResponse allCompactions = context.getDb().showCompactions();
-      for (ShowCompactResponseElement compaction : 
allCompactions.getCompacts()) {
-        if (resp.getId() != compaction.getId()) {
-          continue;
-        }
-
-        switch (compaction.getState()) {
+      ShowCompactRequest request = new ShowCompactRequest();
+      request.setId(resp.getId());
+      ShowCompactResponse compaction = 
context.getDb().showCompactions(request);
+      if (compaction.getCompactsSize() == 1) {
+        switch (compaction.getCompacts().get(0).getState()) {

Review Comment:
   please create a local var for `compaction.getCompacts().get(0)`



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