[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

seek() in GzipReader

Belorion

11/28/2007 9:52:00 PM

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Looking at RubyDoc for GzipReader (
http://ruby-doc.org/core/classes/Zlib/GzipR...) I notice that there
is no seek() method available, as with IO.seek() or IO.pos=.

Does anyone have any ideas on how to do a traditional seek through a gzip'ed
file using GzipReader?

I notice that there is GzipReader.lineno=(), but, as per this discussion
from about 2 years ago (http://www.ruby-forum.com/...), the purpose
of lineno=() eludes me (since it doesn't actually modify the position for
the next read operation).

I should clarify that the files being read are quite large (as in several
gigabytes), and so loading up the entire file into an Array in memory is not
an option for me.

regards,
Matt

1 Answer

Belorion

11/28/2007 11:00:00 PM

0

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

I realize, now, that there is probably no "meaningful" way to seek through a
compressed file. It would require starting at the beginning of the file,
and counting the bytes as it was uncompressed until the seek point was
reached ... which rather defeats one of the major benefits of seeking in the
first place (to quickly navigate a file).

I could see, perhaps, a mechanism for leaving position bookmarks as one uses
the file, that can then be used later to faster seeking...

Anyway, sorry for the spam!

Matt


On 11/28/07, Belorion <belorion@gmail.com> wrote:
>
> Looking at RubyDoc for GzipReader (
> http://ruby-doc.org/core/classes/Zlib/GzipR...) I notice that there
> is no seek() method available, as with IO.seek() or IO.pos=.
>
> Does anyone have any ideas on how to do a traditional seek through a
> gzip'ed file using GzipReader?
>
> I notice that there is GzipReader.lineno=(), but, as per this discussion
> from about 2 years ago (http://www.ruby-forum.com/...), the purpose
> of lineno=() eludes me (since it doesn't actually modify the position for
> the next read operation).
>
> I should clarify that the files being read are quite large (as in several
> gigabytes), and so loading up the entire file into an Array in memory is not
> an option for me.
>
> regards,
> Matt
>