david1437 commented on code in PR #2218:
URL: https://github.com/apache/fury/pull/2218#discussion_r2093682673


##########
java/fury-core/src/main/java/org/apache/fury/serializer/ArraySerializers.java:
##########
@@ -147,39 +191,49 @@ public void xwrite(MemoryBuffer buffer, T[] arr) {
 
     @Override
     public T[] read(MemoryBuffer buffer) {
+      Object[] value;
       int numElements = buffer.readVarUint32Small7();
-      boolean isFinal = (numElements & 0b1) != 0;
-      numElements >>>= 1;
-      Object[] value = newArray(numElements);
-      RefResolver refResolver = fury.getRefResolver();
-      refResolver.reference(value);
-      if (isFinal) {
-        final Serializer componentTypeSerializer = 
this.componentTypeSerializer;
-        for (int i = 0; i < numElements; i++) {
-          Object elem;
-          int nextReadRefId = refResolver.tryPreserveRefId(buffer);
-          if (nextReadRefId >= Fury.NOT_NULL_VALUE_FLAG) {
-            elem = componentTypeSerializer.read(buffer);
-            refResolver.setReadObject(nextReadRefId, elem);
-          } else {
-            elem = refResolver.getReadObject();
-          }
-          value[i] = elem;
+      if (this.collectionSerializer != null) {
+        fury.getGenerics().pushGenericType(this.collectionGenericType);
+        value = this.collectionSerializer.read(buffer).toArray();
+        fury.getGenerics().popGenericType();
+        if (this.innerType.isPrimitive() || TypeUtils.isBoxed(this.innerType)) 
{
+          return Arrays.copyOf(value, value.length, this.type);

Review Comment:
   Considering this does a copy it does not feel good is there a better 
approach for handling this? without this i get a class cast exception?



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