protobuf 可以读取没有架构但只有数据的文本文件吗?

Could protobuf read text file which has no schema but just data?

比如proto文件是这样的

message {
  required int key = 1;
  repeated int value = 2;
}

文本文件是这样的,第一列表示键,其他列表示重复值。

3391 [ 4847 3948 4849 ]
9483 [ 4938 48497 71 ]
...

protobuf 可以读取和解析这个文本文件吗?

不,protobuf 不支持自定义文本格式。

您必须为其编写自定义解析器代码,然后可以将其转换为 protobuf 或您可能需要的任何其他表示形式。