Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

内部协议都用的是google ProtoBuf,但为什么 Account 用thrift二进制编解码协议呢? #2

Closed
liushunshun opened this issue Oct 14, 2016 · 4 comments

Comments

@liushunshun
Copy link

如题

@a2888409
Copy link
Owner

实际上protobuf支持的基本数据类型,thrift基本上也都支持,但是thrift额外支持了以下的容器类型
list(java.util.ArrayList)、set(java.util.HashSet)、map(java.util.HashMap),这点是protobuf不具备的。因此相对来说thrift支持了更丰富的数据结构,更易扩展。

@liushunshun
Copy link
Author

thrift生成的对象文件里内容很多看起来很乱,修改也不方便,每次都要重新生成代码。很多情况我们vo对象都是自己写的,这样查看和修改都方便,然后对象转json再存取redis,相比thrift协议byte[]转对象 性能会差很多吗?大概相差多少呢?(刚学这方面的知识,非常感谢您的耐心解答)

@a2888409
Copy link
Owner

个人认为对象转为bytep[]存储,二进制数据应该会更加紧凑,相对来说存储效率会高点。但是二进制缺点就是存储的数据必须要进行序列化反序列化,可读性较差。关于二者的性能差别,我也没有特意测试过,建议你可以针对存储空间、耗时自行做一个测试

@liushunshun
Copy link
Author

非常感谢^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants