alex-plekhanov commented on a change in pull request #8867:
URL: https://github.com/apache/ignite/pull/8867#discussion_r596059275



##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
##########
@@ -757,7 +761,10 @@ void write(Object obj, BinaryWriterExImpl writer) throws 
BinaryObjectException {
 
                 case OBJECT_ARR:
                     writer.doWriteObjectArray((Object[])obj);
+                    break;

Review comment:
       NL

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryArrayWrapper.java
##########
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Array;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Binary object representing array.
+ */
+public class BinaryArrayWrapper implements BinaryObjectEx, Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Context. */
+    @GridDirectTransient
+    private BinaryContext ctx;
+
+    /** Type ID. */
+    private int compTypeId;
+
+    /** Raw data. */
+    private String compClsName;
+
+    /** Value bytes. */
+    private Object[] arr;
+
+    /** Size of the object */
+    private int size;
+
+    /**
+     * {@link Externalizable} support.
+     */
+    public BinaryArrayWrapper() {
+        // No-op.
+    }
+
+    /**
+     * @param ctx Context.
+     * @param compTypeId Component type id.
+     * @param compClsName Component class name.
+     * @param arr Array.
+     * @param size Size of the object.
+     */
+    public BinaryArrayWrapper(BinaryContext ctx, int compTypeId, @Nullable 
String compClsName, Object[] arr, int size) {
+        this.ctx = ctx;
+        this.compTypeId = compTypeId;
+        this.compClsName = compClsName;
+        this.arr = arr;
+        this.size = size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public BinaryType type() throws BinaryObjectException {
+        return BinaryUtils.typeProxy(ctx, this);
+    }
+
+    /** {@inheritDoc} */
+    @Override public @Nullable BinaryType rawType() throws 
BinaryObjectException {
+        return BinaryUtils.type(ctx, this);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T deserialize() throws BinaryObjectException {
+        return (T)deserialize(null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T deserialize(ClassLoader ldr) throws 
BinaryObjectException {
+        ClassLoader resolveLdr = ldr == null ? 
ctx.configuration().getClassLoader() : ldr;
+
+        if (ldr != null)
+            GridBinaryMarshaller.USE_CACHE.set(Boolean.FALSE);
+
+        try {
+            Class compType = BinaryUtils.resolveClass(ctx, compTypeId, 
compClsName, resolveLdr, false);
+
+            Object[] res = (Object[])Array.newInstance(compType, arr.length);
+
+            for (int i = 0; i < arr.length; i++)
+                    res[i] = arr[i] instanceof BinaryObject ? 
((BinaryObject)arr[i]).deserialize(ldr) : arr[i];

Review comment:
       1. Wrong indent.
   2. Perhaps objects should be deserialized recursively since there can be 
collections and maps inside the array. 

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
##########
@@ -150,9 +150,16 @@
     /** Time array. */
     public static final byte TIME_ARR = 37;
 
-    /** Binary enum */
+    /** Binary enum. */
     public static final byte BINARY_ENUM = 38;
 
+    /**
+     * Binary wrapper for {@code Object[]}.
+     * This wrapper used to store array component type id during serde process.
+     * @see BinaryUtils#doReadObjectArrayWrapper(BinaryInputStream, 
BinaryContext, ClassLoader, BinaryReaderHandlesHolder, boolean, boolean)
+     */
+    public static final byte OBJ_ARR_WRAPPER = 39;

Review comment:
       Do we really need a dedicated type for the wrapper? The wrapper is only 
a temporary internal representation of the array after unmarshalling, if we 
marshall it again we can use the same OBJ_ARR type. 

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
##########
@@ -757,7 +761,10 @@ void write(Object obj, BinaryWriterExImpl writer) throws 
BinaryObjectException {
 
                 case OBJECT_ARR:
                     writer.doWriteObjectArray((Object[])obj);
+                    break;
 
+                case OBJECT_ARR_WRAPPER:
+                    writer.doWriteBinaryArrayWrapper((BinaryArrayWrapper)obj);

Review comment:
       NL

##########
File path: 
modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTypeAutoResolveTest.cs
##########
@@ -155,39 +157,59 @@ public void TestCallJavaServiceLocal()
         [Test]
         public void TestCallJavaServiceRemote()
         {
-            // Deploy Java service
-            var javaSvcName = TestUtils.DeployJavaService(_grid1);
+            DoTestPlatformService(name => 
_client.GetServices().GetServiceProxy<IJavaService>(name, false));
+        }
 
-            var svc = 
_client.GetServices().GetServiceProxy<IJavaService>(javaSvcName, false);
+        /// <summary>
+        /// Tests Java service invocation on remote node..
+        /// Types should be resolved implicitly.
+        /// </summary>
+        [Test]
+        public void TestCallJavaServiceThin()
+        {
+            DoTestPlatformService(name => 
_thinClient.GetServices().GetServiceProxy<IJavaService>(name));
+        }
 
-            DoTestService(svc);
+        /// <summary>
+        /// Tests .Net service invocation.
+        /// </summary>
+        public void DoTestPlatformService(Func<String, IJavaService> svc, bool 
isPlatform = false)

Review comment:
       The method name (and comment) is confusing, it can invoke java service 
as well as .net service, but according to method name and comment it can invoke 
only .net service.  

##########
File path: 
modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryArrayWrapper.java
##########
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.lang.reflect.Array;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Binary object representing array.
+ */
+public class BinaryArrayWrapper implements BinaryObjectEx, Externalizable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Context. */
+    @GridDirectTransient
+    private BinaryContext ctx;
+
+    /** Type ID. */
+    private int compTypeId;
+
+    /** Raw data. */
+    private String compClsName;
+
+    /** Value bytes. */
+    private Object[] arr;
+
+    /** Size of the object */
+    private int size;
+
+    /**
+     * {@link Externalizable} support.
+     */
+    public BinaryArrayWrapper() {
+        // No-op.
+    }
+
+    /**
+     * @param ctx Context.
+     * @param compTypeId Component type id.
+     * @param compClsName Component class name.
+     * @param arr Array.
+     * @param size Size of the object.
+     */
+    public BinaryArrayWrapper(BinaryContext ctx, int compTypeId, @Nullable 
String compClsName, Object[] arr, int size) {
+        this.ctx = ctx;
+        this.compTypeId = compTypeId;
+        this.compClsName = compClsName;
+        this.arr = arr;
+        this.size = size;
+    }
+
+    /** {@inheritDoc} */
+    @Override public BinaryType type() throws BinaryObjectException {
+        return BinaryUtils.typeProxy(ctx, this);
+    }
+
+    /** {@inheritDoc} */
+    @Override public @Nullable BinaryType rawType() throws 
BinaryObjectException {
+        return BinaryUtils.type(ctx, this);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T deserialize() throws BinaryObjectException {
+        return (T)deserialize(null);
+    }
+
+    /** {@inheritDoc} */
+    @Override public <T> T deserialize(ClassLoader ldr) throws 
BinaryObjectException {
+        ClassLoader resolveLdr = ldr == null ? 
ctx.configuration().getClassLoader() : ldr;
+
+        if (ldr != null)
+            GridBinaryMarshaller.USE_CACHE.set(Boolean.FALSE);
+
+        try {
+            Class compType = BinaryUtils.resolveClass(ctx, compTypeId, 
compClsName, resolveLdr, false);
+
+            Object[] res = (Object[])Array.newInstance(compType, arr.length);
+
+            for (int i = 0; i < arr.length; i++)
+                    res[i] = arr[i] instanceof BinaryObject ? 
((BinaryObject)arr[i]).deserialize(ldr) : arr[i];
+
+            return (T)res;
+        }
+        finally {
+            GridBinaryMarshaller.USE_CACHE.set(Boolean.TRUE);
+        }
+    }
+
+    /**
+     * @return Underlying array.
+     */
+    public Object[] array() {
+        return arr;
+    }
+
+    /**
+     * @return Component type ID.
+     */
+    public int componentTypeId() {
+        return compTypeId;
+    }
+
+    /**
+     * @return Component class name.
+     */
+    public String componentClassName() {
+        return compClsName;
+    }
+
+    /** {@inheritDoc} */
+    @Override public BinaryObject clone() throws CloneNotSupportedException {
+        return new BinaryArrayWrapper(ctx, compTypeId, compClsName, 
arr.clone(), size);

Review comment:
       IDEA show a warning about using constructor in clone() method, can we 
use super.clone() here?




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to