Skip to content

[improve][ml] Remove the redundant judgment logic of ManagedCursorImpl - #18205

Merged
codelipenghui merged 1 commit into
apache:masterfrom
Pomelongan:update_ManagedCursorImpl
Oct 27, 2022
Merged

codelipenghui merged 1 commit into
apache:masterfrom
Pomelongan:update_ManagedCursorImpl

Conversation

@Pomelongan

Copy link
Copy Markdown
Contributor

Motivation

In org.apache.bookkeeper.mledger.impl.ManagedCursorImpl, if config.isDeletionAtBatchIndexLevelEnabled() is equal to true, the field batchDeletedIndexes will not be null. see line 299,301

ManagedCursorImpl(BookKeeper bookkeeper, ManagedLedgerConfig config, ManagedLedgerImpl ledger, String cursorName) {
this.bookkeeper = bookkeeper;
this.cursorProperties = Collections.emptyMap();
this.config = config;
this.ledger = ledger;
this.name = cursorName;
this.individualDeletedMessages = new RangeSetWrapper<>(positionRangeConverter, this);
if (config.isDeletionAtBatchIndexLevelEnabled()) {
this.batchDeletedIndexes = new ConcurrentSkipListMap<>();
} else {
this.batchDeletedIndexes = null;
}

so judging config.isDeletionAtBatchIndexLevelEnabled() is equal to true can determine that batchDeletedIndexes is not null.
However, many logics judge whether batchDeletedIndexes is not null when config.isDeletionAtBatchIndexLevelEnabled() is equal to true, which is redundant. see line 569,1230

if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null
&& positionInfo.getBatchedEntryDeletionIndexInfoCount() > 0) {
recoverBatchDeletedIndexes(positionInfo.getBatchedEntryDeletionIndexInfoList());
}

if (config.isDeletionAtBatchIndexLevelEnabled() && batchDeletedIndexes != null) {
batchDeletedIndexes.values().forEach(BitSetRecyclable::recycle);
batchDeletedIndexes.clear();
long[] resetWords = newPosition.ackSet;
if (resetWords != null) {
BitSetRecyclable ackSet = BitSetRecyclable.create().resetWords(resetWords);
batchDeletedIndexes.put(newPosition, ackSet);
}
}

Modifications

When config.isDeletionAtBatchIndexLevelEnabled() is equal to true, it is no longer judged whether batchDeletedIndexes is not null.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: Pomelongan#10

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Oct 26, 2022
@AnonHxy AnonHxy changed the title [improve][broker]remove the redundant judgment logic of ManagedCursorImpl [improve][broker]Remove the redundant judgment logic of ManagedCursorImpl Oct 26, 2022
@AnonHxy

AnonHxy commented Oct 26, 2022

Copy link
Copy Markdown
Contributor

LGTM

@gaozhangmin gaozhangmin added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Oct 26, 2022
@nodece

nodece commented Oct 26, 2022 •

Copy link
Copy Markdown
Member

@Pomelongan Could you rebase the master branch to your branch?

@AnonHxy AnonHxy added this to the 2.12.0 milestone Oct 26, 2022
@Pomelongan
Pomelongan force-pushed the update_ManagedCursorImpl branch from 70b35e9 to 8952a5c Compare October 26, 2022 11:38
@Pomelongan Pomelongan closed this Oct 26, 2022
@Pomelongan Pomelongan reopened this Oct 26, 2022
@Pomelongan

Copy link
Copy Markdown
Contributor Author

@Pomelongan Could you rebase the master branch to your branch?

I have updated.PTAL @nodece

@codecov-commenter

codecov-commenter commented Oct 26, 2022 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.52%. Comparing base (6c65ca0) to head (8952a5c).
⚠️ Report is 3526 commits behind head on master.

Files with missing lines Patch % Lines
...che/bookkeeper/mledger/impl/ManagedCursorImpl.java 0.00% 0 Missing and 9 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18205      +/-   ##
============================================
+ Coverage     34.91%   38.52%   +3.61%     
- Complexity     5707    14357    +8650     
============================================
  Files           607     1579     +972     
  Lines         53396   128708   +75312     
  Branches       5712    14150    +8438     
============================================
+ Hits          18644    49589   +30945     
- Misses        32119    73536   +41417     
- Partials       2633     5583    +2950     
Flag Coverage Δ
unittests 38.52% <0.00%> (+3.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...che/bookkeeper/mledger/impl/ManagedCursorImpl.java 73.58% <0.00%> (ø)

... and 1119 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AnonHxy AnonHxy changed the title [improve][broker]Remove the redundant judgment logic of ManagedCursorImpl [improve][ml]Remove the redundant judgment logic of ManagedCursorImpl Oct 27, 2022
@codelipenghui codelipenghui changed the title [improve][ml]Remove the redundant judgment logic of ManagedCursorImpl [improve][ml] Remove the redundant judgment logic of ManagedCursorImpl Oct 27, 2022

@Jason918 Jason918 left a comment

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.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.11 doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants