EmmyMiao87 commented on a change in pull request #1154: Add logic of cancel job
URL: https://github.com/apache/incubator-doris/pull/1154#discussion_r283668614
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
 ##########
 @@ -113,10 +114,11 @@ public void cancelLoadJob(CancelLoadStmt stmt) throws 
DdlException {
             if (!dbIdToLabelToLoadJobs.containsKey(db.getId())) {
                 throw new DdlException("Load job does not exist");
             }
-            if 
(!dbIdToLabelToLoadJobs.get(db.getId()).containsKey(stmt.getLabel())) {
+            Map<String, List<LoadJob>> labelToLoadJobs = 
dbIdToLabelToLoadJobs.get(db.getId());
+            if (!labelToLoadJobs.containsKey(stmt.getLabel())) {
                 throw new DdlException("Load job does not exist");
             }
-            List<LoadJob> loadJobList = 
dbIdToLabelToLoadJobs.get(db.getId()).get(stmt.getLabel());
+            List<LoadJob> loadJobList = labelToLoadJobs.get(stmt.getLabel());
 
 Review comment:
   Yes, you are right. If I only check the key, the containsKey is better. If I 
need to check and get in concurrent situation, the get and check null is better.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@doris.apache.org
For additional commands, e-mail: dev-h...@doris.apache.org

Reply via email to