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

[Java] use varint for class id to reduce space cost #944

Closed
chaokunyang opened this issue Oct 5, 2023 · 0 comments · Fixed by #945
Closed

[Java] use varint for class id to reduce space cost #944

chaokunyang opened this issue Oct 5, 2023 · 0 comments · Fixed by #945
Labels
enhancement New feature or request java

Comments

@chaokunyang
Copy link
Collaborator

chaokunyang commented Oct 5, 2023

Is your feature request related to a problem? Please describe.

Currently class id is written as 3 bytes:

| flag byte | two bytes short class id |

This is wasteful for space. For string/int/long/etc. classes, class id can be written using 1 bytes.

With this PR, class id will be

Describe the solution you'd like

New class id encoding format:

  • use varint for class id encoding to reduce java class writing space cost.
  • Use little endian order for class id encoding
  • Use bit 0 as flag to indicate the class will be written using class id
  • When reading, read one byte first, since writting use little endian, the bit 0 of read byte can be used as a flag to determine whether this class is written using class id. If so, read varint and >>1 to get real class id. Otherwise, read class by classname instead.
@chaokunyang chaokunyang added the enhancement New feature or request label Oct 5, 2023
@chaokunyang chaokunyang changed the title [Java] use varint for class id read/write [Java] use varint for class id to reduce space cost Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request java
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant