假设我定义了这样的protobuf消息
message Config {
oneof config{
A a = 1;
B b = 2;
}
}
Run Code Online (Sandbox Code Playgroud)
现在在python代码中,当我解析Config的消息实例时,我可以使用
field = config.WhichOneof('config')
Run Code Online (Sandbox Code Playgroud)
但是我应该如何使用获得的字段名访问A?我不想写这样的东西:
if field == 'a':
return config.a
else
return config.b
Run Code Online (Sandbox Code Playgroud)
因为我只想使用a或b获取下划线值,所以我已经知道它的类型。有更好的解决方案吗?谢谢!
我试图使用 dd 来测试我的 ceph 文件系统的性能。在测试过程中,我发现了一些令人困惑的事情,即 dd 和 oflag=dsync 或 conv=fdatasync/fsync 比 dd 和 oflag=direct 快 10 倍左右。
我的网络是 2*10Gb
/mnt/testceph# dd if=/dev/zero of=/mnt/testceph/test1 bs=1G count=1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 23.1742 s, 46.3 MB/s
/mnt/testceph# dd if=/dev/zero of=/mnt/testceph/test1 bs=1G count=1 conv=fdatasync
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 2.22468 s, 483 MB/s
Run Code Online (Sandbox Code Playgroud)