Skip to content

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

@chaokunyang

Description

@chaokunyang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions