ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [05/30] ignite git commit: IGNITE-2099: Fixed serialization of custom collections.
Date Fri, 11 Dec 2015 04:29:09 GMT
IGNITE-2099: Fixed serialization of custom collections.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6cdd5804
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6cdd5804
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6cdd5804

Branch: refs/heads/ignite-843-rc2
Commit: 6cdd58042358049afacc10e169192a009a346846
Parents: be17c9e
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Dec 10 11:41:05 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Dec 10 11:41:05 2015 +0300

----------------------------------------------------------------------
 .../ignite/binary/BinaryCollectionFactory.java  |  33 +++++
 .../apache/ignite/binary/BinaryMapFactory.java  |  33 +++++
 .../apache/ignite/binary/BinaryRawReader.java   |   8 +-
 .../org/apache/ignite/binary/BinaryReader.java  |   9 +-
 .../internal/portable/BinaryFieldAccessor.java  |  19 +--
 .../internal/portable/BinaryReaderExImpl.java   | 107 +++++++-------
 .../internal/portable/BinaryWriteMode.java      |   3 -
 .../internal/portable/BinaryWriterExImpl.java   |  45 ++----
 .../portable/GridPortableMarshaller.java        |  21 ---
 .../portable/PortableClassDescriptor.java       |   7 +-
 .../internal/portable/PortableContext.java      |  71 ++++-----
 .../ignite/internal/portable/PortableUtils.java | 144 +++++--------------
 .../portable/builder/PortableBuilderReader.java |  12 --
 .../builder/PortableBuilderSerializer.java      |  17 +--
 .../portable/builder/PortableLazyMapEntry.java  |  68 ---------
 .../portable/BinaryMarshallerSelfTest.java      | 127 +++++++++++++++-
 .../BinaryObjectBuilderAdditionalSelfTest.java  | 101 ++++++-------
 .../mutabletest/GridPortableTestClasses.java    |  77 +++++++---
 .../src/binary_reader_writer_raw_test.cpp       |  10 +-
 .../core-test/src/binary_reader_writer_test.cpp |  10 +-
 .../core/include/ignite/binary/binary_consts.h  |  29 +---
 .../Impl/Binary/BinaryObjectBuilder.cs          |   8 +-
 .../Impl/Binary/BinarySystemHandlers.cs         |  27 +---
 .../Impl/Binary/BinaryUtils.cs                  |  93 ++----------
 24 files changed, 465 insertions(+), 614 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/binary/BinaryCollectionFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryCollectionFactory.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryCollectionFactory.java
new file mode 100644
index 0000000..0e5bf83
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryCollectionFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.binary;
+
+import java.util.Collection;
+
+/**
+ * Collection factory.
+ */
+public interface BinaryCollectionFactory<K> {
+    /**
+     * Create collection.
+     *
+     * @param size Amount of elements in collection.
+     * @return Collection.
+     */
+    public Collection<K> create(int size);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/binary/BinaryMapFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryMapFactory.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryMapFactory.java
new file mode 100644
index 0000000..d514bf9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryMapFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.binary;
+
+import java.util.Map;
+
+/**
+ * Map factory.
+ */
+public interface BinaryMapFactory<K, V> {
+    /**
+     * Create collection.
+     *
+     * @param size Amount of elements in collection.
+     * @return Collection.
+     */
+    public Map<K, V> create(int size);
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java
index 7ff515a..ce059d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryRawReader.java
@@ -206,11 +206,11 @@ public interface BinaryRawReader {
     @Nullable public <T> Collection<T> readCollection() throws BinaryObjectException;
 
     /**
-     * @param colCls Collection class.
+     * @param factory Collection factory.
      * @return Collection.
      * @throws BinaryObjectException In case of error.
      */
-    @Nullable public <T> Collection<T> readCollection(Class<? extends Collection<T>> colCls)
+    @Nullable public <T> Collection<T> readCollection(BinaryCollectionFactory<T> factory)
         throws BinaryObjectException;
 
     /**
@@ -220,11 +220,11 @@ public interface BinaryRawReader {
     @Nullable public <K, V> Map<K, V> readMap() throws BinaryObjectException;
 
     /**
-     * @param mapCls Map class.
+     * @param factory Map factory.
      * @return Map.
      * @throws BinaryObjectException In case of error.
      */
-    @Nullable public <K, V> Map<K, V> readMap(Class<? extends Map<K, V>> mapCls) throws BinaryObjectException;
+    @Nullable public <K, V> Map<K, V> readMap(BinaryMapFactory<K, V> factory) throws BinaryObjectException;
 
     /**
      * @return Value.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java
index b8183a2..be7a156 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryReader.java
@@ -242,11 +242,11 @@ public interface BinaryReader {
 
     /**
      * @param fieldName Field name.
-     * @param colCls Collection class.
+     * @param factory Collection factory.
      * @return Collection.
      * @throws BinaryObjectException In case of error.
      */
-    public <T> Collection<T> readCollection(String fieldName, Class<? extends Collection<T>> colCls)
+    public <T> Collection<T> readCollection(String fieldName, BinaryCollectionFactory<T> factory)
         throws BinaryObjectException;
 
     /**
@@ -258,12 +258,11 @@ public interface BinaryReader {
 
     /**
      * @param fieldName Field name.
-     * @param mapCls Map class.
+     * @param factory Map factory.
      * @return Map.
      * @throws BinaryObjectException In case of error.
      */
-    public <K, V> Map<K, V> readMap(String fieldName, Class<? extends Map<K, V>> mapCls)
-        throws BinaryObjectException;
+    public <K, V> Map<K, V> readMap(String fieldName, BinaryMapFactory<K, V> factory) throws BinaryObjectException;
 
     /**
      * @param fieldName Field name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java
index 2f6b73c..7701fb5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java
@@ -17,6 +17,11 @@
 
 package org.apache.ignite.internal.portable;
 
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import sun.misc.Unsafe;
+
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
@@ -24,10 +29,6 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
 
 /**
  * Field accessor to speedup access.
@@ -607,11 +608,6 @@ public abstract class BinaryFieldAccessor {
 
                     break;
 
-                case MAP_ENTRY:
-                    writer.writeMapEntryField((Map.Entry<?, ?>)val);
-
-                    break;
-
                 case PORTABLE_OBJ:
                     writer.writePortableObjectField((BinaryObjectImpl)val);
 
@@ -813,11 +809,6 @@ public abstract class BinaryFieldAccessor {
 
                     break;
 
-                case MAP_ENTRY:
-                    val = reader.readMapEntry(id);
-
-                    break;
-
                 case PORTABLE_OBJ:
                     val = reader.readPortableObject(id);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index a0aa2e5..6a8091f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -26,8 +26,11 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
+
+import org.apache.ignite.binary.BinaryCollectionFactory;
 import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryMapFactory;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.BinaryRawReader;
@@ -62,7 +65,6 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT_ARR
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENTRY;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
@@ -310,24 +312,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
 
     /**
      * @param fieldId Field ID.
-     * @return Value.
-     * @throws BinaryObjectException On case of error.
-     */
-    @Nullable Map.Entry<?, ?> readMapEntry(int fieldId) throws BinaryObjectException {
-        if (findFieldById(fieldId)) {
-            Flag flag = checkFlag(MAP_ENTRY);
-
-            if (flag == Flag.NORMAL)
-                return PortableUtils.doReadMapEntry(in, ctx, ldr, this, true);
-            else if (flag == Flag.HANDLE)
-                return readHandleField();
-        }
-
-        return null;
-    }
-
-    /**
-     * @param fieldId Field ID.
      * @return Portable object.
      * @throws BinaryObjectException In case of error.
      */
@@ -1236,20 +1220,20 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <T> Collection<T> readCollection(String fieldName,
-        Class<? extends Collection<T>> colCls) throws BinaryObjectException {
-        return findFieldByName(fieldName) ? readCollection0(colCls) : null;
+    @Nullable @Override public <T> Collection<T> readCollection(String fieldName, BinaryCollectionFactory<T> factory)
+        throws BinaryObjectException {
+        return findFieldByName(fieldName) ? readCollection0(factory) : null;
     }
 
     /**
      * @param fieldId Field ID.
-     * @param colCls Collection class.
+     * @param factory Collection factory.
      * @return Value.
      * @throws BinaryObjectException In case of error.
      */
-    @Nullable <T> Collection<T> readCollection(int fieldId, @Nullable Class<? extends Collection> colCls)
+    @Nullable <T> Collection<T> readCollection(int fieldId, @Nullable BinaryCollectionFactory<T> factory)
         throws BinaryObjectException {
-        return findFieldById(fieldId) ? (Collection<T>)readCollection0(colCls) : null;
+        return findFieldById(fieldId) ? (Collection<T>)readCollection0(factory) : null;
     }
 
     /** {@inheritDoc} */
@@ -1258,26 +1242,41 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <T> Collection<T> readCollection(Class<? extends Collection<T>> colCls)
+    @Nullable @Override public <T> Collection<T> readCollection(BinaryCollectionFactory<T> factory)
         throws BinaryObjectException {
-        return readCollection0(colCls);
+        return readCollection0(factory);
     }
 
     /**
      * Internal read collection routine.
      *
-     * @param cls Collection class.
+     * @param factory Collection factory.
      * @return Value.
      * @throws BinaryObjectException If failed.
      */
-    private Collection readCollection0(@Nullable Class<? extends Collection> cls)
+    private Collection readCollection0(@Nullable BinaryCollectionFactory factory)
         throws BinaryObjectException {
         switch (checkFlag(COL)) {
             case NORMAL:
-                return (Collection)PortableUtils.doReadCollection(in, ctx, ldr, this, true, cls);
+                return (Collection)PortableUtils.doReadCollection(in, ctx, ldr, this, true, factory);
 
-            case HANDLE:
-                return readHandleField();
+            case HANDLE: {
+                int handlePos = PortableUtils.positionForHandle(in) - in.readInt();
+
+                Object obj = getHandle(handlePos);
+
+                if (obj == null) {
+                    int retPos = in.position();
+
+                    streamPosition(handlePos);
+
+                    obj = readCollection0(factory);
+
+                    streamPosition(retPos);
+                }
+
+                return (Collection)obj;
+            }
 
             default:
                 return null;
@@ -1290,19 +1289,19 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName, Class<? extends Map<K, V>> mapCls)
+    @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName, BinaryMapFactory<K, V> factory)
         throws BinaryObjectException {
-        return findFieldByName(fieldName) ? readMap0(mapCls) : null;
+        return findFieldByName(fieldName) ? readMap0(factory) : null;
     }
 
     /**
      * @param fieldId Field ID.
-     * @param mapCls Map class.
+     * @param factory Factory.
      * @return Value.
      * @throws BinaryObjectException In case of error.
      */
-    @Nullable Map<?, ?> readMap(int fieldId, @Nullable Class<? extends Map> mapCls) throws BinaryObjectException {
-        return findFieldById(fieldId) ? readMap0(mapCls) : null;
+    @Nullable Map<?, ?> readMap(int fieldId, @Nullable BinaryMapFactory factory) throws BinaryObjectException {
+        return findFieldById(fieldId) ? readMap0(factory) : null;
     }
 
     /** {@inheritDoc} */
@@ -1311,25 +1310,40 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public <K, V> Map<K, V> readMap(Class<? extends Map<K, V>> mapCls)
+    @Nullable @Override public <K, V> Map<K, V> readMap(BinaryMapFactory<K, V> factory)
         throws BinaryObjectException {
-        return readMap0(mapCls);
+        return readMap0(factory);
     }
 
     /**
      * Internal read map routine.
      *
-     * @param cls Map class.
+     * @param factory Factory.
      * @return Value.
      * @throws BinaryObjectException If failed.
      */
-    private Map readMap0(@Nullable Class<? extends Map> cls) throws BinaryObjectException {
+    private Map readMap0(@Nullable BinaryMapFactory factory) throws BinaryObjectException {
         switch (checkFlag(MAP)) {
             case NORMAL:
-                return (Map)PortableUtils.doReadMap(in, ctx, ldr, this, true, cls);
+                return (Map)PortableUtils.doReadMap(in, ctx, ldr, this, true, factory);
 
-            case HANDLE:
-                return readHandleField();
+            case HANDLE: {
+                int handlePos = PortableUtils.positionForHandle(in) - in.readInt();
+
+                Object obj = getHandle(handlePos);
+
+                if (obj == null) {
+                    int retPos = in.position();
+
+                    streamPosition(handlePos);
+
+                    obj = readMap0(factory);
+
+                    streamPosition(retPos);
+                }
+
+                return (Map)obj;
+            }
 
             default:
                 return null;
@@ -1584,11 +1598,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
 
                 break;
 
-            case MAP_ENTRY:
-                obj = PortableUtils.doReadMapEntry(in, ctx, ldr, this, true);
-
-                break;
-
             case PORTABLE_OBJ:
                 obj = PortableUtils.doReadPortableObject(in, ctx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java
index bd73ad0..3e0bf69 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java
@@ -133,9 +133,6 @@ public enum BinaryWriteMode {
     MAP(GridPortableMarshaller.MAP),
 
     /** */
-    MAP_ENTRY(GridPortableMarshaller.MAP_ENTRY),
-
-    /** */
     PORTABLE_OBJ(GridPortableMarshaller.OBJ),
 
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
index 6bb493e..4139b8f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
@@ -17,6 +17,16 @@
 
 package org.apache.ignite.internal.portable;
 
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream;
+import org.apache.ignite.internal.portable.streams.PortableOutputStream;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.jetbrains.annotations.Nullable;
+
 import java.io.IOException;
 import java.io.ObjectOutput;
 import java.lang.reflect.InvocationTargetException;
@@ -27,15 +37,6 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream;
-import org.apache.ignite.internal.portable.streams.PortableOutputStream;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.jetbrains.annotations.Nullable;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN;
@@ -62,7 +63,6 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT_ARR
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENTRY;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
@@ -761,23 +761,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
     }
 
     /**
-     * @param e Map entry.
-     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
-     */
-    void doWriteMapEntry(@Nullable Map.Entry<?, ?> e) throws BinaryObjectException {
-        if (e == null)
-            out.writeByte(NULL);
-        else {
-            if (tryWriteAsHandle(e))
-                return;
-
-            out.writeByte(MAP_ENTRY);
-            doWriteObject(e.getKey());
-            doWriteObject(e.getValue());
-        }
-    }
-
-    /**
      * @param val Value.
      */
     void doWriteEnum(@Nullable Enum<?> val) {
@@ -1218,14 +1201,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
     }
 
     /**
-     * @param e Map entry.
-     * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
-     */
-    void writeMapEntryField(@Nullable Map.Entry<?, ?> e) throws BinaryObjectException {
-        doWriteMapEntry(e);
-    }
-
-    /**
      * @param val Value.
      */
     void writeEnumField(@Nullable Enum<?> val) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index 5244da8..5063a1e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -119,9 +119,6 @@ public class GridPortableMarshaller {
     public static final byte MAP = 25;
 
     /** */
-    public static final byte MAP_ENTRY = 26;
-
-    /** */
     public static final byte PORTABLE_OBJ = 27;
 
     /** */
@@ -167,30 +164,12 @@ public class GridPortableMarshaller {
     public static final byte LINKED_HASH_SET = 4;
 
     /** */
-    public static final byte TREE_SET = 5;
-
-    /** */
-    public static final byte CONC_SKIP_LIST_SET = 6;
-
-    /** */
-    public static final byte CONC_LINKED_QUEUE = 7;
-
-    /** */
     public static final byte HASH_MAP = 1;
 
     /** */
     public static final byte LINKED_HASH_MAP = 2;
 
     /** */
-    public static final byte TREE_MAP = 3;
-
-    /** */
-    public static final byte CONC_HASH_MAP = 4;
-
-    /** */
-    public static final byte PROPERTIES_MAP = 5;
-
-    /** */
     public static final int OBJECT_TYPE_ID = -1;
 
     /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 50c8bb5..2dda9eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -205,7 +205,6 @@ public class PortableClassDescriptor {
             case OBJECT_ARR:
             case COL:
             case MAP:
-            case MAP_ENTRY:
             case PORTABLE_OBJ:
             case ENUM:
             case PORTABLE_ENUM:
@@ -536,11 +535,6 @@ public class PortableClassDescriptor {
 
                 break;
 
-            case MAP_ENTRY:
-                writer.doWriteMapEntry((Map.Entry<?, ?>)obj);
-
-                break;
-
             case ENUM:
                 writer.doWriteEnum((Enum<?>)obj);
 
@@ -794,6 +788,7 @@ public class PortableClassDescriptor {
      *
      * @return {@code true} if to use, {@code false} otherwise.
      */
+    @SuppressWarnings("unchecked")
     private boolean initUseOptimizedMarshallerFlag() {
         for (Class c = cls; c != null && !c.equals(Object.class); c = c.getSuperclass()) {
             try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 2c7e4c3..f02867b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -17,6 +17,33 @@
 
 package org.apache.ignite.internal.portable;
 
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.cache.CacheKeyConfiguration;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.processors.datastructures.CollocatedQueueItemKey;
+import org.apache.ignite.internal.processors.datastructures.CollocatedSetItemKey;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.marshaller.MarshallerContext;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.jetbrains.annotations.Nullable;
+import org.jsr166.ConcurrentHashMap8;
+
 import java.io.Externalizable;
 import java.io.File;
 import java.io.IOException;
@@ -41,43 +68,11 @@ import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
 import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryInvalidTypeException;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinarySerializer;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.cache.CacheKeyConfiguration;
-import org.apache.ignite.cache.affinity.AffinityKeyMapped;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.IgnitionEx;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.datastructures.CollocatedQueueItemKey;
-import org.apache.ignite.internal.processors.datastructures.CollocatedSetItemKey;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.marshaller.MarshallerContext;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.jetbrains.annotations.Nullable;
-import org.jsr166.ConcurrentHashMap8;
 
 /**
  * Portable context.
@@ -164,16 +159,9 @@ public class PortableContext implements Externalizable {
         colTypes.put(LinkedList.class, GridPortableMarshaller.LINKED_LIST);
         colTypes.put(HashSet.class, GridPortableMarshaller.HASH_SET);
         colTypes.put(LinkedHashSet.class, GridPortableMarshaller.LINKED_HASH_SET);
-        colTypes.put(TreeSet.class, GridPortableMarshaller.TREE_SET);
-        colTypes.put(ConcurrentSkipListSet.class, GridPortableMarshaller.CONC_SKIP_LIST_SET);
-        colTypes.put(ConcurrentLinkedQueue.class, GridPortableMarshaller.CONC_LINKED_QUEUE);
 
         mapTypes.put(HashMap.class, GridPortableMarshaller.HASH_MAP);
         mapTypes.put(LinkedHashMap.class, GridPortableMarshaller.LINKED_HASH_MAP);
-        mapTypes.put(TreeMap.class, GridPortableMarshaller.TREE_MAP);
-        mapTypes.put(ConcurrentHashMap.class, GridPortableMarshaller.CONC_HASH_MAP);
-        mapTypes.put(ConcurrentHashMap8.class, GridPortableMarshaller.CONC_HASH_MAP);
-        mapTypes.put(Properties.class, GridPortableMarshaller.PROPERTIES_MAP);
 
         // IDs range from [0..200] is used by Java SDK API and GridGain legacy API
 
@@ -210,14 +198,9 @@ public class PortableContext implements Externalizable {
         registerPredefinedType(LinkedList.class, 0);
         registerPredefinedType(HashSet.class, 0);
         registerPredefinedType(LinkedHashSet.class, 0);
-        registerPredefinedType(TreeSet.class, 0);
-        registerPredefinedType(ConcurrentSkipListSet.class, 0);
 
         registerPredefinedType(HashMap.class, 0);
         registerPredefinedType(LinkedHashMap.class, 0);
-        registerPredefinedType(TreeMap.class, 0);
-        registerPredefinedType(ConcurrentHashMap.class, 0);
-        registerPredefinedType(ConcurrentHashMap8.class, 0);
 
         registerPredefinedType(GridMapEntry.class, 60);
         registerPredefinedType(IgniteBiTuple.class, 61);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index 5d794ca..125bb25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -17,15 +17,15 @@
 
 package org.apache.ignite.internal.portable;
 
-import java.util.concurrent.ConcurrentLinkedQueue;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryCollectionFactory;
 import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryMapFactory;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectException;
 import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.internal.portable.builder.PortableLazyValue;
 import org.apache.ignite.internal.portable.streams.PortableInputStream;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
@@ -35,8 +35,6 @@ import org.jsr166.ConcurrentHashMap8;
 import java.io.ByteArrayInputStream;
 import java.io.Externalizable;
 import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Timestamp;
@@ -50,7 +48,6 @@ import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
@@ -68,9 +65,6 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLASS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.COL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CONC_HASH_MAP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CONC_LINKED_QUEUE;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CONC_SKIP_LIST_SET;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.DECIMAL;
@@ -92,14 +86,12 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.LINKED_
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENTRY;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJECT_TYPE_ID;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.OPTM_MARSH;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.PORTABLE_OBJ;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROPERTIES_MAP;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
@@ -107,8 +99,6 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TREE_MAP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TREE_SET;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.USER_COL;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.USER_SET;
@@ -271,7 +261,6 @@ public class PortableUtils {
         FIELD_TYPE_NAMES[PORTABLE_OBJ] = "Object";
         FIELD_TYPE_NAMES[COL] = "Collection";
         FIELD_TYPE_NAMES[MAP] = "Map";
-        FIELD_TYPE_NAMES[MAP_ENTRY] = "Entry";
         FIELD_TYPE_NAMES[CLASS] = "Class";
         FIELD_TYPE_NAMES[BYTE_ARR] = "byte[]";
         FIELD_TYPE_NAMES[SHORT_ARR] = "short[]";
@@ -620,15 +609,12 @@ public class PortableUtils {
         if (cls.isArray())
             return cls.getComponentType().isEnum() || cls.getComponentType() == Enum.class ? ENUM_ARR : OBJ_ARR;
 
-        if (Collection.class.isAssignableFrom(cls))
+        if (isSpecialCollection(cls))
             return COL;
 
-        if (Map.class.isAssignableFrom(cls))
+        if (isSpecialMap(cls))
             return MAP;
 
-        if (Map.Entry.class.isAssignableFrom(cls))
-            return MAP_ENTRY;
-
         return OBJ;
     }
 
@@ -1004,19 +990,16 @@ public class PortableUtils {
         else if (cls == Timestamp[].class)
             return BinaryWriteMode.TIMESTAMP_ARR;
         else if (cls.isArray())
-            return cls.getComponentType().isEnum() ?
-                BinaryWriteMode.ENUM_ARR : BinaryWriteMode.OBJECT_ARR;
+            return cls.getComponentType().isEnum() ? BinaryWriteMode.ENUM_ARR : BinaryWriteMode.OBJECT_ARR;
         else if (cls == BinaryObjectImpl.class)
             return BinaryWriteMode.PORTABLE_OBJ;
         else if (Binarylizable.class.isAssignableFrom(cls))
             return BinaryWriteMode.PORTABLE;
         else if (Externalizable.class.isAssignableFrom(cls))
             return BinaryWriteMode.EXTERNALIZABLE;
-        else if (Map.Entry.class.isAssignableFrom(cls))
-            return BinaryWriteMode.MAP_ENTRY;
-        else if (Collection.class.isAssignableFrom(cls))
+        else if (isSpecialCollection(cls))
             return BinaryWriteMode.COL;
-        else if (Map.class.isAssignableFrom(cls))
+        else if (isSpecialMap(cls))
             return BinaryWriteMode.MAP;
         else if (cls.isEnum())
             return BinaryWriteMode.ENUM;
@@ -1027,6 +1010,27 @@ public class PortableUtils {
     }
 
     /**
+     * Check if class represents a collection which must be treated specially.
+     *
+     * @param cls Class.
+     * @return {@code True} if this is a special collection class.
+     */
+    private static boolean isSpecialCollection(Class cls) {
+        return ArrayList.class.equals(cls) || LinkedList.class.equals(cls) ||
+            HashSet.class.equals(cls) || LinkedHashSet.class.equals(cls);
+    }
+
+    /**
+     * Check if class represents a map which must be treated specially.
+     *
+     * @param cls Class.
+     * @return {@code True} if this is a special map class.
+     */
+    private static boolean isSpecialMap(Class cls) {
+        return HashMap.class.equals(cls) || LinkedHashMap.class.equals(cls);
+    }
+
+    /**
      * @return Value.
      */
     public static byte[] doReadByteArray(PortableInputStream in) {
@@ -1688,9 +1692,6 @@ public class PortableUtils {
             case MAP:
                 return doReadMap(in, ctx, ldr, handles, false, null);
 
-            case MAP_ENTRY:
-                return doReadMapEntry(in, ctx, ldr, handles, false);
-
             case PORTABLE_OBJ:
                 return doReadPortableObject(in, ctx);
 
@@ -1738,13 +1739,13 @@ public class PortableUtils {
 
     /**
      * @param deserialize Deep flag.
-     * @param cls Collection class.
+     * @param factory Collection factory.
      * @return Value.
      * @throws BinaryObjectException In case of error.
      */
     @SuppressWarnings("unchecked")
     public static Collection<?> doReadCollection(PortableInputStream in, PortableContext ctx, ClassLoader ldr,
-        BinaryReaderHandlesHolder handles, boolean deserialize, @Nullable Class<? extends Collection> cls)
+        BinaryReaderHandlesHolder handles, boolean deserialize, BinaryCollectionFactory factory)
         throws BinaryObjectException {
         int hPos = positionForHandle(in);
 
@@ -1756,20 +1757,8 @@ public class PortableUtils {
 
         Collection<Object> col;
 
-        if (cls != null) {
-            try {
-                Constructor<? extends Collection> cons = cls.getConstructor();
-
-                col = cons.newInstance();
-            }
-            catch (NoSuchMethodException ignored) {
-                throw new BinaryObjectException("Collection class doesn't have public default constructor: " +
-                    cls.getName());
-            }
-            catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
-                throw new BinaryObjectException("Failed to instantiate collection: " + cls.getName(), e);
-            }
-        }
+        if (factory != null)
+            col = factory.create(size);
         else {
             switch (colType) {
                 case ARR_LIST:
@@ -1792,21 +1781,6 @@ public class PortableUtils {
 
                     break;
 
-                case TREE_SET:
-                    col = new TreeSet<>();
-
-                    break;
-
-                case CONC_SKIP_LIST_SET:
-                    col = new ConcurrentSkipListSet<>();
-
-                    break;
-
-                case CONC_LINKED_QUEUE:
-                    col = new ConcurrentLinkedQueue<>();
-
-                    break;
-
                 case USER_SET:
                     col = U.newHashSet(size);
 
@@ -1832,13 +1806,13 @@ public class PortableUtils {
 
     /**
      * @param deserialize Deep flag.
-     * @param cls Map class.
+     * @param factory Map factory.
      * @return Value.
      * @throws BinaryObjectException In case of error.
      */
     @SuppressWarnings("unchecked")
     public static Map<?, ?> doReadMap(PortableInputStream in, PortableContext ctx, ClassLoader ldr,
-        BinaryReaderHandlesHolder handles, boolean deserialize, @Nullable Class<? extends Map> cls)
+        BinaryReaderHandlesHolder handles, boolean deserialize, BinaryMapFactory factory)
         throws BinaryObjectException {
         int hPos = positionForHandle(in);
 
@@ -1850,20 +1824,8 @@ public class PortableUtils {
 
         Map<Object, Object> map;
 
-        if (cls != null) {
-            try {
-                Constructor<? extends Map> cons = cls.getConstructor();
-
-                map = cons.newInstance();
-            }
-            catch (NoSuchMethodException ignored) {
-                throw new BinaryObjectException("Map class doesn't have public default constructor: " +
-                    cls.getName());
-            }
-            catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
-                throw new BinaryObjectException("Failed to instantiate map: " + cls.getName(), e);
-            }
-        }
+        if (factory != null)
+            map = factory.create(size);
         else {
             switch (mapType) {
                 case HASH_MAP:
@@ -1876,26 +1838,11 @@ public class PortableUtils {
 
                     break;
 
-                case TREE_MAP:
-                    map = new TreeMap<>();
-
-                    break;
-
-                case CONC_HASH_MAP:
-                    map = new ConcurrentHashMap<>(size);
-
-                    break;
-
                 case USER_COL:
                     map = U.newHashMap(size);
 
                     break;
 
-                case PROPERTIES_MAP:
-                    map = new Properties();
-
-                    break;
-
                 default:
                     throw new BinaryObjectException("Invalid map type: " + mapType);
             }
@@ -1914,25 +1861,6 @@ public class PortableUtils {
     }
 
     /**
-     * @param deserialize Deserialize flag flag.
-     * @return Value.
-     * @throws BinaryObjectException In case of error.
-     */
-    public static Map.Entry<?, ?> doReadMapEntry(PortableInputStream in, PortableContext ctx, ClassLoader ldr,
-        BinaryReaderHandlesHolder handles, boolean deserialize) throws BinaryObjectException {
-        int hPos = positionForHandle(in);
-
-        Object val1 = deserializeOrUnmarshal(in, ctx, ldr, handles, deserialize);
-        Object val2 = deserializeOrUnmarshal(in, ctx, ldr, handles, deserialize);
-
-        GridMapEntry entry = new GridMapEntry<>(val1, val2);
-
-        handles.setHandle(entry, hPos);
-
-        return entry;
-    }
-
-    /**
      * Deserialize or unmarshal the object.
      *
      * @param deserialize Deserialize.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
index cf27da4..0b7e0b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -344,12 +344,6 @@ public class PortableBuilderReader implements PortablePositionReadable {
                 return;
             }
 
-            case GridPortableMarshaller.MAP_ENTRY:
-                skipValue();
-                skipValue();
-
-                return;
-
             case GridPortableMarshaller.PORTABLE_OBJ:
                 len = readInt() + 4;
 
@@ -448,7 +442,6 @@ public class PortableBuilderReader implements PortablePositionReadable {
             case GridPortableMarshaller.OBJ_ARR:
             case GridPortableMarshaller.COL:
             case GridPortableMarshaller.MAP:
-            case GridPortableMarshaller.MAP_ENTRY:
                 return new LazyCollection(pos);
 
             case GridPortableMarshaller.ENUM: {
@@ -732,8 +725,6 @@ public class PortableBuilderReader implements PortablePositionReadable {
 
                     case GridPortableMarshaller.HASH_SET:
                     case GridPortableMarshaller.LINKED_HASH_SET:
-                    case GridPortableMarshaller.TREE_SET:
-                    case GridPortableMarshaller.CONC_SKIP_LIST_SET:
                         return new PortableLazySet(this, size);
                 }
 
@@ -749,9 +740,6 @@ public class PortableBuilderReader implements PortablePositionReadable {
             case GridPortableMarshaller.ENUM_ARR:
                 return new PortableEnumArrayLazyValue(this);
 
-            case GridPortableMarshaller.MAP_ENTRY:
-                return new PortableLazyMapEntry(this);
-
             case GridPortableMarshaller.PORTABLE_OBJ: {
                 int size = readInt();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
index 52f84c6..d5923ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java
@@ -19,14 +19,15 @@ package org.apache.ignite.internal.portable.builder;
 
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.internal.portable.BinaryMetadata;
-import org.apache.ignite.internal.portable.GridPortableMarshaller;
 import org.apache.ignite.internal.portable.BinaryObjectExImpl;
+import org.apache.ignite.internal.portable.BinaryWriterExImpl;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
 import org.apache.ignite.internal.portable.PortableContext;
 import org.apache.ignite.internal.portable.PortableUtils;
-import org.apache.ignite.internal.portable.BinaryWriterExImpl;
-import org.apache.ignite.internal.util.*;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.IdentityHashMap;
+import java.util.Map;
 
 /**
  *
@@ -118,13 +119,7 @@ class PortableBuilderSerializer {
             writer.writeByte(GridPortableMarshaller.COL);
             writer.writeInt(c.size());
 
-            byte colType;
-
-            if (c instanceof GridConcurrentSkipListSet)
-                colType = GridPortableMarshaller.CONC_SKIP_LIST_SET;
-            else
-                colType = writer.context().collectionType(c.getClass());
-
+            byte colType = writer.context().collectionType(c.getClass());
 
             writer.writeByte(colType);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
deleted file mode 100644
index 5ebb223..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMapEntry.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.portable.builder;
-
-import org.apache.ignite.internal.portable.*;
-
-import java.util.Map;
-
-/**
- *
- */
-class PortableLazyMapEntry implements Map.Entry<Object, Object>, PortableBuilderSerializationAware {
-    /** */
-    private final Object key;
-
-    /** */
-    private Object val;
-
-    /**
-     * @param reader GridMutablePortableReader
-     */
-    PortableLazyMapEntry(PortableBuilderReader reader) {
-        key = reader.parseValue();
-        val = reader.parseValue();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object getKey() {
-        return PortableUtils.unwrapLazy(key);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object getValue() {
-        return PortableUtils.unwrapLazy(val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object setValue(Object val) {
-        Object res = getValue();
-
-        this.val = val;
-
-        return res;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void writeTo(BinaryWriterExImpl writer, PortableBuilderSerializer ctx) {
-        writer.writeByte(GridPortableMarshaller.MAP_ENTRY);
-
-        ctx.writeValue(writer, key);
-        ctx.writeValue(writer, val);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
index d667e07..037adf9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -40,6 +40,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Queue;
@@ -50,7 +51,9 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentSkipListSet;
 import junit.framework.Assert;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryCollectionFactory;
 import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryMapFactory;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.binary.BinaryObjectException;
@@ -383,6 +386,50 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Test serialization of custom collections.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public void testCustomCollections() throws Exception {
+        CustomCollections cc = new CustomCollections();
+
+        cc.list.add(1);
+        cc.customList.add(2);
+
+        CustomCollections copiedCc = marshalUnmarshal(cc);
+
+        assert copiedCc.customList.getClass().equals(CustomArrayList.class);
+
+        assertEquals(cc.list.size(), copiedCc.list.size());
+        assertEquals(cc.customList.size(), copiedCc.customList.size());
+
+        assertEquals(cc.list.get(0), copiedCc.list.get(0));
+        assertEquals(cc.customList.get(0), copiedCc.customList.get(0));
+    }
+
+    /**
+     * Test custom collections with factories.
+     *
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("unchecked")
+    public void testCustomCollectionsWithFactory() throws Exception {
+        CustomCollectionsWithFactory cc = new CustomCollectionsWithFactory();
+
+        cc.list.add(new DummyHolder(1));
+        cc.map.put(new DummyHolder(2), new DummyHolder(3));
+
+        CustomCollectionsWithFactory copiedCc = marshalUnmarshal(cc);
+
+        assertEquals(cc.list.size(), copiedCc.list.size());
+        assertEquals(cc.map.size(), copiedCc.map.size());
+
+        assertEquals(cc.list.get(0), copiedCc.list.get(0));
+        assertEquals(cc.map.get(new DummyHolder(2)), copiedCc.map.get(new DummyHolder(2)));
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testExternalizableHashCode() throws Exception {
@@ -1153,8 +1200,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
         ));
 
         Object[] arr = new Object[] {new Value(1), new Value(2), new Value(3)};
-        Collection<Value> col = Arrays.asList(new Value(4), new Value(5), new Value(6));
-        Map<Key, Value> map = F.asMap(new Key(10), new Value(10), new Key(20), new Value(20), new Key(30), new Value(30));
+        Collection<Value> col = new ArrayList<>(Arrays.asList(new Value(4), new Value(5), new Value(6)));
+        Map<Key, Value> map = new HashMap<>(F.asMap(new Key(10), new Value(10), new Key(20), new Value(20), new Key(30), new Value(30)));
 
         CollectionFieldsObject obj = new CollectionFieldsObject(arr, col, map);
 
@@ -3460,6 +3507,82 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * Custom array list.
+     */
+    private static class CustomArrayList extends ArrayList {
+        // No-op.
+    }
+
+    /**
+     * Custom hash map.
+     */
+    private static class CustomHashMap extends HashMap {
+        // No-op.
+    }
+
+    /**
+     * Holder for non-stadard collections.
+     */
+    private static class CustomCollections {
+        public List list = new ArrayList();
+        public List customList = new CustomArrayList();
+    }
+
+    @SuppressWarnings("unchecked")
+    private static class CustomCollectionsWithFactory implements Binarylizable {
+        public List list = new CustomArrayList();
+        public Map map = new CustomHashMap();
+
+        /** {@inheritDoc} */
+        @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+            writer.writeCollection("list", list);
+            writer.writeMap("map", map);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+            list = (List)reader.readCollection("list", new BinaryCollectionFactory<Object>() {
+                @Override public Collection<Object> create(int size) {
+                    return new CustomArrayList();
+                }
+            });
+
+            map = reader.readMap("map", new BinaryMapFactory<Object, Object>() {
+                @Override public Map<Object, Object> create(int size) {
+                    return new CustomHashMap();
+                }
+            });
+        }
+    }
+
+    /**
+     * Dummy value holder.
+     */
+    private static class DummyHolder {
+        /** Value. */
+        public int val;
+
+        /**
+         * Constructor.
+         *
+         * @param val Value.
+         */
+        public DummyHolder(int val) {
+            this.val = val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            return o != null && o instanceof DummyHolder && ((DummyHolder)o).val == val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            return val;
+        }
+    }
+
+    /**
      */
     private static class CycleLinkObject {
         /** */

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
index cfeb714..06535d2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
@@ -21,6 +21,24 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
+import org.apache.ignite.internal.portable.mutabletest.GridBinaryMarshalerAwareTestClass;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.processors.cache.portable.IgniteBinaryImpl;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Assert;
+
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
@@ -35,27 +53,11 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
-import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
-import org.apache.ignite.internal.portable.mutabletest.GridBinaryMarshalerAwareTestClass;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.cache.portable.IgniteBinaryImpl;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.Assert;
 
 import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Address;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.AddressBook;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Addresses;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Companies;
 import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Company;
 import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
 import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectArrayList;
@@ -148,15 +150,6 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
 
                     break;
                 }
-
-                case "entry":
-                    assertEquals(((Map.Entry)expVal).getKey(), ((Map.Entry)actVal).getKey());
-                    assertEquals(((Map.Entry)expVal).getValue(), ((Map.Entry)actVal).getValue());
-                    break;
-
-                default:
-                    assertTrue(field.getName(), Objects.deepEquals(expVal, actVal));
-                    break;
             }
         }
     }
@@ -923,27 +916,6 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
     /**
      *
      */
-    public void testMapEntryModification() {
-        TestObjectContainer obj = new TestObjectContainer();
-        obj.foo = ImmutableMap.of(1, "a").entrySet().iterator().next();
-
-        BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
-        Map.Entry<Object, Object> entry = mutableObj.getField("foo");
-
-        assertEquals(1, entry.getKey());
-        assertEquals("a", entry.getValue());
-
-        entry.setValue("b");
-
-        TestObjectContainer res = mutableObj.build().deserialize();
-
-        assertEquals(new GridMapEntry<>(1, "b"), res.foo);
-    }
-
-    /**
-     *
-     */
     public void testMapEntryOverride() {
         TestObjectContainer obj = new TestObjectContainer();
 
@@ -1116,30 +1088,39 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
      *
      */
     public void testChangeMap() {
-        AddressBook addrBook = new AddressBook();
+        Addresses addrs = new Addresses();
+
+        addrs.addCompany(new Company(1, "Google inc", 100,
+            new Address("Saint-Petersburg", "Torzhkovskya", 1, 53), "occupation"));
+
+        addrs.addCompany(new Company(2, "Apple inc", 100,
+            new Address("Saint-Petersburg", "Torzhkovskya", 1, 54), "occupation"));
+
+        addrs.addCompany(new Company(3, "Microsoft", 100,
+            new Address("Saint-Petersburg", "Torzhkovskya", 1, 55), "occupation"));
+
+        addrs.addCompany(new Company(4, "Oracle", 100,
+            new Address("Saint-Petersburg", "Nevskiy", 1, 1), "occupation"));
 
-        addrBook.addCompany(new Company(1, "Google inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 53), "occupation"));
-        addrBook.addCompany(new Company(2, "Apple inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 54), "occupation"));
-        addrBook.addCompany(new Company(3, "Microsoft", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 55), "occupation"));
-        addrBook.addCompany(new Company(4, "Oracle", 100, new Address("Saint-Petersburg", "Nevskiy", 1, 1), "occupation"));
+        BinaryObjectBuilderImpl binaryAddres = wrap(addrs);
 
-        BinaryObjectBuilderImpl mutableObj = wrap(addrBook);
+        Map<String, BinaryObjectBuilderImpl> map = binaryAddres.getField("companyByStreet");
 
-        Map<String, List<BinaryObjectBuilderImpl>> map = mutableObj.getField("companyByStreet");
+        BinaryObjectBuilderImpl binaryCompanies = map.get("Torzhkovskya");
 
-        List<BinaryObjectBuilderImpl> list = map.get("Torzhkovskya");
+        List<BinaryObjectBuilderImpl> binaryCompaniesList = binaryCompanies.getField("companies");
 
-        BinaryObjectBuilderImpl company = list.get(0);
+        BinaryObjectBuilderImpl company = binaryCompaniesList.get(0);
 
         assert "Google inc".equals(company.<String>getField("name"));
 
-        list.remove(0);
+        binaryCompaniesList.remove(0);
 
-        AddressBook res = mutableObj.build().deserialize();
+        Addresses res = binaryAddres.build().deserialize();
 
         assertEquals(Arrays.asList("Nevskiy", "Torzhkovskya"), new ArrayList<>(res.getCompanyByStreet().keySet()));
 
-        List<Company> torzhkovskyaCompanies = res.getCompanyByStreet().get("Torzhkovskya");
+        Companies torzhkovskyaCompanies = res.getCompanyByStreet().get("Torzhkovskya");
 
         assertEquals(2, torzhkovskyaCompanies.size());
         assertEquals("Apple inc", torzhkovskyaCompanies.get(0).name);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
index 69687ab..b568cb5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
@@ -31,6 +31,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
+
+import org.apache.ignite.binary.BinaryMapFactory;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.internal.util.lang.GridMapEntry;
 import org.apache.ignite.binary.BinaryObject;
 
@@ -315,7 +321,10 @@ public class GridPortableTestClasses {
     /**
      *
      */
-    public static class Address {
+    public static class Address implements Serializable {
+        /** SUID. */
+        private static final long serialVersionUID = 0L;
+
         /** City. */
         public String city;
 
@@ -354,7 +363,10 @@ public class GridPortableTestClasses {
     /**
      *
      */
-    public static class Company {
+    public static class Company implements Serializable {
+        /** SUID. */
+        private static final long serialVersionUID = 0L;
+
         /** ID. */
         public int id;
 
@@ -396,28 +408,50 @@ public class GridPortableTestClasses {
     }
 
     /**
-     *
+     * Companies.
      */
-    public static class AddressBook {
-        /** */
-        private Map<String, List<Company>> companyByStreet = new TreeMap<>();
+    public static class Companies {
+        /** Companies. */
+        private List<Company> companies = new ArrayList<>();
 
         /**
-         * @param street Street.
+         * @param idx Index.
          * @return Company.
          */
-        public List<Company> findCompany(String street) {
-            return companyByStreet.get(street);
+        public Company get(int idx) {
+            return companies.get(idx);
+        }
+
+        /**
+         * @param company Company.
+         */
+        public void add(Company company) {
+            companies.add(company);
+        }
+
+        /**
+         * @return Size.
+         */
+        public int size() {
+            return companies.size();
         }
+    }
+
+    /**
+     *
+     */
+    public static class Addresses implements Binarylizable {
+        /** */
+        private Map<String, Companies> companyByStreet = new TreeMap<>();
 
         /**
          * @param company Company.
          */
         public void addCompany(Company company) {
-            List<Company> list = companyByStreet.get(company.address.street);
+            Companies list = companyByStreet.get(company.address.street);
 
             if (list == null) {
-                list = new ArrayList<>();
+                list = new Companies();
 
                 companyByStreet.put(company.address.street, list);
             }
@@ -428,16 +462,23 @@ public class GridPortableTestClasses {
         /**
          * @return map
          */
-        public Map<String, List<Company>> getCompanyByStreet() {
+        public Map<String, Companies> getCompanyByStreet() {
             return companyByStreet;
         }
 
-        /**
-         * @param companyByStreet map
-         */
-        public void setCompanyByStreet(Map<String, List<Company>> companyByStreet) {
-            this.companyByStreet = companyByStreet;
+        /** {@inheritDoc} */
+        @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+            writer.writeMap("companyByStreet", companyByStreet);
         }
-    }
 
+        /** {@inheritDoc} */
+        @SuppressWarnings("unchecked")
+        @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+            companyByStreet = reader.readMap("companyByStreet", new BinaryMapFactory<String, Companies>() {
+                @Override public Map<String, Companies> create(int size) {
+                    return new TreeMap<>();
+                }
+            });
+        }
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
index 8d47c24..4e7e2df 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
@@ -1496,7 +1496,7 @@ BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
 
 BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
 {
-    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+    CollectionType typ = IGNITE_COLLECTION_LINKED_HASH_SET;
 
     CheckRawCollectionEmpty(&typ);
 }
@@ -1508,7 +1508,7 @@ BOOST_AUTO_TEST_CASE(TestCollection)
 
 BOOST_AUTO_TEST_CASE(TestCollectionTyped)
 {
-    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+    CollectionType typ = IGNITE_COLLECTION_LINKED_HASH_SET;
 
     CheckRawCollection(&typ);
 }
@@ -1520,7 +1520,7 @@ BOOST_AUTO_TEST_CASE(TestCollectionIterators)
 
 BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
 {
-    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+    CollectionType typ = IGNITE_COLLECTION_LINKED_HASH_SET;
 
     CheckRawCollectionIterators(&typ);
 }
@@ -1573,7 +1573,7 @@ BOOST_AUTO_TEST_CASE(TestMapEmpty)
 
 BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
 {
-    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+    MapType typ = IGNITE_MAP_LINKED_HASH_MAP;
 
     CheckRawMapEmpty(&typ);
 }
@@ -1585,7 +1585,7 @@ BOOST_AUTO_TEST_CASE(TestMap)
 
 BOOST_AUTO_TEST_CASE(TestMapTyped)
 {
-    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+    MapType typ = IGNITE_MAP_LINKED_HASH_MAP;
 
     CheckRawMap(&typ);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
index b2551ec..71177b8 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
@@ -1891,7 +1891,7 @@ BOOST_AUTO_TEST_CASE(TestCollectionEmpty)
 
 BOOST_AUTO_TEST_CASE(TestCollectionEmptyTyped)
 {
-    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+    CollectionType typ = IGNITE_COLLECTION_LINKED_HASH_SET;
 
     CheckCollectionEmpty(&typ);
 }
@@ -1903,7 +1903,7 @@ BOOST_AUTO_TEST_CASE(TestCollection)
 
 BOOST_AUTO_TEST_CASE(testCollectionTyped)
 {
-    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+    CollectionType typ = IGNITE_COLLECTION_LINKED_HASH_SET;
 
     CheckCollection(&typ);
 }
@@ -1915,7 +1915,7 @@ BOOST_AUTO_TEST_CASE(TestCollectionIterators)
 
 BOOST_AUTO_TEST_CASE(TestCollectionIteratorsTyped)
 {
-    CollectionType typ = IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET;
+    CollectionType typ = IGNITE_COLLECTION_LINKED_HASH_SET;
 
     CheckCollectionIterators(&typ);
 }
@@ -1980,7 +1980,7 @@ BOOST_AUTO_TEST_CASE(TestMapEmpty)
 
 BOOST_AUTO_TEST_CASE(TestMapEmptyTyped)
 {
-    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+    MapType typ = IGNITE_MAP_LINKED_HASH_MAP;
 
     CheckMapEmpty(&typ);
 }
@@ -1992,7 +1992,7 @@ BOOST_AUTO_TEST_CASE(TestMap)
 
 BOOST_AUTO_TEST_CASE(TestMapTyped)
 {
-    MapType typ = IGNITE_MAP_CONCURRENT_HASH_MAP;
+    MapType typ = IGNITE_MAP_LINKED_HASH_MAP;
 
     CheckMap(&typ);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h b/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h
index 68ed9f9..7f0fd1e 100644
--- a/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h
+++ b/modules/platforms/cpp/core/include/ignite/binary/binary_consts.h
@@ -52,17 +52,7 @@ namespace ignite
             /**
              * Linked hash set. Maps to LinkedHashSet in Java.
              */
-            IGNITE_COLLECTION_LINKED_HASH_SET = 4,
-
-            /**
-             * Tree set. Maps to TreeSet in Java.
-             */
-            IGNITE_COLLECTION_TREE_SET = 5,
-
-            /**
-             * Concurrent skip list set. Maps to ConcurrentSkipListSet in Java.
-             */
-            IGNITE_COLLECTION_CONCURRENT_SKIP_LIST_SET = 6
+            IGNITE_COLLECTION_LINKED_HASH_SET = 4
         };
 
         /**
@@ -83,22 +73,7 @@ namespace ignite
             /**
              * Linked hash map. Maps to LinkedHashMap in Java.
              */
-            IGNITE_MAP_LINKED_HASH_MAP = 2,
-
-            /**
-             * Tree map. Maps to TreeMap in Java.
-             */
-            IGNITE_MAP_TREE_MAP = 3,
-            
-            /**
-             * Concurrent hash map. Maps to ConcurrentHashMap in Java.
-             */
-            IGNITE_MAP_CONCURRENT_HASH_MAP = 4,
-            
-            /**
-             * Properties map. Maps to Properties in Java.
-             */
-            IGNITE_MAP_PROPERTIES_MAP = 5
+            IGNITE_MAP_LINKED_HASH_MAP = 2
         };
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
index 7ef6259..f41514f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -972,13 +972,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                     }
 
                     break;
-
-                case BinaryUtils.TypeMapEntry:
-                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-
-                    break;
-
+                    
                 case BinaryUtils.TypeBinary:
                     TransferArray(inStream, outStream, 1); // Data array.
                     TransferBytes(inStream, outStream, 4); // Offset in array.

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
index 506b56d..7596992 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs
@@ -69,7 +69,6 @@ namespace Apache.Ignite.Core.Impl.Binary
             {typeof (Guid?), BinaryUtils.TypeGuid},
             {typeof (ArrayList), BinaryUtils.TypeCollection},
             {typeof (Hashtable), BinaryUtils.TypeDictionary},
-            {typeof (DictionaryEntry), BinaryUtils.TypeMapEntry},
             {typeof (bool[]), BinaryUtils.TypeArrayBool},
             {typeof (byte[]), BinaryUtils.TypeArrayByte},
             {typeof (sbyte[]), BinaryUtils.TypeArrayByte},
@@ -162,11 +161,8 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             // 13. Arbitrary dictionary.
             ReadHandlers[BinaryUtils.TypeDictionary] = new BinarySystemReader(ReadDictionary);
-
-            // 15. Map entry.
-            ReadHandlers[BinaryUtils.TypeMapEntry] = new BinarySystemReader(ReadMapEntry);
             
-            // 16. Enum.
+            // 14. Enum.
             ReadHandlers[BinaryUtils.TypeArrayEnum] = new BinarySystemReader(ReadEnumArray);
         }
 
@@ -218,8 +214,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                 return WriteArrayList;
             if (type == typeof(Hashtable))
                 return WriteHashtable;
-            if (type == typeof(DictionaryEntry))
-                return WriteMapEntry;
+
             if (type.IsArray)
             {
                 // We know how to write any array type.
@@ -612,16 +607,6 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /**
-         * <summary>Write map entry.</summary>
-         */
-        private static void WriteMapEntry(BinaryWriter ctx, object obj)
-        {
-            ctx.Stream.WriteByte(BinaryUtils.TypeMapEntry);
-
-            BinaryUtils.WriteMapEntry(ctx, (DictionaryEntry)obj);
-        }
-
-        /**
          * <summary>Write binary object.</summary>
          */
         private static void WriteBinary(BinaryWriter ctx, object obj)
@@ -697,14 +682,6 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /**
-         * <summary>Read map entry.</summary>
-         */
-        private static object ReadMapEntry(BinaryReader ctx, Type type)
-        {
-            return BinaryUtils.ReadMapEntry(ctx);
-        }
-        
-        /**
          * <summary>Read delegate.</summary>
          * <param name="ctx">Read context.</param>
          * <param name="type">Type.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/6cdd5804/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index 4c54dea..1ae5722 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Impl.Binary
 {
     using System;
     using System.Collections;
-    using System.Collections.Concurrent;
     using System.Collections.Generic;
     using System.Diagnostics;
     using System.Diagnostics.CodeAnalysis;
@@ -133,10 +132,7 @@ namespace Apache.Ignite.Core.Impl.Binary
 
         /** Type: map. */
         public const byte TypeDictionary = 25;
-
-        /** Type: map entry. */
-        public const byte TypeMapEntry = 26;
-
+        
         /** Type: binary object. */
         public const byte TypeBinary = 27;
 
@@ -199,34 +195,13 @@ namespace Apache.Ignite.Core.Impl.Binary
 
         /** Collection: linked list. */
         public const byte CollectionLinkedList = 2;
-
-        /** Collection: hash set. */
-        public const byte CollectionHashSet = 3;
-
-        /** Collection: hash set. */
-        public const byte CollectionLinkedHashSet = 4;
-
-        /** Collection: sorted set. */
-        public const byte CollectionSortedSet = 5;
-
-        /** Collection: concurrent bag. */
-        public const byte CollectionConcurrentBag = 6;
-
+        
         /** Map: custom. */
         public const byte MapCustom = 0;
 
         /** Map: hash map. */
         public const byte MapHashMap = 1;
-
-        /** Map: linked hash map. */
-        public const byte MapLinkedHashMap = 2;
-
-        /** Map: sorted map. */
-        public const byte MapSortedMap = 3;
-
-        /** Map: concurrent hash map. */
-        public const byte MapConcurrentHashMap = 4;
-
+        
         /** Byte "0". */
         public const byte ByteZero = 0;
 
@@ -1096,10 +1071,6 @@ namespace Apache.Ignite.Core.Impl.Binary
                     colType = CollectionArrayList;
                 else if (genType == typeof (LinkedList<>))
                     colType = CollectionLinkedList;
-                else if (genType == typeof (SortedSet<>))
-                    colType = CollectionSortedSet;
-                else if (genType == typeof (ConcurrentBag<>))
-                    colType = CollectionConcurrentBag;
                 else
                     colType = CollectionCustom;
             }
@@ -1147,10 +1118,6 @@ namespace Apache.Ignite.Core.Impl.Binary
             {
                 if (colType == CollectionLinkedList)
                     res = new LinkedList<object>();
-                else if (colType == CollectionSortedSet)
-                    res = new SortedSet<object>();
-                else if (colType == CollectionConcurrentBag)
-                    res = new ConcurrentBag<object>();
                 else
                     res = new ArrayList(len);
             }
@@ -1181,14 +1148,7 @@ namespace Apache.Ignite.Core.Impl.Binary
             {
                 var genType = valType.GetGenericTypeDefinition();
 
-                if (genType == typeof (Dictionary<,>))
-                    dictType = MapHashMap;
-                else if (genType == typeof (SortedDictionary<,>))
-                    dictType = MapSortedMap;
-                else if (genType == typeof (ConcurrentDictionary<,>))
-                    dictType = MapConcurrentHashMap;
-                else
-                    dictType = MapCustom;
+                dictType = genType == typeof (Dictionary<,>) ? MapHashMap : MapCustom;
             }
             else
                 dictType = valType == typeof (Hashtable) ? MapHashMap : MapCustom;
@@ -1221,29 +1181,16 @@ namespace Apache.Ignite.Core.Impl.Binary
          * <param name="factory">Factory delegate.</param>
          * <returns>Dictionary.</returns>
          */
-        public static IDictionary ReadDictionary(BinaryReader ctx,
-            DictionaryFactory factory)
+        public static IDictionary ReadDictionary(BinaryReader ctx, DictionaryFactory factory)
         {
             IBinaryStream stream = ctx.Stream;
 
             int len = stream.ReadInt();
 
-            byte colType = ctx.Stream.ReadByte();
-
-            IDictionary res;
-
-            if (factory == null)
-            {
-                if (colType == MapSortedMap)
-                    res = new SortedDictionary<object, object>();
-                else if (colType == MapConcurrentHashMap)
-                    res = new ConcurrentDictionary<object, object>(Environment.ProcessorCount, len);
-                else
-                    res = new Hashtable(len);
-            }
-            else
-                res = factory.Invoke(len);
+            // Skip dictionary type as we can do nothing with it here.
+            ctx.Stream.ReadByte();
 
+            var res = factory == null ? new Hashtable(len) : factory.Invoke(len);
 
             for (int i = 0; i < len; i++)
             {
@@ -1257,30 +1204,6 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /**
-         * <summary>Write map entry.</summary>
-         * <param name="ctx">Write context.</param>
-         * <param name="val">Value.</param>
-         */
-        public static void WriteMapEntry(BinaryWriter ctx, DictionaryEntry val)
-        {
-            ctx.Write(val.Key);
-            ctx.Write(val.Value);
-        }
-
-        /**
-         * <summary>Read map entry.</summary>
-         * <param name="ctx">Context.</param>
-         * <returns>Map entry.</returns>
-         */
-        public static DictionaryEntry ReadMapEntry(BinaryReader ctx)
-        {
-            object key = ctx.Deserialize<object>();
-            object val = ctx.Deserialize<object>();
-
-            return new DictionaryEntry(key, val);
-        }
-
-        /**
          * <summary>Write binary object.</summary>
          * <param name="stream">Stream.</param>
          * <param name="val">Value.</param>


Mime
View raw message