3 ms·
> you probably shouldn't be using elaborate data structures in streams/files. I don't consider Option<T> a particular "elaborate" data structure, but protobuf
by deathanatos 8y ago
> you probably shouldn't be using elaborate data structures in streams/files.
I don't consider Option<T> a particular "elaborate" data structure, but protobuf would benefit heavily from. Instead, as the author alludes to, you're forced to do different things depending on which side of the message/scalar dichotomy T falls on; if it's a message, you get Option<T> essentially for free, as a submessage can always be omitted. (Which is bad in the case that you just want a T; protobufs will happily let you forget to encode that attribute, and happily decode the lack thereof at the other end, all without error, despite the message being malformed, as it lacks a way to express this — rather common — constraint.) If T is a scalar, you get to use one of the WKTs.
See this GitHub issue for more context: https://github.com/protocolbuffers/protobuf/issues/1606 https://github.com/protocolbuffers/protobuf/issues/1606
I work with data where most attributes outside of the attributes that compose the key identifying some object are quite possibly unknown. Our data comes from messy datasets, and while we clean it up as best we can, sometimes an attribute's value is unintelligble in the source data, and it is more pragmatic to move on without it. In SQL, we represent this as NULL, in JSON, null, but protobuf makes it rather difficult, and this frustration is evident from the other posters in that GitHub issue.