-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization: special null values #35
Comments
isn't that basically FlatBuffer's default value? In standard flatbuffer generated code, such a value is not stored (i.e. it is stored as NULL) |
Yes, as in "a specialized variant" of that as the "defaults" are fixed. PS.: to clarify, the existing behavior should stay as is. Storing nulls from zeros is something one should be very aware of (too troublesome to make it the default behavior). |
If I get this right, the desired behavior would be:
If that's the case it would behave like flatbuffers normally do, i.e. don't write default values to the buffer. Since we have changed this behaviour to write all the time, we can switch back for individual fields using the |
Hmm, this is not exactly what I had in mind. I had started with some code locally some days back; maybe we can sync on that in a vcall next week? |
In addition to existing "optional" support for C++, there should also be a variant to represent "null" values in FlatBuffers via special values. Why? The current C++11 solution with
unique_ptr
is heap based and thus comes with an extra indirection with potential cache misses (not to mention additional allocs and deallocs). C++17'soptional
is much better but still comes with space overhead (one byte plus padding; resulting in 2x space requirements in some cases).Special values to indicate a null in FlatBuffers could be configurable in the future, but to start with we can only consider the "obvious" ones: empty string, zero for integer types, and NAN for floating points. This requires a new annotation or an addition to the existing one. E.g.
/// objectbox:optional="special-value"
Btw, https://cpp.objectbox.io/entity-annotations does not mention optional values at all yet.
The text was updated successfully, but these errors were encountered: