urlyy opened a new pull request, #2798: URL: https://github.com/apache/fory/pull/2798
## What does this PR do? 1. Changed `register` to a lazy form, and `finalize_registration()` is only called for the actual registration during `serialize()`, `deserialize()`, or `new_from_fory()`. 2. Adjusted the `register_xx` methods of `TypeResolver` and exposed lazy `register` methods externally. 3. To distinguish between `Context::TypeResolver` and `Fory::TypeResolver`, a new struct `SharedTypeResolver` was introduced. It is responsible for collecting lazy registration information and finalizing it. Using `UnsafeCell` avoids needing `mut fory`, and `Once` ensures finalization happens only once. After finalization, `get_clone()` can return a clone of the internal `TypeResolver` to be inserted into `Context`. 4. Use BTreeMap to store lazy registration information, because HashMap is unordered, iterating over its values can produce different traversal orders for the same input. Using a BTreeMap makes my testing more convenient. 5. modify struct::fory_fields_info() logic, when field_type not found in TypeResolver, will register it immediately and retry get its fory_type_id. Use a HashSet to record Types have been registered. ## Related issues #2793 close #2794 ## Does this PR introduce any user-facing change? - [x] Does this PR introduce any public API change? The `Read/WriteContext::new_from_fory()` will return `Result<Read/WriteContext, Error>` -- 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]
