-
Notifications
You must be signed in to change notification settings - Fork 42
Description
In the current protobuf definition, there are four separate oneof value blocks which are all nearly identical. Depending on the application language being used, this can required nearly identical repeated code blocks to handle reading and writing them. I think there is a strong argument that we create a common block something like this and reuse it throughout the protobuf, with the understanding that certain data types are illegal to use within certain cases:
message TypedValue {
optional enum DataType type = 1;
optional bool is_null = 2;
oneof value {
uint32 int_value = 3;
uint64 long_value = 4;
float float_value = 5;
double double_value = 6;
bool boolean_value = 7;
string string_value = 8;
bytes bytes_value = 9; // Bytes, File
DataSet dataset_value = 10;
Template template_value = 11;
TypedValueExtension extension_value = 12;
}
}
The exact list of options in the oneof block should be expanded to be the superset of all possible oneof value blocks, obviously.
One other tweak in that sample, is that I used the explicit enum DataType instead of a simple integer. I suspect this will make handling of datatypes in the most languages source code more easy to understand as well.