Comments (10)
Any table can be a root in a buffer. The root type is mostly for use by JSON, which doesn't specify any types, so we need to know where to start. The generated GetRoot functions are merely convenience.
from flatbuffers.
Ok, thanks. But in Java,
- If i have a ByteBuffer of a non root table how do read that using FlatBuffersBuilder. The only way I know is to use the __init() function, is there another way?
- Is there a way to know the type of the table from the binary data?
- How to use the addXXXType function, in your JavaTest.java you used: Monster.addTestType(fbb, (byte)1); how do you get the type of a table, in this case 1 which it is hard-coded ?
from flatbuffers.
-
a commit was pushed yesterday that adds GetRootAs functions for all tables, not just the root_type.
-
generally no. this is a strongly types system, meaning you need to know the kind of buffer you're dealing with. If you want to use this in a context where you want to have multiple different root types, you have these options:
a) make your root type a table that contains a union of all possible sub-roots.
b) prefix flatbuffers with your own file header
c) use flatbuffer's built-in file indentification feature, which hasn't been ported to Java yet. I'll get to that. -
That's a bug, the
1
should actually read:Any.Monster
. I'll fix that.
from flatbuffers.
Thanks
- But i think the name should be just "get" or "init" instead of getRootAs
from flatbuffers.
getRootAs
is a bit more descriptive and less likely to clash with other identifiers. I think I'll keep it for now.
To further my response to your issue #2, the built-in file_identifier functionality is now also available in Java. See the Schema docs, Java docs, and Java code.
from flatbuffers.
So... How do I access non root_type buffers, can't find anything like Get*** in c++ generated files and the same problem in go lang.
generated code has huge differencies between languages and it's really hard to work with
from flatbuffers.
Tried both latest master and latest release versions
from flatbuffers.
In C++ there is the GetRoot templated function that works with any table type.
Go appears to still be pending on: #363
from flatbuffers.
please explain me how to build flatc executable?
from flatbuffers.
@gaurimaheshwari : https://google.github.io/flatbuffers/flatbuffers_guide_building.html
from flatbuffers.
Related Issues (20)
- rust-flatbuffers: Upgrading from flat 1.12 to 25.x
- rust-flatbuffers: Alignment issue
- --force-empty only support cpp ?
- Conflicts with Rust `core` module in code generated by flatc 23.5.26. HOT 1
- ReleaseRaw cannot be used with custom allocators [C++]
- [kotlin-kmp] Enums only files skipped when multiple schemas are used as input HOT 1
- Assertion `!nested' failed.
- [Python] No functional API to create a flatbuffer
- Question on using Flatbuffers for high performance research application
- Rust: FlatBuffers are impossible to return from functions
- Is it binary-compatible to delete (required) attribute?
- [Python] Use 'T' suffix object for serialization
- [swift] distinguish unknown from absent enum value for scheme evolution HOT 5
- undocumented breaking change GenerateText->GenText
- [Java, FlatBuffers 23.5.26, Mac OS 14.3] getByKey returns null while accessing using vector index works
- `get_root_as_*` functions not generated [Rust, 23.5.26, Linux] HOT 1
- Generating schemas with language adapters (as optional add-ons)?
- Streaming flatbuffers in java HOT 1
- [TS] optional escalar not set in the binary when it holds value 0 HOT 13
- Release a new version, please HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flatbuffers.