caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dhek Uir <dhekuir@gmail.com>
To: Drup <drupyog+caml@zoho.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Simple compression library
Date: Mon, 2 Feb 2015 18:00:56 +0100	[thread overview]
Message-ID: <CAJn4uc4RdwLnABxwydi0O628NHeKrBfi5QZGmS=SwXZaR1_0TQ@mail.gmail.com> (raw)
In-Reply-To: <54CFAA41.20706@zoho.com>

[-- Attachment #1: Type: text/plain, Size: 2468 bytes --]

But since camlzip does not have an input_value function, it seems I must
set up a buffer to decompress the data, then use Marshal to obtain input
data from the decompressed buffer. But if I use Marshal.from_string to read
the decompressed buffer, then I need to keep track of its position (which
is not returned by Marshal.from_string), and check whether the buffer is
nearly empty, so that I may need to re-read from the compressed in_channel,
etc, etc. Did I miss the right function again?

It seems that Netgzip would require some similar amount of effort, from
what I'm seeing (I see no "channel -> 'a" functions in the API).

Thanks for the serialization tips, though I don't care much about the
safety, I have strong assumptions about the how the data will be produced
and consumed.


On Mon, Feb 2, 2015 at 5:48 PM, Drup <drupyog+caml@zoho.com> wrote:

>  input/output_value are using Marshal under the hood, so it's going to be
> the same.
>
> However, be aware that marshall (and the _value functions) are quite
> unsafe. If you have an error in the data (or your change the representation
> in OCaml), you will have ... surprising errors (including segfaults).
>
> There are plenty of safer solutions for serialization (deriving, sexp,
> yojson, to name a few).
>
> Le 02/02/2015 17:05, Dhek Uir a écrit :
>
>
>
> On Mon, Feb 2, 2015 at 4:43 PM, Jacques-Henri Jourdan <
> jacques-henri.jourdan@inria.fr> wrote:
>
>> Le 02/02/2015 16:39, Dhek Uir a écrit :
>>  > I'm looking for a compression library such as camlzip to read/write
>> > compressed files (any lossless compression algorithm is fine), but
>> > having a function similar to Pervasives.output_value, which does not
>> > seem to be available in camlzip (and I do not see how I could easily
>> > implement it).
>> >
>> > Would it be simple to modify camlzip to add this function? I believe
>> > that if this were the case, then it would already have been done, but
>> > I might be wrong.
>> >
>> > Otherwise, is there another OCaml library with an API very similar to
>> > Pervasives'? I'd prefer a lightweight solution (avoiding Core and
>> > Batteries) if possible.
>>
>>  Can't you do Marshal.to_string, and then use Camlzip on the generated
>> string ?
>>
>>
> Indeed, I can. I believe the hard part is actually the input_value
> operation.
>  But I haven't looked enough into Marshal, maybe my solution can be found
> there.
>
>
>

[-- Attachment #2: Type: text/html, Size: 4254 bytes --]

  reply	other threads:[~2015-02-02 17:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 15:39 Dhek Uir
2015-02-02 15:43 ` Jacques-Henri Jourdan
2015-02-02 16:05   ` Dhek Uir
2015-02-02 16:48     ` Drup
2015-02-02 17:00       ` Dhek Uir [this message]
2015-02-02 17:38         ` David Allsopp
2015-02-02 17:53           ` Dhek Uir

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJn4uc4RdwLnABxwydi0O628NHeKrBfi5QZGmS=SwXZaR1_0TQ@mail.gmail.com' \
    --to=dhekuir@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=drupyog+caml@zoho.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).