I am doing some calculations based on the graph generated by hyperlinks on the web. I have one huge file (~500GB), in which the n
th line corresponds to all nodes in the graph adjacent to the n
th node; the file is a list of adjacency lists.
For my calculations I need to access lines in this file at random based on my calculations, since obviously this data is way to much for any more advanced data structure. The question is, what is the fastest way to access lines in such a huge file at random?
The way I see it, I have a few options:
- linear search
- try my luck with Tie::File
- find the longest line, pad each line so all lines are the same length, and use byte offsets to access lines with seek (or something)
- find number of bytes on each line, maintain auxiliary data structure (BerkeleyDB?) storing byte to line offset
Ordinarily I would try to do this in C++, but since I discovered perl, I have a high level of faith in its capabilities. This is my first post, I welcome your advice!
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.