chaokunyang commented on code in PR #3021:
URL: https://github.com/apache/fory/pull/3021#discussion_r2617794316


##########
java/fory-core/src/main/java/org/apache/fory/type/Descriptor.java:
##########
@@ -89,6 +89,8 @@ public static void clearDescriptorCache() {
   private final Method writeMethod;
   private ForyField foryField;
   private boolean nullable;
+  // trackingRef should only be true if explicitly set to true via 
@ForyField(ref=true)
+  // If no annotation or ref not specified, trackingRef stays false and 
type-based tracking applies
   private boolean trackingRef;

Review Comment:
   You can update `MapRefResolver` like this:
   
   ```java
     public void reference(Object object) {
       int refId = readRefIds.pop();
       if (refId >= 0) {
         setReadObject(refId, object);
       }
     }
   ```
   
   Then for fields which will track ref but skip ref now, you can reserve an id 
`-1`:
   ```java
   preserveRefId(-1)
   ```
   
   `@ForyField` needs higher priority, it can improve performance signicantly. 
Most of times in an object graph, there is no shared/circular reference, but 
due to we can't differeiate those objects, we introduced lots of unnecesary ref 
tracking



##########
java/fory-core/src/main/java/org/apache/fory/type/Descriptor.java:
##########
@@ -89,6 +89,8 @@ public static void clearDescriptorCache() {
   private final Method writeMethod;
   private ForyField foryField;
   private boolean nullable;
+  // trackingRef should only be true if explicitly set to true via 
@ForyField(ref=true)
+  // If no annotation or ref not specified, trackingRef stays false and 
type-based tracking applies
   private boolean trackingRef;

Review Comment:
   @mchernyakov You can update `MapRefResolver` like this:
   
   ```java
     public void reference(Object object) {
       int refId = readRefIds.pop();
       if (refId >= 0) {
         setReadObject(refId, object);
       }
     }
   ```
   
   Then for fields which will track ref but skip ref now, you can reserve an id 
`-1`:
   ```java
   preserveRefId(-1)
   ```
   
   `@ForyField` needs higher priority, it can improve performance signicantly. 
Most of times in an object graph, there is no shared/circular reference, but 
due to we can't differeiate those objects, we introduced lots of unnecesary ref 
tracking



-- 
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]

Reply via email to