BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone tell me what the paired integers (n:m) shown after the ARRAY in the dump of a hash mean?

SV = RV(0xcd16be0) at 0xcd16bd0 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x177aa0 SV = PVHV(0x3d857b0) at 0x177aa0 REFCNT = 2 FLAGS = (PADMY,SHAREKEYS) ARRAY = 0xa1a0058 (0:406794, 1:382690, 2:182129, 3:58962, 4:14525 +, 5:2894, 6:489, 7:84, 8:8, 10:1) ##HERE hash quality = 99.2% KEYS = 1000000 FILL = 641782 MAX = 1048575 RITER = -1 EITER = 0x0 Elt "ABTMEA" HASH = 0xf00000 SV = NULL(0x0) at 0x7830258 REFCNT = 1 FLAGS = () Elt "AAYGXV" HASH = 0xf1000000 SV = NULL(0x0) at 0x61b8a90 REFCNT = 1 FLAGS = () Elt "AAUDDR" HASH = 0xf1000000 SV = NULL(0x0) at 0x600dc50 REFCNT = 1 FLAGS = ()

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

Replies are listed 'Best First'.
Re: Devel::Peek hashref.
by salva (Canon) on Sep 23, 2010 at 17:01 UTC
    Devel::Peek::Dump is just a wrapper around dump.c Perl_do_sv_dump function, and after examining it I think it is an histogram of the keys per hash slot.

    For your sample hash it means that there are 406794 slots with 0 keys, 382690 slots with 1 key, 182129 slots with 2 keys, etc.

    That also means, that your idea of sorting the keys in every slot and then performing a merge is not going to have a great performance... though, you could degrade the hash to use just one slot while you are processing it.

      Ah yes. That makes sense.

      FILL = 641782 + 0:406794 = MAX = 1048575

      sum( 1:382690, 2:182129, 3:58962, 4:14525, 5:2894, 6:489, 7:84, 8:8, 10:1 ) == FILL = 641782.

      Thanks.

      This hash contains just test data. Namely 'AAAAAA'++ 1e6 times. So, (hopefully), this distribution is not representative of real data :)


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Devel::Peek hashref.
by ikegami (Patriarch) on Sep 23, 2010 at 17:02 UTC

    x:y means there's y elements in slot x of a bucket, I think.

    1 item requires exactly 10 comparisons to find.
    8 items requires exactly 8 comparisons to find.
    ...

    Update: No, the above is wrong.

    x:y means there's y buckets with exactly x elements.

    1 item requires exactly 10 comparisons to find.
    1 items require exactly 9 comparisons to find.
    8+1 items require exactly 8 comparisons to find.
    ...
    382690+182129+58962+14525+2894+489+84+8+1 items require exactly 1 comparison to find.
    406794 buckets are empty.

Re: Devel::Peek hashref.
by Anonymous Monk on Sep 23, 2010 at 16:58 UTC