drse opened a new issue, #2609: URL: https://github.com/apache/fory/issues/2609
### Feature Request When registering classes manually, the provided api method `register(Class<?>, int id)` implies to the user that any specified integer is valid. However: - `0` means "Unregistered" - Value must be unsigned - There is a reserved range unknown to the user - This reserved range is subject to change - The actual valid user range is ~150 - 32766, and subject to change - Precondition range check fails with no explanatory message ### Is your feature request related to a problem? Please describe The problem is usability, and possible compatibility issues with user ranges in future versions. ### Describe the solution you'd like - Maintain the current api signature - Reserve the first, say `1000` ids for internal classes - Allow the user range to be `0-20000` (or up to 31765, assuming 0 and Short.MAX_VALUE can't be used, and 1000 ids are reserved) - Internally, compute the user registered class id to 1000 + user supplied id - If precondition fails the range, report an intuitive error message: "Supplied class id 41234 is outside valid range of 0 to 20000" - never expose internal ranges to user Or - Maintain the existing scheme - Fix precondition message to be more intuitive and explanatory, and docs as well - expose methods to obtain `minClassId` and `maxClassId` and perhaps `isValidClassId(int)` to give the user a basis for constructing their own ids Or amend protocol to separate internal and user-ranges, see below. ### Describe alternatives you've considered Inside the serialization protocol, create semantics to indicate internal or user-specified id. Instead of specifying the 16-bit user id, start by using a bit flag to indicate if its an internal id or user-specified. If internal, follow with a `byte`, if user, with a `short`, and modify the api to `register(Class<?>, short)`, accepting both 0 and Short.MAX_VALUE. Internally, modify class lookups to consider the two types of ranges. ### Additional context _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
