Skip to content

Refactor aligned printer #605

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ariraein
Copy link

Issue number of the reported bug or feature request: #

Describe your changes
A clear and concise description of the changes you have made.

Testing performed
Describe the testing you have performed to ensure that the bug has been addressed, or that the new feature works as planned.

Additional context
Add any other context about your contribution here.

@ariraein ariraein requested a review from a team as a code owner February 11, 2025 02:42
Copy link
Collaborator

@678098 678098 left a comment

Choose a reason for hiding this comment

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

  1. Added a review notes
  2. CI DCO check fails for the second commit in the PR. All commits need to be DCO-signed to pass this. The instructions how it can be simply fixed are here: https://github.com/bloomberg/blazingmq/blob/main/CONTRIBUTING.md#dco-check
  3. CI formatter check fails, need to run clang-format on source files before commiting, or alternatively you can use CI output to make fixes: https://github.com/bloomberg/blazingmq/actions/runs/13254786590/job/37026607247?pr=605
  4. Build fails, might be related to review notes

.gitignore Outdated
docker/sanitizers/
lib64/
src/groups/mqb/mqbc/mqbc_clusterutil.t.cpp
src/groups/mqb/mqbc/mqbc_clusterutil.t.cpp
Copy link
Collaborator

Choose a reason for hiding this comment

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

Among these newly added items:

  1. Some are not expected in a normal workflow:
.bash_history
.bde_tools/
lib64/
  1. Some are legit project-related files or folders and there is no reason to ignore them:
docker/sanitizers/
src/groups/mqb/mqbc/mqbc_clusterutil.t.cpp
src/groups/mqb/mqbc/mqbc_clusterutil.t.cpp

Let's revert changes in this file

@@ -1219,7 +1219,7 @@ static void test14_summaryTest()
fields.push_back("Number of partially confirmed messages");
fields.push_back("Number of confirmed messages");
fields.push_back("Number of outstanding messages");
bmqu::AlignedPrinter printer(expectedStream, &fields);
bmqu::AlignedPrinter printer(expectedStream, fields);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to change type a few lines above:
bsl::vector<const char*> fields -> bsl::vector<bsl::string> fields

@@ -2108,7 +2108,7 @@ static void test24_summaryWithQueueDetailsTest()
fields.push_back("Number of partially confirmed messages");
fields.push_back("Number of confirmed messages");
fields.push_back("Number of outstanding messages");
bmqu::AlignedPrinter printer(expectedStream, &fields);
bmqu::AlignedPrinter printer(expectedStream, fields);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to change type a few lines above:
bsl::vector<const char*> fields -> bsl::vector<bsl::string> fields

@@ -71,7 +71,7 @@ void printRecord(bsl::ostream& stream,
fields.push_back("GUID");
fields.push_back("Crc32c");

bmqu::AlignedPrinter printer(stream, &fields);
bmqu::AlignedPrinter printer(stream, fields);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to change type, and do the same in other places in this file:
bsl::vector<const char*> fields -> bsl::vector<bsl::string> fields

@@ -155,7 +155,7 @@ void printRecord(bsl::ostream& stream,
}
}

bmqu::AlignedPrinter printer(stream, &fields);
bmqu::AlignedPrinter printer(stream, fields);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to change type above:
bsl::vector<const char*> fields -> bsl::vector<bsl::string> fields

@@ -81,7 +81,7 @@ void printJournalFileMeta(bsl::ostream& ostream,
fields.push_back("SyncPoint DataFileOffset (DWORDS)");
fields.push_back("SyncPoint QlistFileOffset (WORDS)");

bmqu::AlignedPrinter printer(ostream, &fields);
bmqu::AlignedPrinter printer(ostream, fields);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to change type, and do the same in other places in this file:
bsl::vector<const char*> fields -> bsl::vector<bsl::string> fields

@@ -474,7 +474,7 @@ void StorageInspector::processCommand(
fields.push_back("SyncPoint DataFileOffset (DWORDS)");
fields.push_back("SyncPoint QlistFileOffset (WORDS)");

bmqu::AlignedPrinter printer(BALL_LOG_OUTPUT_STREAM, &fields);
bmqu::AlignedPrinter printer(BALL_LOG_OUTPUT_STREAM, fields);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to change type above, and do the same in other places in this file:
bsl::vector<const char*> fields -> bsl::vector<bsl::string> fields

Comment on lines 686 to 618
it.loadAppIds(&appIdLenPairs);
it.loadAppIdHashes(&appIdHashes);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also need to updates methods loadAppIds and loadAppIdHashes to use bsl::string:

void loadAppIds(bsl::vector<AppIdLengthPair>* appIds) const;

void loadAppIdHashes(bsl::vector<const char*>* appIdHashes) const;

And this typedef:

typedef bsl::pair<const char*, unsigned int> AppIdLengthPair;

Copy link
Author

Choose a reason for hiding this comment

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

Hi Evgeny. Do you agree with the below?

typedef bsl::pair<bsl::string, unsigned int> AppIdLengthPair;

void loadAppIds(bsl::vector<AppIdLengthPair>& appIds) const;

void loadAppIdHashes(bsl::vector<bsl::string>& appIdHashes) const;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @ariraein

typedef bsl::pair<bsl::string, unsigned int> AppIdLengthPair;

This change is good.

void loadAppIds(bsl::vector& appIds) const;

void loadAppIdHashes(bsl::vectorbsl::string& appIdHashes) const;

For these 2 cases, we still have to pass output argument by pointer according to BDE coding standard we use:

https://bloomberg.github.io/bde/knowledge_base/coding_standards.html

Screenshot 2025-02-13 at 18 00 07

So it should be:

void loadAppIds(bsl::vector<AppIdLengthPair> *appIds) const;

void loadAppIdHashes(bsl::vector<bsl::string> *appIdHashes) const;

@ariraein
Copy link
Author

Hi Evgeny. Sorry for the delay. The code changes/updates are done. The only problem is I'm trying to build locally before committing, so to cause no issues here, but so far having issues building on MacOS. Will take care of it by tomorrow. Thanks, Ari.

@ariraein ariraein force-pushed the refactor-aligned-printer branch from c7e40fc to b1a7de7 Compare February 21, 2025 04:37
@678098
Copy link
Collaborator

678098 commented Feb 21, 2025

Hi @ariraein, thank you for fixing DCO. It seems that the files that you modify in this PR were modified by other people, and it causes merge conflicts. Can you solve them?

To start solving merge conflicts, you need to have the latest branch you want to merge to, in this case it's the base repository's main. You can update metadata for this version of main with these commands:

# probably you have your fork of the repo configured, you can also add the base repo as a remote:
git remote add upstream https://github.com/bloomberg/blazingmq.git
git fetch upstream

After this, you can start rebasing:

# make sure you are in the feature branch
git checkout refactor-aligned-printer

# you can make a backup of your branch before resolving conflicts just to be safe
git checkout -b refactor-aligned-printer-backup

# you have created a backup and also switched branch, now you can go back to the branch you want to fix:
git checkout refactor-aligned-printer

# this command will try to move commits in your branch so it starts from the latest main from the base repo:
git rebase upstream/main

git rebase will complain that it cannot perform rebase because there are conflicts. It will also output the list of files with conflicts. You will need to go to these files and apply changes to resolve them.

You can also check that the resolved version builds and after this you can continue git rebase:

# add files that had conflicts fixed
git add .

# check that you haven't added files that are not needed
git status

# finish rebase, the command should complete
git rebase --continue

# now you can update the version of the branch in remote (this PR)
git push -f origin refactor-aligned-printer

Hope these notes will be helpful. If you have any problems, don't hesitate to reach out

@ariraein
Copy link
Author

Hi @678098 Thank you so much for the explanation and help.

@ariraein ariraein force-pushed the refactor-aligned-printer branch from bce40cf to 66c46e9 Compare February 28, 2025 00:21
@678098 678098 self-assigned this Feb 28, 2025
@678098
Copy link
Collaborator

678098 commented Feb 28, 2025

Hi @ariraein, I am busy this week and can review or help on the next. For now, I can launch the CI to check if the PR builds

@ariraein
Copy link
Author

Hi @678098 Thank you. I tried building locally and it was successful. If the PR fails, I will try my best to take care of it.

@ariraein ariraein force-pushed the refactor-aligned-printer branch 2 times, most recently from 01f226e to 4604e20 Compare March 13, 2025 21:22
@ariraein
Copy link
Author

hi @678098 when you have a chance can you please let me know know what am I doing wrong in the process?

1 - built successfully locally
2 - clang-format everything in root blazingmq directory
3 - add all modified files (11)
4 - DCO check steps

@678098
Copy link
Collaborator

678098 commented Mar 20, 2025

Hi @ariraein

1 - built successfully locally
I think the default local build steps don't include building bmqstoragetool. This is why you can build the rest (bmqbrkr, bmqtool), but the CI fails on building bmqstoragetool:

/home/runner/work/blazingmq/blazingmq/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp:1599:20: error: ‘d_queueDeleteRecordsMap’ was not declared in this scope
 1599 |         printer << d_queueDeleteRecordsMap[queueKey];
      |                    ^~~~~~~~~~~~~~~~~~~~~~~

2 - clang-format everything in root blazingmq directory
If you run git clang-format, it will only format the changed files added/updated (but not committed yet) to git. If you had formatting problem in the previous commit, you can either run clang-format on problematic files clang-format -i <path_to_file>, or alternatively you can revert the last commit and re-apply clang-format on file diff:

# check your current branch and commits
git status
git log

# if you are in your branch and the last commit has formatting problem, revert it but keep changes
git reset --soft HEAD~1

# apply clang-format on the files from the reverted commit
git clang-format

# add the updated formatted files and commit again
git add .
git commit -s -m "<commit message>"

# if you are sure that the changes are good you can update your remote fork with the new version of the branch
# git push -f is always a risk, you need to be extra careful not to overwrite good changes
git push -f origin <your branch>

" Num Delete Records : 5";

bsl::string res(resultStream.str(), bmqtst::TestHelperUtil::allocator());
ASSERT(res.starts_with(expectedStream.str()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

A general comment, in the PR's description there are much more additions than deletions: +662 −72
It looks suspicious because you can expect the numbers to be pretty close if you are doing code refactor. If you look closely at the changed files, many of them have additions only. This means that the PR is adding new code rather than changing the existing one. I think the reason for this is the conflict resolution process when the code moved to another places in the main branch. You should probably search for the place where the code moved and apply changes there.
If you see places where the code was just added without modification of other code, it's probably a place where the conflict resolution went wrong

@678098 678098 requested a review from alexander-e1off March 27, 2025 12:14
@ariraein ariraein force-pushed the refactor-aligned-printer branch from 4604e20 to 86a7a1a Compare April 13, 2025 02:53
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.

2 participants