-
Notifications
You must be signed in to change notification settings - Fork 191
Refactor[mqbs::FileStore]: Encapsulate write-head cursor accessors #1673
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fc86c5f
Refactor[mqbs::FileStore]: Add setWriteHead to move the write cursor
kaikulimu 2eccee3
Refactor[mqbs::FileStore]: sequenceNumber -> writeHeadSeqNum
kaikulimu 66fb6a2
Refactor[mqbs::FileStore]: Encapsulate write-head seqNum increment
kaikulimu 6e72d80
Refactor[mqbs::DataStore]: Order leaseId before seqNum in RecordKey
kaikulimu af5bc64
Refactor[mqbs::FileStore]: Harden incrementWriteHeadSeqNum precondition
kaikulimu 2d98f43
PR#1673: Address feedback
kaikulimu 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -179,10 +179,10 @@ struct DataStoreRecord { | |||||
| struct DataStoreRecordKey { | ||||||
| public: | ||||||
| // PUBLIC DATA | ||||||
| bsls::Types::Uint64 d_sequenceNum; | ||||||
|
|
||||||
| unsigned int d_primaryLeaseId; | ||||||
|
|
||||||
| bsls::Types::Uint64 d_sequenceNum; | ||||||
|
|
||||||
| // TRAITS | ||||||
| BSLMF_NESTED_TRAIT_DECLARATION(DataStoreRecordKey, | ||||||
| bslmf::IsBitwiseEqualityComparable) | ||||||
|
|
@@ -192,8 +192,8 @@ struct DataStoreRecordKey { | |||||
| // CREATORS | ||||||
| DataStoreRecordKey(); | ||||||
|
|
||||||
| DataStoreRecordKey(const bsls::Types::Uint64 sequenceNum, | ||||||
| unsigned int primaryLeaseId); | ||||||
| DataStoreRecordKey(unsigned int primaryLeaseId, | ||||||
| const bsls::Types::Uint64 sequenceNum); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This is a basic type, no need to have |
||||||
|
|
||||||
| // ACCESSORS | ||||||
|
|
||||||
|
|
@@ -831,17 +831,17 @@ inline DataStoreRecord::DataStoreRecord( | |||||
|
|
||||||
| // CREATORS | ||||||
| inline DataStoreRecordKey::DataStoreRecordKey() | ||||||
| : d_sequenceNum(0) | ||||||
| , d_primaryLeaseId(0) | ||||||
| : d_primaryLeaseId(0) | ||||||
| , d_sequenceNum(0) | ||||||
| { | ||||||
| // NOTHING | ||||||
| } | ||||||
|
|
||||||
| inline DataStoreRecordKey::DataStoreRecordKey( | ||||||
| const bsls::Types::Uint64 sequenceNum, | ||||||
| unsigned int primaryLeaseId) | ||||||
| : d_sequenceNum(sequenceNum) | ||||||
| , d_primaryLeaseId(primaryLeaseId) | ||||||
| unsigned int primaryLeaseId, | ||||||
| const bsls::Types::Uint64 sequenceNum) | ||||||
| : d_primaryLeaseId(primaryLeaseId) | ||||||
| , d_sequenceNum(sequenceNum) | ||||||
| { | ||||||
| // NOTHING | ||||||
| } | ||||||
|
|
@@ -851,8 +851,8 @@ template <class HASH_ALGORITHM> | |||||
| void hashAppend(HASH_ALGORITHM& hashAlgo, const mqbs::DataStoreRecordKey& key) | ||||||
| { | ||||||
| using bslh::hashAppend; // for ADL | ||||||
| hashAppend(hashAlgo, key.d_sequenceNum); | ||||||
| hashAppend(hashAlgo, key.d_primaryLeaseId); | ||||||
| hashAppend(hashAlgo, key.d_sequenceNum); | ||||||
| } | ||||||
|
|
||||||
| // -------------------------------- | ||||||
|
|
@@ -864,8 +864,8 @@ template <class TYPE> | |||||
| inline DataStoreRecordKeyHashAlgo::result_type | ||||||
| DataStoreRecordKeyHashAlgo::operator()(const TYPE& type) const | ||||||
| { | ||||||
| return type.d_sequenceNum + | ||||||
| (static_cast<bsls::Types::Uint64>(type.d_primaryLeaseId) << 32); | ||||||
| return (static_cast<bsls::Types::Uint64>(type.d_primaryLeaseId) << 32) + | ||||||
| type.d_sequenceNum; | ||||||
| } | ||||||
|
|
||||||
| // ----------------------------- | ||||||
|
|
||||||
This file contains hidden or 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 hidden or 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
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.
Now member alignment is not ideal:
If only we could use 64bit type for
leaseIdtoo...Uh oh!
There was an error while loading. Please reload this page.
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.
Switched them back only in the data member declarations.