Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Long answer: <a href="http://burtleburtle.net/bob/hash/evahash.html#funneling" rel="nofollow">here</a></p> <p>Short answer: <br/>A <strong>funnel</strong> occurs when 2+ keys get hashed to the same value because of an error with the underlying hashing function. Like this:</p> <pre><code>Map&lt;String,Object&gt; myMap = new HashMap&lt;String,Object&gt;(); Thing thing1, thing2; thing1 = new Thing(); thing2 = new Thing(); myMap.put("ab", thing1); myMap.put("ba", thing2); </code></pre> <p>If there is an inherent flaw in the hashing function used by <code>HashMap&lt;K,V&gt;</code>, a "funnel" could occur where the keys <code>ab</code> and <code>ba</code> both map to, say, <code>thing1</code>.</p> <p>Think of a funnel as an actual funnel: multiple inputs get <em>funneled</em> into the same place.</p> <p><strong>Edit</strong><br/> If a hash function is flawed and does contain funnels, then a way to minimize their occurrence is to set the size of the table to being a prime number.</p> <p>This is because, in terms of being a "class" (category) of numbers, prime numbers have the least amount of factors. According to that article, funnels occur when a given key is a factor or multiple of the size of the table. So if we set the table size to 100 (not a prime number), we introduce the <em>possibility</em> of funneling when the provided key is any <em>factor of 100</em>: 1, 2, 4, 5, 10, ..., 100, 200, 300, etc.</p> <p>But if we make the size of the table to a prime, say, 101... then the only <em>possibility</em> of a funnel occurs at: 1, 101, 202, 302, etc. We've greatly reduced the <em>possibility</em> of a funnel.</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.
 

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