in reply to Data structure for statistics

Just my 2 cents:
I could save quite some memory by using pack and unpack with c on a bytestring, as I expect the number of hits per second to be well below 100.

Well, if you plan on doing it in plain perl... You can use larger buckets than pack's 'C' (not 'c', no reason for it to be signed), for example short 'v' or long 'V', or their 'n'/'N' counterparts.

And don't forget about vec, in case you want to read/update individual slots.

If you don't care about older data except when in processed in bulk, then note that pack also supports BER compressed integers ('w'), which makes byte strings of minimal length, storing up to 7 bits of useful data per byte. Unfortunately it makes looking up an individual number by array index a bit hard.

And finally, you can abuse UTF8, and store this array of integers as a string of characters, which can easily hold larger values than 255 per character!

Replies are listed 'Best First'.
Re^2: Data structure for statistics
by salva (Canon) on Oct 06, 2008 at 11:07 UTC