-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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(collections): quad collection #21090
Conversation
WalkthroughWalkthroughThe changes introduce a new Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- collections/quad.go (1 hunks)
- collections/quad_test.go (1 hunks)
Additional context used
Path-based instructions (2)
collections/quad_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"collections/quad.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (25)
collections/quad_test.go (2)
13-18
: LGTM!The
TestQuad
function correctly tests the conformance of theQuadKeyCodec
. The use ofcolltest.TestKeyCodec
ensures that the codec is tested comprehensively.
21-60
: LGTM!The
TestQuadRange
function comprehensively tests the range operations for theQuad
collection. The test covers various scenarios, including prefix and super prefix queries.collections/quad.go (23)
11-17
: LGTM!The
Quad
struct is well-defined and follows best practices for defining multipart keys.
19-22
: LGTM!The
Join4
function is correctly implemented and follows best practices for instantiating a newQuad
instance.
24-30
: LGTM!The
K1
function is correctly implemented and follows best practices for returning the first part of the key.
32-38
: LGTM!The
K2
function is correctly implemented and follows best practices for returning the second part of the key.
40-46
: LGTM!The
K3
function is correctly implemented and follows best practices for returning the third part of the key.
56-59
: LGTM!The
QuadPrefix
function is correctly implemented and follows best practices for creating a newQuad
instance composed only of the first part of the key.
61-64
: LGTM!The
QuadSuperPrefix
function is correctly implemented and follows best practices for creating a newQuad
instance composed only of the first two parts of the key.
66-69
: LGTM!The
QuadSuperPrefix3
function is correctly implemented and follows best practices for creating a newQuad
instance composed only of the first three parts of the key.
71-80
: LGTM!The
QuadKeyCodec
function is correctly implemented and follows best practices for instantiating a newKeyCodec
instance that can encode theQuad
.
91-113
: LGTM!The
EncodeJSON
function is correctly implemented and follows best practices for encoding theQuad
into JSON format.
115-143
: LGTM!The
DecodeJSON
function is correctly implemented and follows best practices for decoding theQuad
from JSON format.
145-185
: LGTM!The
Stringify
function is correctly implemented and follows best practices for converting theQuad
into a string representation.
187-189
: LGTM!The
KeyType
function is correctly implemented and follows best practices for returning the type of the key.
191-221
: LGTM!The
Encode
function is correctly implemented and follows best practices for encoding theQuad
into a byte buffer.
224-247
: LGTM!The
Decode
function is correctly implemented and follows best practices for decoding theQuad
from a byte buffer.
249-264
: LGTM!The
Size
function is correctly implemented and follows best practices for returning the size of theQuad
key.
266-296
: LGTM!The
EncodeNonTerminal
function is correctly implemented and follows best practices for encoding theQuad
into a byte buffer, excluding the terminal key.
299-321
: LGTM!The
DecodeNonTerminal
function is correctly implemented and follows best practices for decoding theQuad
from a byte buffer, excluding the terminal key.
324-339
: LGTM!The
SizeNonTerminal
function is correctly implemented and follows best practices for returning the size of theQuad
key, excluding the terminal key.
341-348
: LGTM!The
NewPrefixUntilQuadRange
function is correctly implemented and follows best practices for defining a collection query which ranges until the provided Quad prefix.
350-358
: LGTM!The
NewPrefixedQuadRange
function is correctly implemented and follows best practices for providing a Range for all keys prefixed with the given first part of the Quad key.
360-368
: LGTM!The
NewSuperPrefixedQuadRange
function is correctly implemented and follows best practices for providing a Range for all keys prefixed with the given first and second parts of the Quad key.
370-378
: LGTM!The
NewSuperPrefixedQuadRange3
function is correctly implemented and follows best practices for providing a Range for all keys prefixed with the given first, second, and third parts of the Quad key.
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.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- collections/quad.go (1 hunks)
- collections/quad_test.go (1 hunks)
Additional context used
Path-based instructions (2)
collections/quad_test.go (2)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Pattern
**/*_test.go
: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"collections/quad.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (13)
collections/quad_test.go (2)
13-18
: LGTM!The
TestQuad
function correctly tests the conformance of theQuadKeyCodec
using a sample key.
21-60
: LGTM!The
TestQuadRange
function comprehensively tests the range functionality of theQuad
collection, covering multiple range queries and validating the results.collections/quad.go (11)
19-22
: LGTM!The
Join4
function correctly creates a newQuad
instance with four keys.
24-29
: LGTM!The
K1
function correctly returns the first part of the key or the zero value if nil.
32-37
: LGTM!The
K2
function correctly returns the second part of the key or the zero value if nil.
40-45
: LGTM!The
K3
function correctly returns the third part of the key or the zero value if nil.
56-59
: LGTM!The
QuadPrefix
function correctly creates a newQuad
instance with only the first part of the key.
61-64
: LGTM!The
QuadSuperPrefix
function correctly creates a newQuad
instance with the first two parts of the key.
66-69
: LGTM!The
QuadSuperPrefix3
function correctly creates a newQuad
instance with the first three parts of the key.
71-79
: LGTM!The
QuadKeyCodec
function correctly creates a newKeyCodec
instance for theQuad
key.
91-112
: LGTM!The
EncodeJSON
method correctly encodes aQuad
key to JSON format.
115-142
: LGTM!The
DecodeJSON
method correctly decodes aQuad
key from JSON format.
145-185
: LGTM!The
Stringify
method correctly converts aQuad
key to a string representation.
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- collections/quad.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- collections/quad.go
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
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.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (1)
- collections/quad.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- collections/quad.go
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.
lgtm
We should add a changelog |
Any chance we can tag a new cosmossdk.io/collections tag with this feature, that's compatible with 0.50? (hi everyone btw 👋 ) |
Description
Closes: #21061
Implemented a Quad collection to allow composite keys of 4 parts.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit
New Features
Quad
, for managing composite keys with enhanced type safety.Quad
instances and accessing individual keys.Quad
keys.Tests
Quad
and its key management functionalities.