Version française
Home     About     Download     Resources     Contact us    
Browse thread
zcat vs CamlZip
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] Re: zcat vs CamlZip
Am Dienstag, den 29.08.2006, 15:15 -0400 schrieb Sam Steingold:
> at any rate, do you really expect that using Gzip.input and then 
> searching the result for a newline, slicing and dicing to get the 
> individual input lines, &c &c would be faster?

Ah yes, and there is an easy solution with ocamlnet:

class input_gzip_rec gzip_ch : Netchannels.rec_in_channel =
object(self)
  method input s p l =
    let n = Gzip.input gzip_ch s p l in
    if n = 0 then raise End_of_file;
    n
  method close_in() =
    Gzip.close_in gzip_ch
end


Then use it as follows:

let gz_ch = 
  Netchannels.lift_in (`Rec (new input_gzip gz_in))

let line = gz_ch # input_line()

This adds a buffering layer.

Gerd
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------