-
Notifications
You must be signed in to change notification settings - Fork 13
Add example how to calculate bucketId on client #274
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
Conversation
f4d15d4
to
4412b80
Compare
@dkasimovskiy suggests to export this implementation in source. What do you think about it? |
I think a good solution will be to describe how to create and use your own sharding function with the help of vshard API calls in the README. And leave the sample code in the tests how it is now. |
5d7f09a
to
8bb7c18
Compare
8bb7c18
to
59b635f
Compare
Added, please validate it |
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,just two points here:
- an example of converting a tuple to bytes will be useful
- fixed the grammar a bit
README.md
Outdated
client.callForSingleResult("vshard.router.bucket_count", Integer.class).get() | ||
); | ||
} | ||
return bucketCount.get(); |
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.
I think we need to handle an unexpected null
value better, like with an orElseThrow
callback
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.
Rewritten, please check it out
README.md
Outdated
|
||
Then we can determine bucket id by passing your key through hash function and get the remainder of the division by number of buckets: | ||
```java | ||
byte[] key = ... // can be multipart |
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's not clear now what to put in the key. An example with a tuple will be better
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.
Rewritten, please check it out
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
Co-authored-by: Alexey Kuzin <akudiyar@gmail.com>
5bc9e6a
to
6e7b3de
Compare
@akudiyar Could you check it? |
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
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.
Two small changes are needed, I forgot to mention this, sorry. Let's do this on the next doc change.
client.callForSingleResult("vshard.router.bucket_count", Integer.class).get() | ||
); | ||
} | ||
bucketCount.orElseThrow(() -> new TarantoolClientException("Failed to get bucket count")); |
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.
return
is missing
Then we can determine bucket id by passing your key through hash function and get the remainder of the division by number of buckets: | ||
```java | ||
TarantoolTuple tarantoolTuple = tupleFactory.create(1, null, "FIO", 50, 100); | ||
byte[] key = getBytesFromList(Arrays.asList(tarantoolTuple.getInteger(0), tarantoolTuple.getInteger(2))); |
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 may be good to place a link to this getBytesFromList
method in the tests to the comment above, because it is not a built-in and therefore produces questions
What has been done? Why? What problem is being solved?
I didn't forget about
Closes #???