HADOOP-11221. IdentityHashStore assumes System.identityHashCode() is non-negative. Contributed by Jinghui Wang
This commit is contained in:
parent
fe1f4c64d1
commit
2b5baa6714
|
@ -693,6 +693,9 @@ Release 2.6.0 - UNRELEASED
|
||||||
HADOOP-11250. fix endmacro of set_find_shared_library_without_version in
|
HADOOP-11250. fix endmacro of set_find_shared_library_without_version in
|
||||||
CMakeLists (Yi Liu via Colin P. McCabe)
|
CMakeLists (Yi Liu via Colin P. McCabe)
|
||||||
|
|
||||||
|
HADOOP-11221. IdentityHashStore assumes System.identityHashCode() is
|
||||||
|
non-negative. (Jinghui Wang via szetszwo)
|
||||||
|
|
||||||
Release 2.5.1 - 2014-09-05
|
Release 2.5.1 - 2014-09-05
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -92,9 +92,10 @@ public final class IdentityHashStore<K, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putInternal(Object k, Object v) {
|
private void putInternal(Object k, Object v) {
|
||||||
int hash = System.identityHashCode(k);
|
final int hash = System.identityHashCode(k);
|
||||||
final int numEntries = buffer.length / 2;
|
final int numEntries = buffer.length >> 1;
|
||||||
int index = hash % numEntries;
|
//computing modulo with the assumption buffer.length is power of 2
|
||||||
|
int index = hash & (numEntries-1);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (buffer[2 * index] == null) {
|
if (buffer[2 * index] == null) {
|
||||||
buffer[2 * index] = k;
|
buffer[2 * index] = k;
|
||||||
|
@ -127,9 +128,10 @@ public final class IdentityHashStore<K, V> {
|
||||||
if (buffer == null) {
|
if (buffer == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
final int numEntries = buffer.length / 2;
|
final int numEntries = buffer.length >> 1;
|
||||||
int hash = System.identityHashCode(k);
|
final int hash = System.identityHashCode(k);
|
||||||
int index = hash % numEntries;
|
//computing modulo with the assumption buffer.length is power of 2
|
||||||
|
int index = hash & (numEntries -1);
|
||||||
int firstIndex = index;
|
int firstIndex = index;
|
||||||
do {
|
do {
|
||||||
if (buffer[2 * index] == k) {
|
if (buffer[2 * index] == k) {
|
||||||
|
|
Loading…
Reference in New Issue