I am considering using flatbuffers for messaging. I've 0 experience with it, so some of this might be silly.
Assuming I have complete control of the protocol and how data is passed around,1. Is it advisable to use small flatbuffers for each "message" or a vector of messages?2. Given that on a network, individual read operations do not generally end at the end of a logical message/nested-message(depending on #1's answer). Is there a way to calculate remaining length of a message/nested-message?
--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "FlatBuffers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/flatbuffers/CsjsRw53pvA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to flatbuffers+unsubscribe@googlegroups.com.
On Fri, Sep 23, 2016 at 11:05 PM, 'Wouter van Oortmerssen' via FlatBuffers <flatb...@googlegroups.com> wrote:Typically FlatBuffers don't know their own size, and partial data is generally not readable until the full buffer has been received. Hence, if you want to process messages as they come in, you'll need to store each message in its own individual FlatBuffer, and send a length-prefixed stream of them.
Typically FlatBuffers don't know their own size, and partial data is generally not readable until the full buffer has been received. Hence, if you want to process messages as they come in, you'll need to store each message in its own individual FlatBuffer, and send a length-prefixed stream of them.Is there a preferred way to do this in golang?
One way I have found is to store littleEndian builder.Offset() length in builder.Bytes[builder.Head() - 4:Head()] and return builder.Bytes[Head()-4:] to be used directlyIs that a good way to do it? I'm trying to avoid allocations.
I also wonder how one would handle messages longer than unsigned 32bit length?
Is the acceptable to overwrite the values on "bb.Head()-4 to bb.Head()" after having called Finish.
Or is there some way in the API/internals to leave a gap before the actual byte buffer starts?
Is the acceptable to overwrite the values on "bb.Head()-4 to bb.Head()" after having called Finish.
Or is there some way in the API/internals to leave a gap before the actual byte buffer starts?
--
btw, added some functionality to make size pre-fixing part of FlatBuffers: https://github.com/google/flatbuffers/commit/486c048a0d5963f83f3a0d6957e4dde41602e2e7
table List{
items : [Item];
}
table Item {
a:string;
b:int;
}
root_type List;You'll first need to check if there's actually space in the ByteBuffer. And like I said, you're safer writing a 64bit length just to keep the buffer internals aligned, unless you're sure you won't be using any 64bit quantities.
On Mon, Oct 3, 2016 at 9:12 PM, Piyush Mishra <ma...@ofpiyush.in> wrote:
Is the acceptable to overwrite the values on "bb.Head()-4 to bb.Head()" after having called Finish.
Or is there some way in the API/internals to leave a gap before the actual byte buffer starts?
--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers...@googlegroups.com.
I am not certain of how the offsets are stored, feasibility might depend on that. In theory it is possible but not desireable, at least in my use case.
In practice, I am doing something similar without the overhead of making another table for it.The point of making a table is having random access, in streaming all I need is serial access to each buffer as it comes. Prepending just 4 bytes of length is pretty efficient that way.
I inlined the length and actual buffer instead of going through one level of indirection that tables bring with them.Sort of like how a struct is described in the docs but with vectors inside.
To clarify how FlatBuffers are strucutred internally here is a diagram of my example fbs and a list with two items
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers+unsubscribe@googlegroups.com.