Skip to content

Optimization of enumerated values method#2677

Merged
davidzollo merged 10 commits intoapache:devfrom
CalvinKirs:enum
May 31, 2020
Merged

Optimization of enumerated values method#2677
davidzollo merged 10 commits intoapache:devfrom
CalvinKirs:enum

Conversation

@CalvinKirs
Copy link
Copy Markdown
Member

The values method of enum is a deep copy, it is not recommended to use the value method. Specifically see jmh results

Tips

What is the purpose of the pull request

As mentioned above,The value method of enum is a deep copy, it is not recommended to use the value method. Specifically see jmh results.

Brief change log

Optimization of enumerated values method

Verify this pull request

(Please pick either of the following options)

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

jmh test and junit test

CalvinKirs and others added 2 commits May 11, 2020 17:06
…, it is not recommended to use the value method. Specifically see jmh results
Comment on lines +75 to +85
COMMAND_TYPE_MAP.put(0, START_PROCESS);
COMMAND_TYPE_MAP.put(1, START_CURRENT_TASK_PROCESS);
COMMAND_TYPE_MAP.put(2, RECOVER_TOLERANCE_FAULT_PROCESS);
COMMAND_TYPE_MAP.put(3, RECOVER_SUSPENDED_PROCESS);
COMMAND_TYPE_MAP.put(4, START_FAILURE_TASK_PROCESS);
COMMAND_TYPE_MAP.put(5, COMPLEMENT_DATA);
COMMAND_TYPE_MAP.put(6, SCHEDULER);
COMMAND_TYPE_MAP.put(7, REPEAT_RUNNING);
COMMAND_TYPE_MAP.put(8, PAUSE);
COMMAND_TYPE_MAP.put(9, STOP);
COMMAND_TYPE_MAP.put(10, RECOVER_WAITTING_THREAD);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have better idea? I think the map key will be easy to make wrong with the enum self , actually , it write twice now, these number will be easy to wrong

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have better idea? I think the map key will be easy to make wrong with the enum self , actually , it write twice now, these number will be easy to wrong

I have completed the change, please review

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 12, 2020

Codecov Report

Merging #2677 into dev will decrease coverage by 0.22%.
The diff coverage is 44.44%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev    #2677      +/-   ##
============================================
- Coverage     37.16%   36.93%   -0.23%     
+ Complexity     2548     2535      -13     
============================================
  Files           433      433              
  Lines         19958    19967       +9     
  Branches       2423     2423              
============================================
- Hits           7417     7375      -42     
- Misses        11876    11929      +53     
+ Partials        665      663       -2     
Impacted Files Coverage Δ Complexity Δ
...g/apache/dolphinscheduler/common/enums/DbType.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...che/dolphinscheduler/common/enums/CommandType.java 80.00% <66.66%> (+7.27%) 3.00 <0.00> (+1.00)
...dolphinscheduler/common/enums/ExecutionStatus.java 61.76% <66.66%> (+6.92%) 3.00 <0.00> (+1.00)
...duler/server/entity/DataxTaskExecutionContext.java 35.00% <0.00%> (-60.00%) 7.00% <0.00%> (-6.00%)
.../server/worker/processor/TaskExecuteProcessor.java 10.00% <0.00%> (-26.67%) 1.00% <0.00%> (-2.00%)
...he/dolphinscheduler/api/service/LoggerService.java 82.60% <0.00%> (-8.70%) 9.00% <0.00%> (-1.00%)
...he/dolphinscheduler/common/thread/ThreadUtils.java 71.42% <0.00%> (-6.35%) 14.00% <0.00%> (-1.00%)
...nscheduler/server/entity/TaskExecutionContext.java 81.18% <0.00%> (-5.95%) 57.00% <0.00%> (-3.00%)
...ver/master/consumer/TaskPriorityQueueConsumer.java 54.41% <0.00%> (-4.42%) 16.00% <0.00%> (ø%)
...e/dolphinscheduler/remote/NettyRemotingClient.java 51.07% <0.00%> (-2.88%) 9.00% <0.00%> (-2.00%)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de3a81c...8aa38e0. Read the comment docs.

@CalvinKirs CalvinKirs requested a review from davidzollo May 14, 2020 05:17
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 19, 2020

Codecov Report

Merging #2677 into dev will decrease coverage by 0.06%.
The diff coverage is 44.44%.

Impacted file tree graph

@@             Coverage Diff              @@
##                dev    #2677      +/-   ##
============================================
- Coverage     37.14%   37.08%   -0.07%     
+ Complexity     2555     2551       -4     
============================================
  Files           434      434              
  Lines         20006    20015       +9     
  Branches       2426     2426              
============================================
- Hits           7432     7422      -10     
- Misses        11907    11926      +19     
  Partials        667      667              
Impacted Files Coverage Δ Complexity Δ
...g/apache/dolphinscheduler/common/enums/DbType.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...che/dolphinscheduler/common/enums/CommandType.java 80.00% <66.66%> (+7.27%) 3.00 <0.00> (+1.00)
...dolphinscheduler/common/enums/ExecutionStatus.java 61.76% <66.66%> (+6.92%) 3.00 <0.00> (+1.00)
...duler/server/entity/DataxTaskExecutionContext.java 35.00% <0.00%> (-60.00%) 7.00% <0.00%> (-6.00%)
...ver/master/consumer/TaskPriorityQueueConsumer.java 54.41% <0.00%> (-4.42%) 16.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1513aae...3698e81. Read the comment docs.

Copy link
Copy Markdown
Contributor

@davidzollo davidzollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 2 Code Smells

39.3% 39.3% Coverage
0.0% 0.0% Duplication

warning The version of Java (1.8.0_252) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more here

@davidzollo davidzollo merged commit c8ab27a into apache:dev May 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants