imay commented on a change in pull request #1154: Add logic of cancel job
URL: https://github.com/apache/incubator-doris/pull/1154#discussion_r283659159
##########
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:
Hash the key is the first operation, `containsKey` will also check if two
keys are equal, because hash of two keys may equal. And these operation's cost
is less than a `get` operation.
Yes, in this case you add a readLock. But what I want to say is that it is
good habit to check get's value
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]