Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Simply coincidence, I suspect... there are <em>bound</em> to be collisions, and in this case it looks like the relevant different bits in the first value are being lost, effectively.</p> <p>However, it shouldn't make any difference - anything using hash codes <em>must</em> cope with collisions.</p> <p>EDIT: It's just the way the hashes happen to be calculated. This code shows what's going on:</p> <pre><code>import java.util.*; public class Test { @SuppressWarnings("unchecked") public static void main (String[] args) { AbstractMap.SimpleEntry[] entries = { new AbstractMap.SimpleEntry("campaignId", 4770L), new AbstractMap.SimpleEntry("campaignId", 4936L), new AbstractMap.SimpleEntry("lazy", true), new AbstractMap.SimpleEntry("lazy", false) }; for (AbstractMap.SimpleEntry entry : entries) { System.out.println(entry + ": " + entry.hashCode()); } } } </code></pre> <p>Results:</p> <pre><code>campaignId=4770: -1318251287 campaignId=4936: -1318251261 lazy=true: 3315643 lazy=false: 3315617 </code></pre> <p>So in one pair the first map has a hash 26 <em>less</em> than the second map, and in another pair the first map has a hash 26 <em>more</em> than the second map.</p> <p><code>AbstractMap</code> just sums hash values (one way of making sure that ordering is irrelevant) so the two end up with the same hash code.</p> <p>It's really down to <code>Boolean.hashCode()</code> which looks like this:</p> <pre><code>return value ? 1231 : 1237; </code></pre> <p>... and <code>Long.hashCode()</code> which looks like this:</p> <pre><code>return (int)(value ^ (value &gt;&gt;&gt; 32)); </code></pre> <p>Given the values they happened to pick in <code>Boolean.hashCode()</code>, if your <code>long</code> values are only 26 apart (or 26 * 2^32 apart) then you'll run into the same thing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload