Code Monkey home page Code Monkey logo

Comments (5)

tcoram avatar tcoram commented on July 22, 2024

Not so much as overlooked as (currently) avoided. I've yet to find an (easy) way to coerce Lua to encode/decode little endian ordered doubles. I left the function undefined so there is no ambiguity as to what will happen when you try to encode a double.

from bson-lua.

daurnimator avatar daurnimator commented on July 22, 2024

Have a look at my code at https://github.com/daurnimator/mongol/blob/master/mongol/ll.lua which is what most people end up using

from bson-lua.

tcoram avatar tcoram commented on July 22, 2024

Clever :)
I've resisted luaJIT/ffi because I wanted to keep the implementation pure (I've got some embedded hosts I'm using), but I never thought of exploiting the Lua bytecode!

However, this approach would be a problem with big-endian machines, wouldn't it? Hmm... BSON specifies little-endian encoding and I guess just about all modern CPUs are little endian these days (ARM defaults to this, Intel, etc), so it should be portable most everywhere...

Mind if I incorporate your technique?

from bson-lua.

daurnimator avatar daurnimator commented on July 22, 2024

sure/go for it.

IEEE754 floating point numbers do not have an endianess.

FWIW you can steal any of the code I wrote here: https://github.com/daurnimator/mongol/blob/master/mongol/bson.lua

For the record, I abandoned mongo/bson when I realise that bson "dictionarys" are ordered; i.e. they are an ordered array of key/value pairs, and can't actually represent a hash.

from bson-lua.

tcoram avatar tcoram commented on July 22, 2024

IEEE754 floating point numbers do not have an endianess.

Yes. Of course. Duh on my part.

For the record, I abandoned mongo/bson when I realise that bson "dictionarys" are ordered;

Hmm... the spec doesn't exactly make that obvious, but I do see some rather vocal replies (that, "of course", it is ordered) on the mailing list.

I don't use mongo. I use bson as a less verbose json for some simple payload encoding (where the doc is picked apart via hash indexes).

Thanks for pointing that out though.

from bson-lua.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.