Add example how to calculate bucketId on client#274
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 |
akudiyar
left a comment
There was a problem hiding this comment.
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.
I think we need to handle an unexpected null value better, like with an orElseThrow callback
There was a problem hiding this comment.
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.
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.
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? |
| client.callForSingleResult("vshard.router.bucket_count", Integer.class).get() | ||
| ); | ||
| } | ||
| bucketCount.orElseThrow(() -> new TarantoolClientException("Failed to get bucket count")); |
| 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.
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 #???