VGalaxies commented on code in PR #2321:
URL:
https://github.com/apache/incubator-hugegraph/pull/2321#discussion_r1359894738
##########
hugegraph-pd/hg-pd-test/src/main/java/org/apache/hugegraph/pd/common/PartitionUtilsTest.java:
##########
@@ -17,19 +17,37 @@
package org.apache.hugegraph.pd.common;
-import org.apache.hugegraph.pd.common.PartitionUtils;
+import java.nio.charset.StandardCharsets;
+import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.junit.Test;
-import lombok.extern.slf4j.Slf4j;
-
@Slf4j
public class PartitionUtilsTest extends BaseCommonTest {
+
@Test
public void testCalcHashcode() {
byte[] key = new byte[5];
long code = PartitionUtils.calcHashcode(key);
Assert.assertEquals(code, 31912L);
}
-}
\ No newline at end of file
+
+ // @Test
+ public void testHashCode() {
+ int partCount = 10;
+ int partSize = PartitionUtils.MAX_VALUE / partCount + 1;
+ int[] counter = new int[partCount];
+ for (int i = 0; i < 10000; i++) {
+ String s = String.format("BATCH-GET-UNIT-%02d", i);
+ int c =
PartitionUtils.calcHashcode(s.getBytes(StandardCharsets.UTF_8));
+
+ counter[c / partSize]++;
+
+ }
+
+ for (int i = 0; i < counter.length; i++) {
+ System.out.println(i + " " + counter[i]);
+ }
+ }
+}
Review Comment:
Migrated from the corresponding class in the testing directory of a
sub-module under hugegraph-pd. Awaiting further adaptation in the next step.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]