-
Notifications
You must be signed in to change notification settings - Fork 139
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
Feat[Storagetool]: Add searching by record sequence numbers and offsets #508
Merged
pniedzielski
merged 27 commits into
bloomberg:main
from
alexander-e1off:storagetool-add-seqnum
Dec 20, 2024
+2,107
−132
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
ca179b8
Add seqnum and offset input args, add composite sequence number support
alexander-e1off f36e2f6
Debug binary search for all range types
alexander-e1off 2ed441f
Reemove debug
alexander-e1off 23ca939
Simplify getValue template
alexander-e1off 33d990e
Add search result decorators for seq.number and offset, add UTs
alexander-e1off 1bcf853
Fix hasCache() call
alexander-e1off 25a805a
Fix code style
alexander-e1off 9898b5d
Fix code style
alexander-e1off d00d17c
Add search for specific sequence numbers and offsets
alexander-e1off 1435ed4
Cleanup
alexander-e1off f1d28fa
Fix README.md
alexander-e1off f69ee41
Fix typo in README.md
alexander-e1off 6897db6
Update header caption
alexander-e1off 08e4983
Fix review comments
alexander-e1off 27194b8
Fix code style
alexander-e1off c8758ad
Reset errorDescr
alexander-e1off 7c234b9
Merge branch 'main' into storagetool-add-seqnum
alexander-e1off 768b164
Fix merge conflicts
alexander-e1off 6ecd167
Fix merge conflicts
alexander-e1off 10b24b5
Fix formatting
alexander-e1off eab1197
Merge remote-tracking branch 'upstream/main' into storagetool-add-seqnum
alexander-e1off 3c7d12f
Merge remote-tracking branch 'upstream/main' into storagetool-add-seqnum
alexander-e1off 561f4da
Merge remote-tracking branch 'upstream/main' into storagetool-add-seqnum
alexander-e1off a290ba0
Merge from main, fix conflicts
alexander-e1off e9cf8dd
Fix assert macro names in compositesequencenumber.t
alexander-e1off d17230a
Merge remote-tracking branch 'upstream/main' into storagetool-add-seqnum
alexander-e1off 73cb8d0
Fix review comments: typos, doxygen comments
alexander-e1off File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
src/applications/bmqstoragetool/m_bmqstoragetool_compositesequencenumber.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// Copyright 2014-2023 Bloomberg Finance L.P. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// bmqstoragetool | ||
#include <m_bmqstoragetool_compositesequencenumber.h> | ||
|
||
// BDE | ||
#include <bdlb_print.h> | ||
#include <bsl_stdexcept.h> | ||
|
||
namespace BloombergLP { | ||
namespace m_bmqstoragetool { | ||
|
||
// ============================= | ||
// class CompositeSequenceNumber | ||
// ============================= | ||
|
||
CompositeSequenceNumber::CompositeSequenceNumber() | ||
: d_leaseId(0) | ||
, d_seqNumber(0) | ||
, d_isSet(false) | ||
{ | ||
// NOTHING | ||
} | ||
|
||
CompositeSequenceNumber::CompositeSequenceNumber( | ||
const unsigned int leaseId, | ||
const bsls::Types::Uint64 sequenceNumber) | ||
: d_leaseId(leaseId) | ||
, d_seqNumber(sequenceNumber) | ||
{ | ||
BSLS_ASSERT(d_leaseId > 0 && d_seqNumber > 0); | ||
d_isSet = d_leaseId > 0 && d_seqNumber > 0; | ||
} | ||
|
||
CompositeSequenceNumber& | ||
CompositeSequenceNumber::fromString(bsl::ostream& errorDescription, | ||
const bsl::string& seqNumString) | ||
{ | ||
d_isSet = false; | ||
|
||
if (seqNumString.empty()) { | ||
errorDescription << "Invalid input: empty string."; | ||
return *this; // RETURN | ||
} | ||
|
||
// Find the position of the separator | ||
const size_t separatorPos = seqNumString.find('-'); | ||
if (separatorPos == bsl::string::npos) { | ||
errorDescription << "Invalid format: no '-' separator found."; | ||
return *this; // RETURN | ||
} | ||
|
||
// Extract parts | ||
const bsl::string firstPart = seqNumString.substr(0, separatorPos); | ||
const bsl::string secondPart = seqNumString.substr(separatorPos + 1); | ||
|
||
// Convert parts to numbers | ||
try { | ||
size_t posFirst, posSecond; | ||
|
||
unsigned long uLong = bsl::stoul(firstPart, &posFirst); | ||
d_seqNumber = bsl::stoul(secondPart, &posSecond); | ||
|
||
if (posFirst != firstPart.size() || posSecond != secondPart.size()) { | ||
throw bsl::invalid_argument(""); // THROW | ||
} | ||
|
||
d_leaseId = static_cast<unsigned int>(uLong); | ||
if (uLong != d_leaseId) { | ||
throw bsl::out_of_range(""); // THROW | ||
} | ||
|
||
if (d_leaseId == 0 || d_seqNumber == 0) { | ||
errorDescription << "Invalid input: zero values encountered."; | ||
return *this; // RETURN | ||
} | ||
|
||
d_isSet = true; | ||
} | ||
catch (const bsl::invalid_argument& e) { | ||
errorDescription << "Invalid input: non-numeric values encountered."; | ||
} | ||
catch (const bsl::out_of_range& e) { | ||
errorDescription << "Invalid input: number out of range."; | ||
} | ||
|
||
return *this; | ||
} | ||
|
||
bsl::ostream& CompositeSequenceNumber::print(bsl::ostream& stream, | ||
int level, | ||
int spacesPerLevel) const | ||
{ | ||
if (stream.bad()) { | ||
return stream; // RETURN | ||
} | ||
|
||
bdlb::Print::indent(stream, level, spacesPerLevel); | ||
|
||
if (isSet()) { | ||
stream << "leaseId: " << leaseId() | ||
<< ", sequenceNumber: " << sequenceNumber(); | ||
} | ||
else { | ||
stream << "** UNSET **"; | ||
} | ||
|
||
if (spacesPerLevel >= 0) { | ||
stream << '\n'; | ||
} | ||
|
||
return stream; | ||
} | ||
|
||
} // close package namespace | ||
} // close enterprise namespace |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems reasonable to want to look at journal records with a particular primary lease ID that happened after a particular timestamp, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See earlier comment, let's make this change later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the first step we agreed to make these filters mutual exclusive, and then change behaviour depending on user feedback. Agree to make this change later.