wuxizhi777 commented on PR #4772:
URL: https://github.com/apache/seatunnel/pull/4772#issuecomment-1581822978
public class test {
private static final XXHash64 HASH_INSTANCE =
XXHashFactory.fastestInstance().hash64();
public int getShard(Object shardValue){
int shardWeightCount = 6;
int offset =
(int)
((HASH_INSTANCE.hash(
ByteBuffer.wrap(
shardValue
.toString()
.getBytes(StandardCharsets.UTF_8)),
0)
& Long.MAX_VALUE)
% shardWeightCount);
return offset;
}
@Test
public void testShared(){
String a = "a,b,c,d,e,f";
for(Object o: Arrays.stream(a.split(",")).toArray()){
System.out.println(getShard(o));
}
}
}
===================
the result is :
3
3
3
2
4
5
--
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]