mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
use fnv1a_64 replace murmurhash.
This commit is contained in:
@@ -703,7 +703,7 @@ public class SQLUtils {
|
||||
}
|
||||
|
||||
if (token == Token.ERROR) {
|
||||
return Utils.murmurhash2_64(sql);
|
||||
return Utils.fnv_64(sql);
|
||||
}
|
||||
|
||||
if (buf.length() != 0) {
|
||||
|
||||
@@ -592,7 +592,7 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean, Comparable<JdbcSqlSt
|
||||
|
||||
public long getSqlHash() {
|
||||
if (sqlHash == 0) {
|
||||
sqlHash = Utils.murmurhash2_64(sql);
|
||||
sqlHash = Utils.fnv_64(sql);
|
||||
}
|
||||
return sqlHash;
|
||||
}
|
||||
|
||||
@@ -413,32 +413,33 @@ public class Utils {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long hash = 0x811c9dc5;
|
||||
long hash = 0xcbf29ce484222325L;
|
||||
for (int i = 0; i < input.length(); ++i) {
|
||||
char c = input.charAt(i);
|
||||
hash ^= c;
|
||||
hash *= 0x1000193;
|
||||
hash *= 0x100000001b3L;
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static long fnv_64_lower(String input) {
|
||||
if (input == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long hash = 0x811c9dc5;
|
||||
for (int i = 0; i < input.length(); ++i) {
|
||||
char c = input.charAt(i);
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
c += 32;
|
||||
public static long fnv_64_lower(String key) {
|
||||
long hashCode = 0xcbf29ce484222325L;
|
||||
for (int i = 0; i < key.length(); ++i) {
|
||||
char ch = key.charAt(i);
|
||||
if (ch == '_' || ch == '-') {
|
||||
continue;
|
||||
}
|
||||
hash ^= c;
|
||||
hash *= 0x1000193;
|
||||
|
||||
if (ch >= 'A' && ch <= 'Z') {
|
||||
ch = (char) (ch + 32);
|
||||
}
|
||||
|
||||
hashCode ^= ch;
|
||||
hashCode *= 0x100000001b3L;
|
||||
}
|
||||
|
||||
return hash;
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public static void loadFromFile(String path, Set<String> set) {
|
||||
|
||||
@@ -926,7 +926,7 @@ public abstract class WallProvider {
|
||||
|
||||
long sqlHash = sqlStat.getSqlHash();
|
||||
if (sqlHash == 0) {
|
||||
sqlHash = Utils.murmurhash2_64(sql);
|
||||
sqlHash = Utils.fnv_64(sql);
|
||||
sqlStat.setSqlHash(sqlHash);
|
||||
}
|
||||
sqlStatValue.setSqlHash(sqlHash);
|
||||
|
||||
Reference in New Issue
Block a user