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

1.1 Multiple encoding methods: Type Encoding Format #36

Open
streetycat opened this issue May 6, 2023 · 0 comments
Open

1.1 Multiple encoding methods: Type Encoding Format #36

streetycat opened this issue May 6, 2023 · 0 comments
Assignees

Comments

@streetycat
Copy link
Collaborator

streetycat commented May 6, 2023

Multiple encoding methods

All information based on CYFS can choose one of the following three encoding methods. Both Protobuf and JSON have their standard encoding specifications. I won’t go into details here. We only introduce the binary encoding format.

  1. Binary

    Binary format encoding, usually used for standardized fixed encoding, the most space-saving, but not easy to expand.

    When binary encoding is selected, the type designer needs to fill all fields into a Buffer one by one in a certain order.

  2. Protobuf

    Using Protobuf encoding, while taking into account certain space efficiency and scalability, this is the encoding method selected by most complex types.

    When using Protobuf encoding, the type designer only needs to assign each field of the object to the corresponding Protobuf type, and then use the Protobuf method to encode and decode. Compatibility processing needs to refer to the Protobuf specification.

    ** Note: The Protobuf specification we chose is Proto3, considering backward compatibility, the Protobuf version is unlikely to be upgraded. Of course, other versions can be selected for the type of new design, but different versions need to be carefully introduced. **

  3. JSON

    Encoded in JSON, which is less space efficient but more readable.

    Because of its low space efficiency, the JSON method is usually not selected to encode and decode information. JSON encoding usually appears in the scene of human-computer interaction.

** No matter which encoding method you choose, you must pay attention to the stability of the encoding when you use it for object encoding (for example: Set and Map should pay attention to the order of each element), otherwise the ObjectId obtained by calculating the same content multiple times may be different. **

@streetycat streetycat self-assigned this May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Draft
Development

No branches or pull requests

1 participant