'Serialize message with unsupported C++ types in protobuf
Since protobuf does not allow serialization of int8_t, int16_t and some other c++ types, I have made the following message for those:
message OtherType
{
enum Type
{
CHAR = 0;// Default
INT8 = 1;
INT16 = 2;
UINT8 = 3;
UINT16 = 4;
}
Type type = 1;
int32 value = 2;
}
message arrayOfNotSupportedTypes
{
repeated OtherType value = 1;
}
Now, I may send big amounts of this type of data, e.g. pictures serialized to uint8_t. My question is: Does this approach of having this type of message with the message itself + type tag + value incur a lot of overhead, compared to have a message of just repeated int32 like this:
message PlainArray
{
repeated int32 value = 1;
}
I suppose I could use the second option instead of the first one for types that are not supported and just treat all non-supported values as int32_t after deserialization, if the overhead in the first approach is too big...
EDIT: I know that protobuf is not good for messages larger than 1MB, and if I have a large message , I will of course split it into smaller ones.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
