lamber-ken commented on a change in pull request #1466: [HUDI-742] Fix Java
Math Exception
URL: https://github.com/apache/incubator-hudi/pull/1466#discussion_r399921954
##########
File path:
hudi-client/src/test/java/org/apache/hudi/index/bloom/TestBucketizedBloomCheckPartitioner.java
##########
@@ -79,4 +79,17 @@ public void testNumPartitions() {
BucketizedBloomCheckPartitioner p = new
BucketizedBloomCheckPartitioner(10000, comparisons1, 10);
assertEquals("num partitions must equal total buckets", 100,
p.numPartitions());
}
+
+ @Test
+ public void testGetPartitions() {
+ Map<String, Long> comparisons1 = new HashMap<String, Long>() {
+ {
+ IntStream.range(0, 10).forEach(f -> put("f" + f, 100L));
+ }
+ };
+ BucketizedBloomCheckPartitioner p = new
BucketizedBloomCheckPartitioner(10000, comparisons1, 10);
+ Object key = Pair.of("f0", "value0");
+ assertEquals("candidatePartitions must be a posive number: ", 94,
p.getPartition(key));
Review comment:
IMO, `94` is unstable, the value depends on different hash methods. I think
we can check the partition range, for example. WDYT?
```
@Test
public void testGetPartitions() {
Map<String, Long> comparisons1 = new HashMap<String, Long>() {
{
IntStream.range(0, 100000).forEach(f -> put("f" + f, 100L));
}
};
BucketizedBloomCheckPartitioner p = new
BucketizedBloomCheckPartitioner(1000, comparisons1, 10);
IntStream.range(0, 100000).forEach(f -> {
int partition = p.getPartition(Pair.of("f" + f, "value"));
assertTrue("partition is out of range: " + partition, 0 <= partition &&
partition <= 1000);
});
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services