且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

协议缓冲区-存储1D,2D和3D双数组

更新时间:2023-11-12 23:35:58

***通过以下方式存储double数组:

An array of double would be best stored via

repeated double foo = 5 [packed=true];

repeated使其充当列表,允许多个项目; packed避免每个项目都有标题.

repeated makes it act as a list, allowing multiple items; packed avoids a header per item.

protobuf中不直接支持矩形(或更高版本)的数组.最接近的是存储类似的内容:

There is no direct support for rectangular (or higher) arrays in protobuf. The closest is to store something like:

repeated innerType foo = 5; // note, can't be "packed"

message innerType {
    repeated double foo = 1 [packed=true];
}

这大致类似于锯齿状的数组,但是每个层之间都有一个元素.

this is broadly akin to a jagged array, but with an element between each tier.