Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Displaying/buffering huge text files discusses some index techniques to speed up picking random lines out of a huge file.

The OP in that thread was able to index a 100MB file with ~6 million lines in seconds and pick out random lines in milliseconds by pre-indexing every 1000 lines.

If your 1TB file had avg 80 characters per line, you'd have 13 billion lines. If you indexed every 1000 lines, you could index 13 million lines. At 8 bytes per index point, that would be 100MB for the index.

You pre-index by reading the entire file, and every 1000 lines, write the file position to your index file.

Then, for example, to find line 12345, you divide that by 1000, and read the 12'th index position in the index (12*8). Then seek to that position in the big file and start reading. After 345 lines you're at your position.

You can tune the 1000 to trade off speed and space.


In reply to Re: Read Some lines in Tera byte file by ctilmes
in thread Read Some lines in Tera byte file by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2024-04-18 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found