Skip to content

Commit

Permalink
update(io.mycat.route.function.PartionByLong):
Browse files Browse the repository at this point in the history
1.
在long型key对1024求模时,先将key无符号右移32位得到一个key1,然后将key与key1进行异或得到新的key值,新的key值将保留long型的高32位和低32位的特征。
  • Loading branch information
yzx committed Dec 31, 2019
1 parent 7ab9d91 commit cc8d830
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/mycat/route/function/PartitionByLong.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Integer calculate(String columnValue) {
// columnValue = NumberParseUtil.eliminateQoute(columnValue);
try {
long key = Long.parseLong(columnValue);
key = (key >>> 32) ^ key;
return partitionUtil.partition(key);
} catch (NumberFormatException e){
throw new IllegalArgumentException(new StringBuilder().append("columnValue:").append(columnValue).append(" Please eliminate any quote and non number within it.").toString(),e);
Expand Down

0 comments on commit cc8d830

Please sign in to comment.