18
18
* Modified by the gRPC Authors
19
19
*/
20
20
21
- package io .grpc .xds ;
21
+ package io .grpc .tp . zah ;
22
22
23
23
import static com .google .common .base .Preconditions .checkArgument ;
24
24
import static com .google .common .base .Preconditions .checkNotNull ;
33
33
* <a href="https://github.com/OpenHFT/Zero-Allocation-Hashing/blob/master/src/main/java/net/openhft/hashing/XxHash.java">
34
34
* OpenHFT/Zero-Allocation-Hashing</a>.
35
35
*/
36
- final class XxHash64 {
37
- static final XxHash64 INSTANCE = new XxHash64 (0 );
36
+ final public class XxHash64 {
37
+ static public final XxHash64 INSTANCE = new XxHash64 (0 );
38
38
39
39
// Primes if treated as unsigned
40
40
private static final long P1 = -7046029288634856825L ;
@@ -47,12 +47,12 @@ final class XxHash64 {
47
47
private final long seed ;
48
48
private final long voidHash ;
49
49
50
- XxHash64 (long seed ) {
50
+ public XxHash64 (long seed ) {
51
51
this .seed = seed ;
52
52
this .voidHash = finalize (seed + P5 );
53
53
}
54
54
55
- long hashLong (long input ) {
55
+ public long hashLong (long input ) {
56
56
input = byteOrder == ByteOrder .LITTLE_ENDIAN ? input : Long .reverseBytes (input );
57
57
long hash = seed + P5 + 8 ;
58
58
input *= P2 ;
@@ -63,15 +63,15 @@ long hashLong(long input) {
63
63
return finalize (hash );
64
64
}
65
65
66
- long hashInt (int input ) {
66
+ public long hashInt (int input ) {
67
67
input = byteOrder == ByteOrder .LITTLE_ENDIAN ? input : Integer .reverseBytes (input );
68
68
long hash = seed + P5 + 4 ;
69
69
hash ^= (input & 0xFFFFFFFFL ) * P1 ;
70
70
hash = Long .rotateLeft (hash , 23 ) * P2 + P3 ;
71
71
return finalize (hash );
72
72
}
73
73
74
- long hashShort (short input ) {
74
+ public long hashShort (short input ) {
75
75
input = byteOrder == ByteOrder .LITTLE_ENDIAN ? input : Short .reverseBytes (input );
76
76
long hash = seed + P5 + 2 ;
77
77
hash ^= (input & 0xFFL ) * P5 ;
@@ -81,22 +81,22 @@ long hashShort(short input) {
81
81
return finalize (hash );
82
82
}
83
83
84
- long hashChar (char input ) {
84
+ public long hashChar (char input ) {
85
85
return hashShort ((short ) input );
86
86
}
87
87
88
- long hashByte (byte input ) {
88
+ public long hashByte (byte input ) {
89
89
long hash = seed + P5 + 1 ;
90
90
hash ^= (input & 0xFF ) * P5 ;
91
91
hash = Long .rotateLeft (hash , 11 ) * P1 ;
92
92
return finalize (hash );
93
93
}
94
94
95
- long hashVoid () {
95
+ public long hashVoid () {
96
96
return voidHash ;
97
97
}
98
98
99
- long hashAsciiString (String input ) {
99
+ public long hashAsciiString (String input ) {
100
100
ByteSupplier supplier = new AsciiStringByteSupplier (input );
101
101
return hashBytes (supplier );
102
102
}
@@ -106,7 +106,7 @@ long hashBytes(byte[] bytes) {
106
106
return hashBytes (supplier );
107
107
}
108
108
109
- long hashBytes (byte [] bytes , int offset , int len ) {
109
+ public long hashBytes (byte [] bytes , int offset , int len ) {
110
110
ByteSupplier supplier = new PlainByteSupplier (bytes , offset , len );
111
111
return hashBytes (supplier );
112
112
}
0 commit comments