resize (mutate) a Vector in a flexbuffer

120 views
Skip to first unread message

Simoncl

unread,
Feb 23, 2018, 6:01:12 PM2/23/18
to FlatBuffers
Hi.

Is it possible to resize a Vector  of a flexbuffer?

Can I do something similar to the following but with a flexbuffer?

auto &inventory_field = *fields->LookupByKey("inventory");
auto rinventory = flatbuffers::piv( flatbuffers::GetFieldV<uint8_t>(**rroot, inventory_field),resizingbuf);
 flatbuffers::ResizeVector<uint8_t>(schema, 110, 50, *rinventory, &resizingbuf);  


Cheers

Simon



Wouter van Oortmerssen

unread,
Feb 26, 2018, 12:34:13 PM2/26/18
to Simoncl, FlatBuffers
That is currently not implemented yet, no.

In theory, in-place resizing should be easier in FlexBuffers than FlatBuffers, since it is self-describing, so no need for reflection. There's however one major obstacle: FlexBuffers optimizes offsets to be the smallest possible. This means that if you'd insert in the middle of a buffer, the offsets following it could change size, completely changing the encoding of everything that follows. Implementing that correctly would definitely be complicated.

For now, your best bet are to unpack/insert/repack the whole buffer, or to leave extra space in the vector and use the mutation functions (if dealing with just scalars).

--
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.

Reply all
Reply to author
Forward
0 new messages