BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
If you have 150e6 64-bit values to store for efficient lookup, perl's hashes(~14GB) and arrays(~5GB) are very expensive of memory, and a bitmap is out of the question.
The array is feasible, but to do lookups (binary search) requires it be sorted, and that's quite expensive for this size of array, even when using one of salva's in-place, XS modules.
The values are generated at runtime, and discarded at program end, so DBs are pointless. Even an in-memory sqlite DB which stores numbers as strings is off the cards.
I'm going to have to drop into Inline::C for this for both space and performance reasons.
A straight C array of 64-bit ints is ~1.2GB which is fine; but again sorting it so I can to O(logN) lookups is expensive.
I keep thinking about heaps (or Beaps or B-heaps or other variations), structures that "order" the values as they are inserted; but once built, can any of them be used for efficient (O(logN) or better) lookup?
Wikipedia isn't giving me much on the subject of lookup/searches.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Heap structure for lookup?
by hdb (Monsignor) on May 27, 2015 at 08:24 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 08:43 UTC | |
by hdb (Monsignor) on May 27, 2015 at 09:09 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 09:28 UTC | |
by hdb (Monsignor) on May 27, 2015 at 10:44 UTC | |
| |
Re: Heap structure for lookup?
by dave_the_m (Monsignor) on May 27, 2015 at 09:21 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 09:41 UTC | |
Re: Heap structure for lookup?
by RichardK (Parson) on May 27, 2015 at 09:18 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 09:49 UTC | |
by RichardK (Parson) on May 27, 2015 at 10:26 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 13:06 UTC | |
Re: Heap structure for lookup?
by ohcamacj (Beadle) on May 27, 2015 at 21:04 UTC | |
by BrowserUk (Patriarch) on May 27, 2015 at 22:54 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |