-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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): IndexedMap #14397
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
4619c3c
add: init pair
39e3d8f
Merge branch 'main' into tip/collections-pairkeys
f9f6773
add: refactor ranging
28bd97e
remove useless test
a1861f9
add: testing + proper pair impl
d75e33c
Merge branch 'main' into tip/collections-pairkeys
e683ac0
Merge branch 'main' into tip/collections-pairkeys
5044359
add: tmp
8ec3d87
add: pair key accessor
11ee08b
Merge branch 'tip/collections-pairkeys' into tip/indexed_map
dd6d29b
add: MultiIndex tests
f43b832
add: unique index tests
8ebdfd7
change: unique index propagates pk
036a7ee
change: propagate primary key in indexes multi
6060a4a
Merge branch 'main' into tip/collections-pairkeys
638c582
chore: merge
f3772f0
Merge branch 'tip/collections-pairkeys' into tip/indexed_map
6b71609
chore: merge
61d5a00
add: has method
fc1db55
Merge branch 'main' into tip/indexed_map
96b7c88
merge main
b1ddef0
Merge branch 'main' into tip/indexed_map
testinginprod f20ce08
chore: merge main
50acaa9
chore: merge main2
399a6b4
change: make indexes generic
7d3f205
change indexed map test to depend on generic unique index
71e2242
change move unique index to a separate pkg
1507e38
add: generic multi index testing
0489736
chore: improve coverage
b404df7
chore: add indexes unique testing
1adc55c
remove: specific indexes
99d5140
Merge branch 'main' into tip/indexed_map
testinginprod 4e4d0d8
chore: CHANGELOG.md
c16ddba
Merge branch 'main' into tip/indexed_map
6934ebf
chore: update core deps
67b6509
chore: try to make all more easy to understand
d98c580
Merge branch 'main' into tip/indexed_map
360727e
Merge branch 'main' into tip/indexed_map
tac0turtle 207c4be
Merge branch 'main' into tip/indexed_map
e7088c3
chore: cleanups
7e34f77
docs collections/indexes_generic_multi.go
testinginprod 838295e
Update collections/indexed_map.go
testinginprod c7fc993
chore: docs
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
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
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,48 @@ | ||
package colltest | ||
|
||
import "testing" | ||
|
||
type animal interface { | ||
name() string | ||
} | ||
|
||
type dog struct { | ||
Name string `json:"name"` | ||
BarksLoudly bool `json:"barks_loudly"` | ||
} | ||
|
||
type cat struct { | ||
Name string `json:"name"` | ||
Scratches bool `json:"scratches"` | ||
} | ||
|
||
func (d *cat) name() string { return d.Name } | ||
|
||
func (d dog) name() string { return d.Name } | ||
|
||
func TestMockValueCodec(t *testing.T) { | ||
t.Run("primitive type", func(t *testing.T) { | ||
x := MockValueCodec[string]() | ||
TestValueCodec(t, x, "hello") | ||
}) | ||
|
||
t.Run("struct type", func(t *testing.T) { | ||
x := MockValueCodec[dog]() | ||
TestValueCodec(t, x, dog{ | ||
Name: "kernel", | ||
BarksLoudly: true, | ||
}) | ||
}) | ||
|
||
t.Run("interface type", func(t *testing.T) { | ||
x := MockValueCodec[animal]() | ||
TestValueCodec[animal](t, x, dog{ | ||
Name: "kernel", | ||
BarksLoudly: true, | ||
}) | ||
TestValueCodec[animal](t, x, &cat{ | ||
Name: "echo", | ||
Scratches: true, | ||
}) | ||
}) | ||
} |
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,49 @@ | ||
package colltest | ||
|
||
import ( | ||
"context" | ||
|
||
"cosmossdk.io/core/store" | ||
db "github.com/cosmos/cosmos-db" | ||
) | ||
|
||
// MockStore returns a mock store.KVStoreService and a mock context.Context. | ||
// They can be used to test collections. | ||
func MockStore() (store.KVStoreService, context.Context) { | ||
kv := db.NewMemDB() | ||
return &testStore{kv}, context.Background() | ||
} | ||
|
||
type testStore struct { | ||
db db.DB | ||
} | ||
|
||
func (t testStore) OpenKVStore(ctx context.Context) store.KVStore { | ||
return t | ||
} | ||
|
||
func (t testStore) Get(key []byte) ([]byte, error) { | ||
return t.db.Get(key) | ||
} | ||
|
||
func (t testStore) Has(key []byte) (bool, error) { | ||
return t.db.Has(key) | ||
} | ||
|
||
func (t testStore) Set(key, value []byte) error { | ||
return t.db.Set(key, value) | ||
} | ||
|
||
func (t testStore) Delete(key []byte) error { | ||
return t.db.Delete(key) | ||
} | ||
|
||
func (t testStore) Iterator(start, end []byte) (store.Iterator, error) { | ||
return t.db.Iterator(start, end) | ||
} | ||
|
||
func (t testStore) ReverseIterator(start, end []byte) (store.Iterator, error) { | ||
return t.db.ReverseIterator(start, end) | ||
} | ||
|
||
var _ store.KVStore = testStore{} |
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
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.
TBH these changelog entries are superfluous -- as a dev, they tell me nothing useful.
Honestly, we can probably have a single collections CL entry that outlines all the additions and changes.
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.
yes, it makes sense to me. When we release the first "stable" version we can add a comprehensive list of the features in the changelog, and then apply the classic by PR changelog after the first release.