HADOOP-10555. Add offset support to MurmurHash. Contributed by Sergey Shelukhin.
This commit is contained in:
parent
6ed8f24041
commit
c7a9cbbdde
|
@ -345,6 +345,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
|
|
||||||
HADOOP-10035. Cleanup TestFilterFileSystem. (Suresh Srinivas via wheat9)
|
HADOOP-10035. Cleanup TestFilterFileSystem. (Suresh Srinivas via wheat9)
|
||||||
|
|
||||||
|
HADOOP-10555. Add offset support to MurmurHash.
|
||||||
|
(Sergey Shelukhin via wheat9)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-11785. Reduce the number of listStatus operation in distcp
|
HADOOP-11785. Reduce the number of listStatus operation in distcp
|
||||||
|
|
|
@ -36,9 +36,13 @@ public class MurmurHash extends Hash {
|
||||||
public static Hash getInstance() {
|
public static Hash getInstance() {
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hash(byte[] data, int length, int seed) {
|
public int hash(byte[] data, int length, int seed) {
|
||||||
|
return hash(data, 0, length, seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hash(byte[] data, int offset, int length, int seed) {
|
||||||
int m = 0x5bd1e995;
|
int m = 0x5bd1e995;
|
||||||
int r = 24;
|
int r = 24;
|
||||||
|
|
||||||
|
@ -47,7 +51,7 @@ public class MurmurHash extends Hash {
|
||||||
int len_4 = length >> 2;
|
int len_4 = length >> 2;
|
||||||
|
|
||||||
for (int i = 0; i < len_4; i++) {
|
for (int i = 0; i < len_4; i++) {
|
||||||
int i_4 = i << 2;
|
int i_4 = offset + (i << 2);
|
||||||
int k = data[i_4 + 3];
|
int k = data[i_4 + 3];
|
||||||
k = k << 8;
|
k = k << 8;
|
||||||
k = k | (data[i_4 + 2] & 0xff);
|
k = k | (data[i_4 + 2] & 0xff);
|
||||||
|
@ -67,6 +71,7 @@ public class MurmurHash extends Hash {
|
||||||
int left = length - len_m;
|
int left = length - len_m;
|
||||||
|
|
||||||
if (left != 0) {
|
if (left != 0) {
|
||||||
|
length += offset;
|
||||||
if (left >= 3) {
|
if (left >= 3) {
|
||||||
h ^= (int) data[length - 3] << 16;
|
h ^= (int) data[length - 3] << 16;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue