Skip to content

Support for concatenated objects #10

Closed

Description

@catwell

MessagePack allows binary blobs composed of several valid MessagePack objects concatenated. This is the case of the official MessagePack test data for instance (https://github.com/msgpack/msgpack/tree/master/test).

To support this kind of data you need an interface that:

  • returns the first object of the blob and the byte offset where the decoding stopped,
  • (optionally) allows you to specify an offset where the decoding should start.

An advantage of implementing this is that it would make it possible to use the "official" test data to test this module.

Activity

  1. antirez commented on Feb 20, 2012

    @antirez
    Owner

    I like that, thanks.

    that's the idea for the API change:

    • cmsgpack.unpack() works like now with one argument, returning just the decoded object, and starting at index 0.
    • If a second argument is passed, it is used to start the decoding at the specified byte. Also two values are returned instead of one, that is the decoded object, and the offset at which the decoding ended (offset of next object).
    • Also, no error is returned in this "two arguments" mode if not all the string is consumed of course.

    This makes the API for the obvious case, obvious. The more complex API will impact only more demanding users.

    Thanks for the suggestion,
    Salvatore

  2. catwell commented on Feb 20, 2012

    @catwell
    Author

    This API would work. I do the opposite for return values (offset, object) and I return nil in the offset if the decoding failed (which I use for error checking) but that's a matter of style. In the context of Redis your ordering is simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions