comp.lang.ada
 help / color / mirror / Atom feed
* Resizing Charles Map
@ 2004-09-29 11:18 Alex R. Mosteo
  2004-09-29 13:13 ` Matthew Heaney
  0 siblings, 1 reply; 2+ messages in thread
From: Alex R. Mosteo @ 2004-09-29 11:18 UTC (permalink / raw)


Hi,

I'm using a Charles Map (Hashed strings) to hold a monotonic increasing 
collection of objects. It will contain thousands of them, and while the 
upper limit is unknown, I think that it rarely will reach, for example, 
a million. Is there something that makes not recommendable to issue a

Resize (Map, Natural'Last)

at start?



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Resizing Charles Map
  2004-09-29 11:18 Resizing Charles Map Alex R. Mosteo
@ 2004-09-29 13:13 ` Matthew Heaney
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Heaney @ 2004-09-29 13:13 UTC (permalink / raw)


"Alex R. Mosteo" <devnull@mailinator.com> writes:

> I'm using a Charles Map (Hashed strings) to hold a monotonic
> increasing collection of objects. It will contain thousands of them,
> and while the upper limit is unknown, I think that it rarely will
> reach, for example, a million. Is there something that makes not
> recommendable to issue a Resize (Map, Natural'Last) at start?

That will preallocate the hash table array to a length of >=
Natural'Last.  That's very big, so there's a good chance the allocation
will fail.

If you think the upper limit is around 1 million, then you'd be better
off specifying that as the resize value.

Better yet, if your map can contain thousands of items, then just use a
resize value of 1000 or 10_000 or 50_000 or whatever.  And then let the
map expand automatically in the rare case of more items than that.

Realize that expansion is automatic, so you don't need to manually
resize unless you're trying to optimize away expansion (which is
admittedly expensive, if the number of items is large).  On the other
hand, if you allocate a very large hash table, then that requires a
large chunk of contiguous virtual memory addresses.  So you have to find
the right balance between too many rehashing events, and too much
memory.

I recommend you join the charles.tigris.org mailing lists, and post
questions like this there.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-29 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-29 11:18 Resizing Charles Map Alex R. Mosteo
2004-09-29 13:13 ` Matthew Heaney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox