in reply to Re: Unsigned 64-bit integer as Judy key
in thread Unsigned 64-bit integer as Judy key

Thanks everyone for answers.

https://metacpan.org/release/JJORE/Judy-0.41/source/typemap

oh, but that explains it all. The argument is treated by default and by design as signed IV. Which is a bug in Perl Judy distribution, as very strange as it is. I understand it is "0-dot-something" version, but it's strange and sad this wasn't noticed in 10 years. Conditionals starting from line #88 should first check if $arg is an UV.

For example:

>perl -MDevel::Peek -E "Dump 1<<63" SV = IV(0x3e42b48) at 0x3e42b58 REFCNT = 1 FLAGS = (PADTMP,IOK,READONLY,PROTECT,pIOK,IsUV) UV = 9223372036854775808

How can I check for IsUV flag in XS? Can't find it in perlguts. Hopefully, this easy fix in typemap file won't break anything else.

Replies are listed 'Best First'.
Re^3: Unsigned 64-bit integer as Judy key
by Anonymous Monk on Dec 07, 2022 at 21:56 UTC

    so I changed that line #88 to

    if ( !SvIsUV($arg) && SvIOK($arg) && SvIV($arg) < 0 ) {

    now Judy installs OK with its tests, and a test I posted in OP passes OK. Actually, it's all about 11148465 meditation; I knew Judy technology is amazing and just wanted to check this yet again. With latest llil2d.pl I get

    llil2d start get_properties : 10 secs sort + output : 21 secs total : 31 secs

    and 2263M of htop's RES, with my Judy script:

    my_test start get_properties: 16 secs sort + output: 21 secs total: 37 secs

    and 378M of htop's RES. And like I said (in my plan outline there) "words" are not stored in RAM (suppose they are long strings) but read again while writing output, hence relatively long time in 2nd row with almost instantaneous sort by Sort::Packed. I'll post to that thread later.

      I suspect that the changes doesn't make it stop considering 9223372036854775808 equal to -9223372036854775808.

        Of course not.

        $ perl -MDevel::Peek -E 'Dump $_ for 1<<63,-(1<<63)' SV = IV(0x559e408d8210) at 0x559e408d8220 REFCNT = 1 FLAGS = (IOK,pIOK,IsUV) UV = 9223372036854775808 SV = IV(0x559e408d83c0) at 0x559e408d83d0 REFCNT = 1 FLAGS = (IOK,pIOK) IV = -9223372036854775808 $ perl -MJudy::L=Set -E 'say Set($j, $_, 1) for 1<<63,-(1<<63),0' 94434583711008 Coercing -9223372036854775808 to 0. Can't use negative values as keys. + at -e line 1. 94434579767256 94434579767256