LiangliangSui commented on code in PR #1406:
URL: https://github.com/apache/incubator-fury/pull/1406#discussion_r1524556953
##########
java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java:
##########
@@ -229,8 +228,7 @@ public class ClassResolver {
private final ShimDispatcher shimDispatcher;
private static class ExtRegistry {
- private short registeredClassIdCounter = 0;
- private final LongMap<Class<?>> registeredId2Classes = new
LongMap<>(initialCapacity);
+ private short registeredClassIdCounter = 1;
Review Comment:
`registeredClassIdCounter` will increase automatically after each successful
registration. When we use the built-in ClassID to register and use
`register(Class<?> cls)` again, the `registeredClassIdCounter` can be
recalculated once.
```java
// registeredClassIdCounter = 0
register(LambdaSerializer.ReplaceStub.class, LAMBDA_STUB_ID); //
registeredClassIdCounter = 1 now
register(class); // registeredClassIdCounter = 1 has been registered at this
time, and registeredClassIdCounter needs to be recalculated
```
##########
java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java:
##########
@@ -391,12 +391,7 @@ private void registerDefaultClasses() {
/** register class. */
public void register(Class<?> cls) {
- if (!extRegistry.registeredClassIdMap.containsKey(cls)) {
- while
(extRegistry.registeredId2Classes.containsKey(extRegistry.registeredClassIdCounter))
{
- extRegistry.registeredClassIdCounter++;
- }
- register(cls, extRegistry.registeredClassIdCounter);
- }
+ register(cls, extRegistry.registeredClassIdCounter);
Review Comment:
The situation you mentioned above cannot be covered because the user can
specify the classId.
Duplicate registration of ClassID will be detected.
--
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]