Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is ProtoBuf serialization

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "what is ProtoBuf serialization", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what ProtoBuf serialization is.

Performance comparison

Tool name

It takes time to perform 100 reads and writes

1000 times

10000 times

Native serialization

3451ms

34635ms

331201ms

Protobuff serialization

2860ms

28286ms

295272ms

Conclusion

The performance of ProtoBuf is better than that of Java native serialization.

ProtoBuf serialization stores only the value of the field, and sets the value of the property in order, so to add the attribute, be sure to put it on the last one, and if you delete the attribute, you need to set the order of the property.

Cdn.nlark.com/lark/0/2018/png/128761/1545290719552-e4b15a8f-5884-45a0-9f7b-b4000b16f6ff.png ">

Java native serialization needs to implement the Serializable interface, set the serialVersionUID, including inherited parents, to prevent property change deserialization errors.

ProtoBuf serialization

If field does not set Tag annotations, fieldMapping is set from 1, in the order in which the attributes are defined

Set the value of each attribute serial number number

ProtoBuf deserialization

Set the value according to the number of the property

Therefore, if you need to add attributes, be sure to add them later. Generally, it is not recommended to delete attributes. If you delete attributes, you need to set Tag annotations to prevent attribute assignment errors. If Tag annotations are added to attributes, then all properties in this class must add Tag annotations, including inherited parent classes.

At this point, I believe you have a deeper understanding of "what is ProtoBuf serialization", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report