tarantool / tarantool

Get your data in RAM. Get compute close to data. Enjoy the performance.
https://www.tarantool.io
Other
3.4k stars 379 forks source link

[msgpack]: streaming deserialization #1812

Open zloidemon opened 8 years ago

zloidemon commented 8 years ago

Support streaming deserialization for msgpack.

Streaming deserialization

# deserialize objects from an IO
u = MessagePack::Unpacker.new(io)
u.each do |obj|
  # ...
end

# event-driven deserialization
def on_read(data)
  @u ||= MessagePack::Unpacker.new
  @u.feed_each(data) {|obj|
     # ...
  }
end

python Section Streaming unpacking

import msgpack
from io import BytesIO

buf = BytesIO()
for i in range(100):
   buf.write(msgpack.packb(range(i)))

buf.seek(0)

unpacker = msgpack.Unpacker(buf)
for unpacked in unpacker:
    print unpacked

golang

rtsisyk commented 7 years ago

The idea is good, but we currently doesn't have enough time for it :(