nizhikov commented on a change in pull request #8867: URL: https://github.com/apache/ignite/pull/8867#discussion_r596352884
########## 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: Fixed. ---------------------------------------------------------------- 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]
