Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #5415]fix duplicate records #5416

Merged
merged 2 commits into from
Oct 31, 2022

Conversation

RapperCL
Copy link
Contributor

@RapperCL RapperCL commented Oct 28, 2022

@RapperCL RapperCL changed the title fix duplicate records [ISSUE #5415]fix duplicate records Oct 28, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #5416 (c51b99f) into develop (4ba8aa2) will decrease coverage by 0.03%.
The diff coverage is 0.00%.

@@              Coverage Diff              @@
##             develop    #5416      +/-   ##
=============================================
- Coverage      43.17%   43.13%   -0.04%     
+ Complexity      8046     8038       -8     
=============================================
  Files           1020     1020              
  Lines          71892    71887       -5     
  Branches        9519     9519              
=============================================
- Hits           31039    31011      -28     
- Misses         36946    36960      +14     
- Partials        3907     3916       +9     
Impacted Files Coverage Δ
.../transaction/queue/TransactionalMessageBridge.java 72.06% <0.00%> (-0.22%) ⬇️
...apache/rocketmq/broker/longpolling/PopRequest.java 31.03% <0.00%> (-13.80%) ⬇️
...org/apache/rocketmq/common/stats/StatsItemSet.java 41.79% <0.00%> (-8.96%) ⬇️
.../org/apache/rocketmq/store/ha/DefaultHAClient.java 58.97% <0.00%> (-2.57%) ⬇️
...a/org/apache/rocketmq/filter/util/BloomFilter.java 60.43% <0.00%> (-2.20%) ⬇️
...he/rocketmq/client/trace/AsyncTraceDispatcher.java 82.21% <0.00%> (-1.45%) ⬇️
...ache/rocketmq/broker/client/ConsumerGroupInfo.java 68.46% <0.00%> (-0.91%) ⬇️
...ava/org/apache/rocketmq/store/index/IndexFile.java 73.68% <0.00%> (-0.88%) ⬇️
...ent/impl/consumer/DefaultLitePullConsumerImpl.java 68.38% <0.00%> (-0.47%) ⬇️
...main/java/org/apache/rocketmq/store/CommitLog.java 65.28% <0.00%> (-0.21%) ⬇️
... and 7 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link

@sunheyi6 sunheyi6 left a comment

Choose a reason for hiding this comment

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

if ((opQueue = opQueueMap.get(queueId)) == null) {
You write this way although it looks cleaner, but it is not easy to read the code

Comment on lines 305 to 306
MessageQueue opQueue;
if (opQueueMap.containsKey(queueId)) {
opQueue = opQueueMap.get(queueId);
} else {
if ((opQueue = opQueueMap.get(queueId)) == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Assigning opQueue at first may be better than initializing it in if condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I think this can reduce one query, although the time complexity is only O(1) and I don't think it's a good practice to judge first and then get it. If the opQueueMap has a removal operation, there will be problems.

@RapperCL RapperCL requested review from sunheyi6 and caigy and removed request for sunheyi6 and caigy October 29, 2022 09:57
@RongtongJin RongtongJin merged commit 6af6fed into apache:develop Oct 31, 2022
drpmma pushed a commit that referenced this pull request Feb 21, 2023
* fix duplicate records

* code update
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.

None yet

5 participants