Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Further on buffering huge text files

by halley (Prior)
on Mar 09, 2005 at 17:07 UTC ( [id://437962]=note: print w/replies, xml ) Need Help??


in reply to Further on buffering huge text files

This looks to be exactly the same kind of thing that emacs calls "selective display." In that editor mode, you can hide any image that is indented more than N spaces. Groups of one or more hidden lines appear in the editor as a ... mark appended to the previous visible line. Your cursor moves right over the elipses, you can select everything including an elipses, you can delete or copy chunks that include elipses, etc.

The principle can be extended to any sort of do-or-don't-show filter, of course.

  • You will need to read through the whole file once.
  • You will need to index line positions, either indexing all lines, or filtered lines.
  • If you're threaded, you can index in a separate thread.
    Fill the display once the indexer has indexed enough to fill the first page, but you may need the display to "wait" for the indexer sometimes if you let the user move around before the indexer has finished.
  • You can save the index to a file if the filtration is too slow to perform often.
  • You can "index the index" for intensely huge sources, where even the index would outstrip memory available.
  • When the user wants to scroll into areas not on the screen, use your index to re-read the applicable portions.
  • When the user wants to see things that are hidden, use your index to re-read the applicable portions.

Think of your index as being a hash of weak references to strings, if you know what that means. If the memory is tight, don't keep the strings around, but if they're needed again, then don't hesitate to reconstruct them.

--
[ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://437962]
help
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