lua-cmsgpack icon indicating copy to clipboard operation
lua-cmsgpack copied to clipboard

Support reading from FILE*

Open agladysh opened this issue 13 years ago • 2 comments

I have a large chunk of data in a file, encoded with msgpack, and I want to load it to Lua.

I do not want to pay for overhead of interning this file as a string into Lua state. Instead I want a lua-cmsgpack call that would load my data from file directly.

Is it possible?

I realize that this is somewhat a corner case for lua-cmsgpack, as it is persistence and not message passing, but anyway — would be quite useful.

agladysh avatar Apr 04 '12 09:04 agladysh

This (i.e. msgpack.unpack_from_file("filename")) should be easily doable with memory mapped files BTW.

agladysh avatar Apr 04 '12 21:04 agladysh

@agladysh try: msgpack.unpack( io.open('filename', 'rb'):read('*all') )

denisdemaisbr avatar Apr 28 '17 20:04 denisdemaisbr