Skip to content

Commit 6e7b3de

Browse files
committed
Fixes after review
1 parent 0a1db62 commit 6e7b3de

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,15 @@ For this purpose you need:
276276
client.callForSingleResult("vshard.router.bucket_count", Integer.class).get()
277277
);
278278
}
279-
return bucketCount.get();
279+
bucketCount.orElseThrow(() -> new TarantoolClientException("Failed to get bucket count"));
280280
}
281281
```
282282

283283
Then we can determine bucket id by passing your key through hash function and get the remainder of the division by number of buckets:
284284
```java
285-
byte[] key = ... // can be multipart
286-
Integer bucketId = (bucketIdcrc32(key) % getBucketCount(client)) + 1;
285+
TarantoolTuple tarantoolTuple = tupleFactory.create(1, null, "FIO", 50, 100);
286+
byte[] key = getBytesFromList(Arrays.asList(tarantoolTuple.getInteger(0), tarantoolTuple.getInteger(2)));
287+
Integer bucketId = (crc32(key) % getBucketCount(client)) + 1;
287288
```
288289

289290
After that we may apply it in operations:

src/test/java/io/tarantool/driver/integration/Utils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import io.tarantool.driver.api.conditions.Conditions;
66
import io.tarantool.driver.api.space.TarantoolSpaceOperations;
77
import io.tarantool.driver.api.tuple.TarantoolTuple;
8+
import io.tarantool.driver.exceptions.TarantoolClientException;
9+
import io.tarantool.driver.exceptions.TarantoolException;
10+
import io.tarantool.driver.exceptions.TarantoolSpaceFieldNotFoundException;
811
import io.tarantool.driver.protocol.Packable;
912

1013
import java.io.ByteArrayOutputStream;
@@ -51,7 +54,7 @@ public static <T extends Packable, R extends Collection<T>> Integer getBucketCou
5154
client.callForSingleResult("vshard.router.bucket_count", Integer.class).get()
5255
);
5356
}
54-
return bucketCount.get();
57+
return bucketCount.orElseThrow(() -> new TarantoolClientException("Failed to get bucket count"));
5558
}
5659

5760
/**

0 commit comments

Comments
 (0)