camlzip icon indicating copy to clipboard operation
camlzip copied to clipboard

Add bigstring interfaces for deflate/inflate

Open Laakeri opened this issue 7 years ago • 5 comments

Add {deflate,inflate}_bigstring similar to {delfate,inflate} that read from / write to bigstrings instead of bytes.

bigstring is defined as: type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t See https://github.com/ocaml/ocaml/blob/trunk/bytecomp/lambda.ml#L138

The Z_BUF_ERROR fix (GPR #6) is included in the new C functions camlzip_deflate_bigstring and camlzip_inflate_bigstring.

Laakeri avatar Jul 27 '17 12:07 Laakeri

I know some projets use "bigstrings" as out-of-heap buffers, and others to work around the length limitation on strings on 32-bit platforms. So, this is a reasonable proposal. On the other hand I note that only the low-level primitives are provided for bigstrings but not the high-level APIs in modules Zip and Gzip. Just to convince myself that this is really what we want, could you tell me about the intended usage scenario for these new primitives?

xavierleroy avatar Jul 28 '17 14:07 xavierleroy

In the intended use case we compress/uncompress an infinite stream of data that uses bigstrings as buffers.

Laakeri avatar Jul 28 '17 16:07 Laakeri

I would also like this (in the high level API's) so I can unzip things that aren't files (HTTP responses and other things in memory).

brendanlong avatar Jan 18 '18 23:01 brendanlong

@brendanlong I wrote this somewhat hacked together library on top of cryptokit's zlib support to handle in-memory g(un)zip handling of strings. It may be useful to you until something better is available.

hcarty avatar Jan 19 '18 00:01 hcarty

Is there anything I can do to help get this merged?

XVilka avatar Aug 20 '18 14:08 XVilka