You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a problem with the computation of our hashkeys generated very frequent collisions, and thus bigger buckets. We then had an exception using UnifiedSet.retainAll().
I had a look at the code and found the problem: if i>3 then ChainedBucket.remove(i) calls removeLongChain(i-3), but the switch statement in removeLongChain throws an exception if i-3 > 3. Removing an object in the third chained bucket is thus not possible. It surely did not occur until now, because such heavy collisions are unlikely to happen.
Here is a "minimal change" fix:
privatevoidremoveLongChain(ChainedBucketoldBucket, inti)
{
do
{
ChainedBucketbucket = (ChainedBucket) oldBucket.three;
switch (i)
{
case0:
bucket.zero = bucket.removeLast(0);
return;
case1:
bucket.one = bucket.removeLast(1);
return;
case2:
bucket.two = bucket.removeLast(2);
return;
case3:
if (bucket.threeinstanceofChainedBucket)
{
i -= 3;
oldBucket = bucket;
continue;
}
bucket.three = null;
return;
default:
// new code starts here (similar to case 3)if (bucket.threeinstanceofChainedBucket)
{
i -= 3;
oldBucket = bucket;
continue;
}
// new code ends herethrownewAssertionError();
}
}
while (true);
}
Here is a small exemple that reproduces the problem (using some of the strings wth colliding hash from issue #26):
Hi there,
a problem with the computation of our hashkeys generated very frequent collisions, and thus bigger buckets. We then had an exception using UnifiedSet.retainAll().
I had a look at the code and found the problem: if
i>3
thenChainedBucket.remove(i)
callsremoveLongChain(i-3)
, but the switch statement inremoveLongChain
throws an exception ifi-3 > 3
. Removing an object in the third chained bucket is thus not possible. It surely did not occur until now, because such heavy collisions are unlikely to happen.Here is a "minimal change" fix:
Here is a small exemple that reproduces the problem (using some of the strings wth colliding hash from issue #26):
Thanks for the great collections, I hope this helps!
Vincent.
The text was updated successfully, but these errors were encountered: