Hi, this is very valuable post, I appreciate your input.
Yes, I tried Storable first, hash solution is faster.
I think it's worth to explore your solution with arrays, or some kind of
trees in more detail.
Few explanations:
The hash structure us never rebuilt. It's static (use constant), the data never changes.
The issue is: to import a list of unknown phone numbers, and based on the area code and 3 or 4 digit prefix, determine the name of carrier for this phone number.
Carrier names (or rather IDs) are kept in a hash of hashes (two level) - that's the structure that is used for lookups, and is big in size. First 'index' level is area code, second one is 3 or 4 digit prefix.
Hash is used for lookups only. The phone data is stored somewhere else (it happens to be object data store based on Storable).
With hashes, the speed of the lookup is pretty good, I have no numbers but:
reading 500k of CSV with 12k phone numbers,
parsing it, doing carrier lookup for each single number, removing redundant numbers and storing the numbers with carrier info in the data store takes now 14s, which is sufficient.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.