What is canonical way to store NULL value in FlatBuffers ?
I have
ExpirationDate *int64
I understand why FlatBuffers is not defining NULL. But I do not understand how to handle that properly. Should I have extra bool field or make value a array?
ExpirationDate [int64]
vs
ExpirationDate int64
ExpirationDateNull bool
For tables may be I can use also union
.
A third option is struct NullableInt64 { i:int64 }
and then in table have a field of type NullableInt64
. When this field is not present, the accessor function will return NULL
. And because it a struct, it will take the same space on the wire as a naked int64 (they're both 8 bytes and are stored inline in the parent).
For storing values like int32 / int64 etc. You can directly keep the scalars in the table.
But in your case you have an indirection, which can be mimiced by an indirection created by non-scalars in flatbuffers.
Non-scalars are struct, array, and table.
So you may try :
Struct IntPtr
{
val:int64
}
Table Expiration
{
ExpirationDate:IntPtr;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With