4343 */
4444public final class MurmurHash3 {
4545
46+ /** TODO Replace on Java 8 with Long.BYTES. */
47+ private static final int LONG_BYTES = Long .SIZE / Byte .SIZE ;
48+
49+ /** TODO Replace on Java 8 with Integer.BYTES. */
50+ private static final int INTEGER_BYTES = Integer .SIZE / Integer .SIZE ;
51+
52+ /** TODO Replace on Java 8 with Short.BYTES. */
53+ private static final int SHORT_BYTES = Short .SIZE / Short .SIZE ;
54+
4655 // from 64-bit linear congruential generator
4756 public static final long NULL_HASHCODE = 2862933555777941757L ;
4857
@@ -105,7 +114,7 @@ public static int hash32(long l0, int seed) {
105114 hash = mix32 ((int ) r0 , hash );
106115 hash = mix32 ((int ) (r0 >>> 32 ), hash );
107116
108- return fmix32 (Long . BYTES , hash );
117+ return fmix32 (LONG_BYTES , hash );
109118 }
110119
111120 /**
@@ -126,7 +135,7 @@ public static int hash32(long l0, long l1, int seed) {
126135 hash = mix32 ((int ) (r1 ), hash );
127136 hash = mix32 ((int ) (r1 >>> 32 ), hash );
128137
129- return fmix32 (Long . BYTES * 2 , hash );
138+ return fmix32 (LONG_BYTES * 2 , hash );
130139 }
131140
132141 /**
@@ -237,7 +246,7 @@ public static long hash64(byte[] data) {
237246 public static long hash64 (long data ) {
238247 long hash = DEFAULT_SEED ;
239248 long k = Long .reverseBytes (data );
240- int length = Long . BYTES ;
249+ int length = LONG_BYTES ;
241250 // mix functions
242251 k *= C1 ;
243252 k = Long .rotateLeft (k , R1 );
@@ -259,7 +268,7 @@ public static long hash64(long data) {
259268 */
260269 public static long hash64 (int data ) {
261270 long k1 = Integer .reverseBytes (data ) & (-1L >>> 32 );
262- int length = Integer . BYTES ;
271+ int length = INTEGER_BYTES ;
263272 long hash = DEFAULT_SEED ;
264273 k1 *= C1 ;
265274 k1 = Long .rotateLeft (k1 , R1 );
@@ -289,7 +298,7 @@ public static long hash64(short data) {
289298 hash ^= k1 ;
290299
291300 // finalization
292- hash ^= Short . BYTES ;
301+ hash ^= SHORT_BYTES ;
293302 hash = fmix64 (hash );
294303 return hash ;
295304 }
0 commit comments