-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Saving Alphanueric Ranges and Searching it #6357
Comments
probably related to #871 |
Hi @gelinger777. What is the concrete type you're saving here? Is a range a string? e.g. |
@alexanderbez we are open to change the way it is saved if needed . We could theoretically save the range for example as |
Because there is an overlap?
Almost every single module uses prefix queries and iterators. e.g (prefix: func (k Keeper) IterateEvidence(ctx sdk.Context, cb func(exported.Evidence) bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixEvidence)
iterator := sdk.KVStorePrefixIterator(store, nil)
defer iterator.Close()
for ; iterator.Valid(); iterator.Next() {
evidence := k.MustUnmarshalEvidence(iterator.Value())
if cb(evidence) {
break
}
}
} If you simply want an operation to fail if the series overlaps/intersects with an existing one, you can leverage several approaches and data structures. e.g.
|
@alexanderbez thank you for your detailed response. Last question, thought. What would be faster and more robust approach , sorted arrays or prefix scans? |
Option (1) would require you load the entire set at once, depending on if this set is small, this could be fine. (2) would require less IO, but might be more complicated? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@alexanderbez thank you very much |
Let me first of all thank you very much for the hard work you are doing for building this great product.
Summary
Currently we are building a private blockchain, where we need to save alphanumeric serial numbers which consist of following structure
1-2 Char Letters (A, AB, AC, BC etc ) and number which can be from 1-1.000.000.000
We always have a sequence like this
AA0000000001-AA0000000124 for example . So always in our stored data there is Start and End .
So when a new range is added, we have to check existing database of assigned ranges and make sure that it has never been used before.
Problem Definition
How to define number ranges? How to make search on existing ranges and forbid already used numbers to be used again? Is there a way exists with current situation?
The text was updated successfully, but these errors were encountered: