Code Monkey home page Code Monkey logo

Comments (4)

sapek avatar sapek commented on August 14, 2024

This can only be answered for a pair (schema, protocol). For example in Compact Binary almost all types are variable length, the only exceptions are bool, float and double and 8-bit integers. In Fast Binary all integer are fixed size. Furthermore most protocols omit optional fields that are set to default value.

There is no such API.

from bond.

redknightlois avatar redknightlois commented on August 14, 2024

Can be done from outside of Bond internals? (If there is no such API).
Is there any intention to provide such an API?
If possible how?

from bond.

sapek avatar sapek commented on August 14, 2024

The rules for determining if a schema is const length for a given protocol would have to hardcoded per protocol. There is no way to determine it programmatically. One could in theory imagine some way to encoding this as protocol metadata but I think it would only make sense to add if Bond itself had some feature taking advantage of fixed size fields.

As for determining what the size of a fixed length schema is, the easiest way would be to serialize an instance (e.g. default instance) to a stream that just counts bytes. We have a stream like that implemented in C++ and use it to calculate lengths in the first pass of Compact Binary v2 serialization.

from bond.

redknightlois avatar redknightlois commented on August 14, 2024

Yes, I was actually thinking into implementing our own SimpleFastProtocol disallowing variable size types altogether; where we can estimate that without much problems. The solution used in C++ would also work, we use counting streams ourselves too.

from bond.

Related Issues (20)

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.