In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to write an optional .proto file". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to write an optional .proto file".
Protobuf1. Why use protobuf
Protobuf is a structured data serialization framework.
two。 What is serialization?
Convert objects or structured data into a data format that is easy to store and transfer. To ensure that the serialized results can be re-established back to the original object or data.
3. Why Protobuf is faster and smaller
Convert to binary with compression
4 how to write .proto file
Keyword
Proto3 deleted optional and required
Syntax = "proto2"
Package tutorial
Option java_package = "com.example.tutorial"
Option java_outer_classname = "AddressBookProtos"
Message Person {
Required string name = 1
Required int32 id = 2
Optional string email = 3
Enum PhoneType {
MOBILE = 0
HOME = 1
WORK = 2
}
Message PhoneNumber {
Required string number = 1
Optional PhoneType type = 2 [default = HOME]
}
Repeated PhoneNumber phones = 4
}
Message AddressBook {
Repeated Person people = 1
}
5 comparison of common data types with java
Proto
Java
Int32
Int
String
String
Double
Double
Enum
Enum
Int 64
Long
Thank you for your reading, the above is the content of "how to write optional .proto file", after the study of this article, I believe you have a deeper understanding of how to write optional .proto file, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.