max length of keys? 
Author Message
 max length of keys?

what is the maximum length of keys of hashes I can use? I couldnt find it
in the documentation or any books I own.

klaus



Tue, 02 Mar 2004 13:00:51 GMT  
 max length of keys?

Quote:

>what is the maximum length of keys of hashes I can use? I couldnt find it
>in the documentation or any books I own.

The built-in limit seems to be 2^32 -2 (or -1, if it hasn't got to be
zero terminated). However, you should consider that the key length has
some influence on the access speed - the longer the key, the longer it
takes to compute its internal hash value. And if you have many long
keys, you may also have to factor in an even greater penalty when you
have keys with the same internal hash value.

HTH,
--

split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while



Tue, 02 Mar 2004 13:36:34 GMT  
 max length of keys?
Don't know but like make Perl things I guess it is only limited by your
system resources.  I wrote the following script to do a rough test and found
that above 6 orders of magnitude (that's 16777216 characters in length)
things get very slow.

In the real world I would think that if you need to use keys longer than a
few of hundred characters you're there's probably a better way to do things.

for my $order (1..6) {
  my $key = '.' x (0x10 ** $order);
  $h{$key} = length($key);

Quote:
}

foreach (keys %h) {
  print length($_), " => ", $h{$_}, "\n";
Quote:
}



Tue, 02 Mar 2004 14:23:59 GMT  
 max length of keys?
Perhaps you could store a digest of the key as the hash key and store the
data as a nested hash?

--
  Simon Oliver


Quote:
> Don't know but like make Perl things I guess it is only limited by your
> system resources.  I wrote the following script to do a rough test and
found
> that above 6 orders of magnitude (that's 16777216 characters in length)
> things get very slow.

> In the real world I would think that if you need to use keys longer than a
> few hundred characters there's probably a better way to do things.

> for my $order (1..6) {
>   my $key = '.' x (0x10 ** $order);
>   $h{$key} = length($key);
> }

> foreach (keys %h) {
>   print length($_), " => ", $h{$_}, "\n";
> }



Tue, 02 Mar 2004 14:52:35 GMT  
 max length of keys?
thanks to all who helped. my keys won't get that big, but good to know how
far you can go...
Quote:

> Perhaps you could store a digest of the key as the hash key and store the
> data as a nested hash?



Tue, 02 Mar 2004 19:09:11 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. DOS Perl: max input line length?

2. max. length of perl regexp

3. DBI --max length of insert (ingres)

4. Max. Length of an Array

5. Max length of a string

6. max length of data in sdbm record

7. max international, mlm business opportunity, MaxGXL, network marketing opportunity , Max GXL, MaxWLX, Max N-fuze, Max WLX,

8. Error in LWP [Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16]

9. Error in LWP [Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16]

10. Bad arg length for Socket::unpack_sockaddr_in, length is 0

11. Error in LWP [Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16]

 

 
Powered by phpBB® Forum Software