catwell / luajit-msgpack-pure Goto Github PK
View Code? Open in Web Editor NEWMessagePack for LuaJIT (using FFI, no bindings, V4 API)
License: MIT License
MessagePack for LuaJIT (using FFI, no bindings, V4 API)
License: MIT License
2018/03/02
19:13:45 [error] 31794#0: *287 lua entry thread aborted: runtime error: /data/web/openresty-websocket/resty/luajit-msgpack-pure.lua:433: unimplemented
stack traceback:
coroutine 0:
[C]: in function 'error'
/data/web/openresty-websocket/resty/luajit-msgpack-pure.lua:433: in function 'dynamic'
/data/web/openresty-websocket/resty/luajit-msgpack-pure.lua:567: in function 'unpack'
/data/web/openresty-websocket/libs/pushs.lua:77: in function 'unpack'
/data/web/openresty-websocket/websocket.lua:180: in function 'run'
content_by_lua(nginx.conf:106):3: in function <content_by_lua(nginx.conf:106):1>, client: 116.115.11.21, server: ngx.p.qc.com, request: "GET /?order=ccf8f35a2bff&user=2d7zsk&ver=372&reconnect=1&ingame=0 HTTP/1.1", host: "api2.qc.com:4396"
`
nginx_error. log a lot of errors. What should I do?
I maintain a pure javascript implementation of msgpack for node.js and the browser. I've extended the msgpack format to allow the js type undefined
as well as binary blobs (since js strings are unicode and can't hold arbitrary binary data).
I noticed that you extended the format to support nan
, inf
, and -inf
. Since JavaScript also has these values, (and I want to use your library for my luvit project) I propose we merge our extensions to become compatible.
What do you think?
Rob Pike says checking for endianness is wrong and I tend to agree. Moreover I fear my code doesn't work on big endian platforms (it's never been tested).
http://commandcenter.blogspot.fr/2012/04/byte-order-fallacy.html
Otherwise packing this would be disastrous:
{
[0] = 1,
[1000000] = 1,
}
The heuristic should be: integer keys are continuous and start at one.
Moreover current code is probably broken for arrays that start at 0 or negative numbers.
for a better time resolution in benchmark, use require'socket'.gettime()
instead of require'os'.clock()
I don't know if this would work with luaffi -> try it someday.
A patch for convenient reuse of a buffer, and concatenating msgs without .. on many strings.
--packer functions
local pack_meta
pack_meta.__index = pack_meta
-- pack more stuff to the buffer
function p:pack(data)
buffer = self
packers.dynamic(data)
end
-- reuse the buffer for a new set of batched msg
function p:reset()
self.size = 0
end
local function get_pack_buffer()
local tbl = {}
sbuffer_init(tbl)
ffi.gc(tbl.data, ffi.C.free)
return setmetatable(tbl,pack_meta)
end
return {
pack_many = get_pack_buffer,
pack = ljp_pack,
unpack = ljp_unpack,
set_fp_type = set_fp_type,
set_table_classifier = set_table_classifier,
packers = packers,
unpackers = unpackers,
}
msgpack ruby gem was not using str 8 at all up to version 0.5, but since 0.6 it has started to use it. New users will get a failure.
msgpack 0.6:
2.1.2 :004 > MessagePack.pack(' ' * 255)
=> "\xD9\xFF "
msgpack 0.5.11:
2.1.2 :002 > MessagePack.pack(' ' * 255)
=> "\xDA\x00\xFF
Currently numbers are serialized as doubles. There should be an option to serialize them as floats to save memory at the expense of precision.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.