YuweiXiao commented on code in PR #4958:
URL: https://github.com/apache/hudi/pull/4958#discussion_r917395167
##########
hudi-client/hudi-client-common/src/test/java/org/apache/hudi/index/bucket/TestConsistentBucketIdIdentifier.java:
##########
@@ -76,4 +96,90 @@ public void testGetBucket() {
Assertions.assertEquals(nodes.get(1),
identifier.getBucketByFileId(FSUtils.createNewFileId("1", 0)));
Assertions.assertEquals(nodes.get(2),
identifier.getBucketByFileId(FSUtils.createNewFileId("2", 0)));
}
+
+ /**
+ * @param v0 first node hash value
+ * @param v1 second node hash value
+ * @param mid mid node hash value generated by split the first bucket v0
+ */
+ @ParameterizedTest
+ @MethodSource("splitBucketParams")
+ public void testSplitBucket(int v0, int v1, int mid) {
+ // Hash range mapping:: [0, 0xf], (0xf, MAX]
+ List<ConsistentHashingNode> nodes = Arrays.asList(
+ new ConsistentHashingNode(v0, "0"),
+ new ConsistentHashingNode(v1, "1"));
+ HoodieConsistentHashingMetadata meta = new
HoodieConsistentHashingMetadata((short) 0, "", "", 4, 0, nodes);
+ Option<List<ConsistentHashingNode>> res = new
ConsistentBucketIdentifier(meta).splitBucket(nodes.get(0));
+ if (mid < 0) {
+ Assertions.assertTrue(!res.isPresent());
+ return;
+ }
+
+ List<ConsistentHashingNode> childNodes = res.get();
+ Assertions.assertEquals(2, childNodes.size());
Review Comment:
Thanks for the suggestion. By the way, will static import provide better
performance? or it is for cleaner code.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]