You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/03/27 11:00:13 UTC

ignite git commit: IGNITE-4351 .NET: Use BinaryArrayIdentityResolver by default. This closes #1668.

Repository: ignite
Updated Branches:
  refs/heads/master 24f90d6d2 -> 12e240a2d


IGNITE-4351 .NET: Use BinaryArrayIdentityResolver by default. This closes #1668.


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

Branch: refs/heads/master
Commit: 12e240a2d127f32b6883a8ee1b7422d9e59f3f16
Parents: 24f90d6
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Mar 27 14:00:08 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Mar 27 14:00:08 2017 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.Core.Tests.csproj             |   1 -
 .../Binary/BinaryBuilderSelfTest.cs             | 151 +++++--------------
 .../BinaryBuilderSelfTestArrayIdentity.cs       |  34 -----
 .../Binary/BinarySelfTest.cs                    |   8 -
 .../Cache/Query/CacheDmlQueriesTest.cs          |   5 +-
 .../Binary/BinaryArrayEqualityComparer.cs       |   5 +
 .../Binary/IBinaryObjectBuilder.cs              |  10 --
 .../Impl/Binary/BinaryObject.cs                 |  72 +--------
 .../Impl/Binary/BinaryObjectBuilder.cs          |  65 +++-----
 .../Impl/Binary/BinaryUtils.cs                  |  10 ++
 .../Impl/Binary/BinaryWriter.cs                 |   8 +-
 .../Impl/Binary/IBinaryEqualityComparer.cs      |  10 ++
 12 files changed, 94 insertions(+), 285 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 0eb3e39..1540243 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -68,7 +68,6 @@
     <Reference Include="System.Xml.Linq" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Binary\BinaryBuilderSelfTestArrayIdentity.cs" />
     <Compile Include="Binary\BinaryEqualityComparerTest.cs" />
     <Compile Include="Binary\BinaryReaderWriterTest.cs" />
     <Compile Include="Binary\IO\BinaryStreamsTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
index e9ca852..e59611b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -58,57 +58,33 @@ namespace Apache.Ignite.Core.Tests.Binary
                 {
                     TypeConfigurations = new List<BinaryTypeConfiguration>
                     {
-                        new BinaryTypeConfiguration(typeof(Empty)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(Primitives)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(PrimitiveArrays)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(StringDateGuidEnum))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        },
-                        new BinaryTypeConfiguration(typeof(WithRaw)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(MetaOverwrite)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(NestedOuter)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(NestedInner)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(MigrationOuter)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(MigrationInner)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(InversionOuter)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(InversionInner)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(CompositeOuter)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(CompositeInner)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(CompositeArray)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(CompositeContainer))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        },
-                        new BinaryTypeConfiguration(typeof(ToBinary)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(Remove)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(RemoveInner)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(BuilderInBuilderOuter))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        },
-                        new BinaryTypeConfiguration(typeof(BuilderInBuilderInner))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        },
-                        new BinaryTypeConfiguration(typeof(BuilderCollection))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        },
-                        new BinaryTypeConfiguration(typeof(BuilderCollectionItem))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        },
-                        new BinaryTypeConfiguration(typeof(DecimalHolder)) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(TypeEmpty) {EqualityComparer = GetIdentityResolver()},
-                        new BinaryTypeConfiguration(typeof(TestEnumRegistered))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        },
+                        new BinaryTypeConfiguration(typeof(Empty)),
+                        new BinaryTypeConfiguration(typeof(Primitives)),
+                        new BinaryTypeConfiguration(typeof(PrimitiveArrays)),
+                        new BinaryTypeConfiguration(typeof(StringDateGuidEnum)),
+                        new BinaryTypeConfiguration(typeof(WithRaw)),
+                        new BinaryTypeConfiguration(typeof(MetaOverwrite)),
+                        new BinaryTypeConfiguration(typeof(NestedOuter)),
+                        new BinaryTypeConfiguration(typeof(NestedInner)),
+                        new BinaryTypeConfiguration(typeof(MigrationOuter)),
+                        new BinaryTypeConfiguration(typeof(MigrationInner)),
+                        new BinaryTypeConfiguration(typeof(InversionOuter)),
+                        new BinaryTypeConfiguration(typeof(InversionInner)),
+                        new BinaryTypeConfiguration(typeof(CompositeOuter)),
+                        new BinaryTypeConfiguration(typeof(CompositeInner)),
+                        new BinaryTypeConfiguration(typeof(CompositeArray)),
+                        new BinaryTypeConfiguration(typeof(CompositeContainer)),
+                        new BinaryTypeConfiguration(typeof(ToBinary)),
+                        new BinaryTypeConfiguration(typeof(Remove)),
+                        new BinaryTypeConfiguration(typeof(RemoveInner)),
+                        new BinaryTypeConfiguration(typeof(BuilderInBuilderOuter)),
+                        new BinaryTypeConfiguration(typeof(BuilderInBuilderInner)),
+                        new BinaryTypeConfiguration(typeof(BuilderCollection)),
+                        new BinaryTypeConfiguration(typeof(BuilderCollectionItem)),
+                        new BinaryTypeConfiguration(typeof(DecimalHolder)),
+                        new BinaryTypeConfiguration(TypeEmpty),
+                        new BinaryTypeConfiguration(typeof(TestEnumRegistered)),
                         new BinaryTypeConfiguration(typeof(NameMapperTestType))
-                        {
-                            EqualityComparer = GetIdentityResolver()
-                        }
                     },
                     DefaultIdMapper = new IdMapper(),
                     DefaultNameMapper = new NameMapper(),
@@ -130,14 +106,6 @@ namespace Apache.Ignite.Core.Tests.Binary
         }
 
         /// <summary>
-        /// Gets the identity resolver.
-        /// </summary>
-        protected virtual IEqualityComparer<IBinaryObject> GetIdentityResolver()
-        {
-            return null;
-        }
-
-        /// <summary>
         /// Tear down routine.
         /// </summary>
         [TestFixtureTearDown]
@@ -567,7 +535,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
 
             Assert.IsNotNull(binObj);
-            Assert.AreEqual(GetIdentityResolver() == null ? 0 : 1, binObj.GetHashCode());
+            Assert.AreEqual(1, binObj.GetHashCode());
 
             IBinaryType meta = binObj.GetBinaryType();
 
@@ -589,7 +557,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             IBinaryObject binObj = _grid.GetBinary().GetBuilder(TypeEmpty).Build();
 
             Assert.IsNotNull(binObj);
-            Assert.AreEqual(GetIdentityResolver() == null ? 0 : 1, binObj.GetHashCode());
+            Assert.AreEqual(1, binObj.GetHashCode());
 
             IBinaryType meta = binObj.GetBinaryType();
 
@@ -612,17 +580,6 @@ namespace Apache.Ignite.Core.Tests.Binary
         }
 
         /// <summary>
-        /// Test hash code alteration.
-        /// </summary>
-        [Test]
-        public void TestHashCodeChange()
-        {
-            IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Empty)).SetHashCode(100).Build();
-
-            Assert.AreEqual(100, binObj.GetHashCode());
-        }
-
-        /// <summary>
         /// Tests equality and formatting members.
         /// </summary>
         [Test]
@@ -635,8 +592,8 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             Assert.AreEqual(obj1, obj2);
 
-            Assert.AreEqual(0, obj1.GetHashCode());
-            Assert.AreEqual(0, obj2.GetHashCode());
+            Assert.AreEqual(1823354401, obj1.GetHashCode());
+            Assert.AreEqual(1823354401, obj2.GetHashCode());
 
             Assert.IsTrue(Regex.IsMatch(obj1.ToString(), @"myType \[idHash=[0-9]+, str=foo, int=1\]"));
         }
@@ -658,7 +615,6 @@ namespace Apache.Ignite.Core.Tests.Binary
                 .SetField<float>("fFloat", 5)
                 .SetField<double>("fDouble", 6)
                 .SetField("fDecimal", 7.7m)
-                .SetHashCode(100)
                 .Build();
 
             CheckPrimitiveFields1(binObj);
@@ -674,7 +630,6 @@ namespace Apache.Ignite.Core.Tests.Binary
                 .SetFloatField("fFloat", 5)
                 .SetDoubleField("fDouble", 6)
                 .SetDecimalField("fDecimal", 7.7m)
-                .SetHashCode(100)
                 .Build();
 
             CheckPrimitiveFields1(binObj2);
@@ -723,8 +678,6 @@ namespace Apache.Ignite.Core.Tests.Binary
         /// </summary>
         private static void CheckPrimitiveFields1(IBinaryObject binObj)
         {
-            Assert.AreEqual(100, binObj.GetHashCode());
-
             IBinaryType meta = binObj.GetBinaryType();
 
             Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
@@ -809,7 +762,6 @@ namespace Apache.Ignite.Core.Tests.Binary
                 .SetField("fFloat", new float[] { 5 })
                 .SetField("fDouble", new double[] { 6 })
                 .SetField("fDecimal", new decimal?[] { 7.7m })
-                .SetHashCode(100)
                 .Build();
 
             CheckPrimitiveArrayFields1(binObj);
@@ -825,7 +777,6 @@ namespace Apache.Ignite.Core.Tests.Binary
                 .SetFloatArrayField("fFloat", new float[] {5})
                 .SetDoubleArrayField("fDouble", new double[] {6})
                 .SetDecimalArrayField("fDecimal", new decimal?[] {7.7m})
-                .SetHashCode(100)
                 .Build();
 
             CheckPrimitiveArrayFields1(binObj2);
@@ -874,8 +825,6 @@ namespace Apache.Ignite.Core.Tests.Binary
         /// </summary>
         private static void CheckPrimitiveArrayFields1(IBinaryObject binObj)
         {
-            Assert.AreEqual(100, binObj.GetHashCode());
-
             IBinaryType meta = binObj.GetBinaryType();
 
             Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
@@ -965,7 +914,6 @@ namespace Apache.Ignite.Core.Tests.Binary
                 .SetTimestampArrayField("fTimestampArr", new[] { nDate })
                 .SetGuidArrayField("fGuidArr", new[] { nGuid })
                 .SetEnumArrayField("fEnumArr", new[] { TestEnum.One })
-                .SetHashCode(100)
                 .Build();
 
             CheckStringDateGuidEnum1(binObj, nDate, nGuid);
@@ -982,7 +930,6 @@ namespace Apache.Ignite.Core.Tests.Binary
                 .SetTimestampArrayField("fTimestampArr", new[] { nDate })
                 .SetGuidArrayField("fGuidArr", new[] { nGuid })
                 .SetEnumArrayField("fEnumArr", new[] { TestEnum.One })
-                .SetHashCode(100)
                 .Build();
 
             CheckStringDateGuidEnum1(binObj2, nDate, nGuid);
@@ -1036,8 +983,6 @@ namespace Apache.Ignite.Core.Tests.Binary
         /// </summary>
         private void CheckStringDateGuidEnum1(IBinaryObject binObj, DateTime? nDate, Guid? nGuid)
         {
-            Assert.AreEqual(100, binObj.GetHashCode());
-
             IBinaryType meta = binObj.GetBinaryType();
 
             Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
@@ -1179,7 +1124,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             // 1. Test simple array.
             object[] inArr = { new CompositeInner(1) };
 
-            IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+            IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray))
                 .SetField("inArr", inArr).Build();
 
             IBinaryType meta = binObj.GetBinaryType();
@@ -1188,8 +1133,6 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.AreEqual(1, meta.Fields.Count);
             Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
 
-            Assert.AreEqual(100, binObj.GetHashCode());
-
             var binInArr = binObj.GetField<IBinaryObject[]>("inArr").ToArray();
 
             Assert.AreEqual(1, binInArr.Length);
@@ -1202,11 +1145,9 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
 
             // 2. Test addition to array.
-            binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+            binObj = _grid.GetBinary().GetBuilder(binObj)
                 .SetField("inArr", new[] { binInArr[0], null }).Build();
 
-            Assert.AreEqual(200, binObj.GetHashCode());
-
             binInArr = binObj.GetField<IBinaryObject[]>("inArr").ToArray();
 
             Assert.AreEqual(2, binInArr.Length);
@@ -1222,11 +1163,9 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             binInArr[1] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
 
-            binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(300)
+            binObj = _grid.GetBinary().GetBuilder(binObj)
                 .SetField("inArr", binInArr.OfType<object>().ToArray()).Build();
 
-            Assert.AreEqual(300, binObj.GetHashCode());
-
             binInArr = binObj.GetField<IBinaryObject[]>("inArr").ToArray();
 
             Assert.AreEqual(2, binInArr.Length);
@@ -1245,11 +1184,9 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             inArr = new object[] { inner, inner };
 
-            binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+            binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray))
                 .SetField("inArr", inArr).Build();
 
-            Assert.AreEqual(100, binObj.GetHashCode());
-
             binInArr = binObj.GetField<IBinaryObject[]>("inArr").ToArray();
 
             Assert.AreEqual(2, binInArr.Length);
@@ -1265,11 +1202,9 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             binInArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
 
-            binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+            binObj = _grid.GetBinary().GetBuilder(binObj)
                 .SetField("inArr", binInArr.ToArray<object>()).Build();
 
-            Assert.AreEqual(200, binObj.GetHashCode());
-
             binInArr = binObj.GetField<IBinaryObject[]>("inArr").ToArray();
 
             Assert.AreEqual(2, binInArr.Length);
@@ -1286,7 +1221,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             // 4. Test nested object handle inversion.
             CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
 
-            binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+            binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray))
                 .SetField("outArr", outArr.ToArray<object>()).Build();
 
             meta = binObj.GetBinaryType();
@@ -1296,8 +1231,6 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
             Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
 
-            Assert.AreEqual(100, binObj.GetHashCode());
-
             var binOutArr = binObj.GetField<IBinaryObject[]>("outArr").ToArray();
 
             Assert.AreEqual(2, binOutArr.Length);
@@ -1314,11 +1247,9 @@ namespace Apache.Ignite.Core.Tests.Binary
             binOutArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeOuter))
                 .SetField("inner", new CompositeInner(2)).Build();
 
-            binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+            binObj = _grid.GetBinary().GetBuilder(binObj)
                 .SetField("outArr", binOutArr.ToArray<object>()).Build();
 
-            Assert.AreEqual(200, binObj.GetHashCode());
-
             binInArr = binObj.GetField<IBinaryObject[]>("outArr").ToArray();
 
             Assert.AreEqual(2, binInArr.Length);
@@ -1345,7 +1276,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             col.Add(new CompositeInner(1));
             dict[3] = new CompositeInner(3);
 
-            IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
+            IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeContainer))
                 .SetCollectionField("col", col)
                 .SetDictionaryField("dict", dict).Build();
 
@@ -1484,9 +1415,6 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(MigrationOuter));
 
-            if (GetIdentityResolver() == null)
-                builder.SetHashCode(outer.GetHashCode());
-
             builder.SetField<object>("inner1", inner);
             builder.SetField<object>("inner2", inner);
 
@@ -1713,9 +1641,6 @@ namespace Apache.Ignite.Core.Tests.Binary
         [Test]
         public void TestRemoteBinaryMode()
         {
-            if (GetIdentityResolver() != null)
-                return;  // When identity resolver is set, it is required to have the same config on all nodes.
-
             var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
             {
                 IgniteInstanceName = "grid2",

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestArrayIdentity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestArrayIdentity.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestArrayIdentity.cs
deleted file mode 100644
index b5e767c..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTestArrayIdentity.cs
+++ /dev/null
@@ -1,34 +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.
- */
-
-namespace Apache.Ignite.Core.Tests.Binary
-{
-    using System.Collections.Generic;
-    using Apache.Ignite.Core.Binary;
-
-    /// <summary>
-    /// Tests with array equality comparer (identity resolver).
-    /// </summary>
-    public class BinaryBuilderSelfTestArrayIdentity : BinaryBuilderSelfTest
-    {
-        /** <inheritdoc /> */
-        protected override IEqualityComparer<IBinaryObject> GetIdentityResolver()
-        {
-            return new BinaryArrayEqualityComparer();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index f859b01..70226e6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -947,8 +947,6 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
-            Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
             PrimitiveFieldType newObj = portObj.Deserialize<PrimitiveFieldType>();
 
             Assert.AreEqual(obj, newObj);
@@ -986,8 +984,6 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
-            Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
             if (!raw)
             {
                 // Test enum field in binary form
@@ -1070,8 +1066,6 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
-            Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
             CollectionsType newObj = portObj.Deserialize<CollectionsType>();
 
             Assert.AreEqual(obj, newObj);
@@ -1587,8 +1581,6 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             IBinaryObject portOutObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
 
-            Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
-
             OuterObjectType newOutObj = portOutObj.Deserialize<OuterObjectType>();
 
             Assert.AreEqual(outObj, newOutObj);

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
index c460252..a6a295b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
@@ -43,10 +43,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
                 {
                     TypeConfigurations =
                     {
-                        new BinaryTypeConfiguration(typeof(Key))
-                        {
-                            EqualityComparer = new BinaryArrayEqualityComparer()
-                        },
+                        new BinaryTypeConfiguration(typeof(Key)),
                         new BinaryTypeConfiguration(typeof(Key2))
                         {
                             EqualityComparer = new BinaryFieldEqualityComparer("Hi", "Lo")

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs
index e4e3451..ccc0808 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs
@@ -30,6 +30,11 @@ namespace Apache.Ignite.Core.Binary
         IBinaryStreamProcessor<KeyValuePair<int,int>, int>
     {
         /// <summary>
+        /// Singleton instance.
+        /// </summary>
+        public static readonly BinaryArrayEqualityComparer Instance = new BinaryArrayEqualityComparer();
+
+        /// <summary>
         /// Determines whether the specified objects are equal.
         /// </summary>
         /// <param name="x">The first object to compare.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
index 740706a..851926f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinaryObjectBuilder.cs
@@ -60,16 +60,6 @@ namespace Apache.Ignite.Core.Binary
         IBinaryObjectBuilder RemoveField(string fieldName);
 
         /// <summary>
-        /// Set explicit hash code. If builder creating object from scratch,
-        /// then hash code initially set to 0. If builder is created from
-        /// existing binary object, then hash code of that object is used
-        /// as initial value.
-        /// </summary>
-        /// <param name="hashCode">Hash code.</param>
-        /// <returns>Current builder instance.</returns>
-        IBinaryObjectBuilder SetHashCode(int hashCode);
-
-        /// <summary>
         /// Build the object.
         /// </summary>
         /// <returns>Resulting binary object.</returns>

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
index 0a14bd2..21a5323 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
@@ -247,74 +247,18 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             BinaryObject that = obj as BinaryObject;
 
-            if (that != null)
-            {
-                if (_data == that._data && _offset == that._offset)
-                    return true;
-
-                if (TypeId != that.TypeId)
-                    return false;
-
-                var desc = _marsh.GetDescriptor(true, TypeId);
-
-                if (desc != null && desc.EqualityComparer != null)
-                    return desc.EqualityComparer.Equals(this, that);
-
-                // 1. Check headers
-                if (_header == that._header)
-                {
-                    // 2. Check if objects have the same field sets.
-                    InitializeFields();
-                    that.InitializeFields();
-
-                    if (_fields.Keys.Count != that._fields.Keys.Count)
-                        return false;
-
-                    foreach (int id in _fields.Keys)
-                    {
-                        if (!that._fields.ContainsKey(id))
-                            return false;
-                    }
-
-                    // 3. Check if objects have the same field values.
-                    foreach (KeyValuePair<int, int> field in _fields)
-                    {
-                        object fieldVal = GetField<object>(field.Value, null);
-                        object thatFieldVal = that.GetField<object>(that._fields[field.Key], null);
-
-                        var arr = fieldVal as Array;
-                        var thatArr = thatFieldVal as Array;
+            if (that == null)
+                return false;
 
-                        if (arr != null && thatArr != null && arr.Length == thatArr.Length)
-                        {
-                            for (var i = 0; i < arr.Length; i++)
-                            {
-                                if (!Equals(arr.GetValue(i), thatArr.GetValue(i)))
-                                    return false;
-                            }
-                        }
-                        else if (!Equals(fieldVal, thatFieldVal))
-                        {
-                            return false;
-                        }
-                    }
+            if (_data == that._data && _offset == that._offset)
+                return true;
 
-                    // 4. Check if objects have the same raw data.
-                    // ReSharper disable ImpureMethodCallOnReadonlyValueField (method is not impure)
-                    using (var stream = new BinaryHeapStream(_data))
-                    using (var thatStream = new BinaryHeapStream(that._data))
-                    {
-                        var rawOffset = _header.GetRawOffset(stream, _offset);
-                        var thatRawOffset = that._header.GetRawOffset(thatStream, that._offset);
+            if (TypeId != that.TypeId)
+                return false;
 
-                        return BinaryUtils.CompareArrays(_data, _offset + rawOffset, _header.Length - rawOffset,
-                            that._data, that._offset + thatRawOffset, that._header.Length - thatRawOffset);
-                    }
-                    // ReSharper restore ImpureMethodCallOnReadonlyValueField
-                }
-            }
+            var desc = _marsh.GetDescriptor(true, TypeId);
 
-            return false;
+            return BinaryUtils.GetEqualityComparer(desc).Equals(this, that);
         }
 
         /** <inheritdoc /> */

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/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 40f1862..6e8df0b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -54,9 +54,6 @@ namespace Apache.Ignite.Core.Impl.Binary
         /** Contextual fields. */
         private IDictionary<int, BinaryBuilderField> _cache;
 
-        /** Hash code. */
-        private int? _hashCode;
-        
         /** Current context. */
         private Context _ctx;
 
@@ -93,23 +90,7 @@ namespace Apache.Ignite.Core.Impl.Binary
             _parent = parent ?? this;
             _desc = desc;
 
-            if (obj != null)
-            {
-                _obj = obj;
-                _hashCode = obj.GetHashCode();
-            }
-            else
-            {
-                _obj = BinaryFromDescriptor(desc);
-            }
-        }
-
-        /** <inheritDoc /> */
-        public IBinaryObjectBuilder SetHashCode(int hashCode)
-        {
-            _hashCode = hashCode;
-
-            return this;
+            _obj = obj ?? BinaryFromDescriptor(desc);
         }
 
         /** <inheritDoc /> */
@@ -508,13 +489,11 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <param name="inStream">Input stream with initial object.</param>
         /// <param name="outStream">Output stream.</param>
         /// <param name="desc">Type descriptor.</param>
-        /// <param name="hashCode">Hash code.</param>
         /// <param name="vals">Values.</param>
         private void Mutate(
             BinaryHeapStream inStream,
             BinaryHeapStream outStream,
             IBinaryTypeDescriptor desc,
-            int? hashCode, 
             IDictionary<string, BinaryBuilderField> vals)
         {
             // Set correct builder to writer frame.
@@ -553,7 +532,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                 }
 
                 // Actual processing.
-                Mutate0(_parent._ctx, inStream, outStream, true, hashCode, vals0);
+                Mutate0(_parent._ctx, inStream, outStream, true, vals0);
 
                 // 3. Handle metadata.
                 if (metaHnd != null)
@@ -580,11 +559,10 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <param name="outStream">Output stream.</param>
         /// <param name="ctx">Context.</param>
         /// <param name="changeHash">WHether hash should be changed.</param>
-        /// <param name="hash">New hash.</param>
         /// <param name="vals">Values to be replaced.</param>
         /// <returns>Mutated object.</returns>
         private void Mutate0(Context ctx, BinaryHeapStream inStream, IBinaryStream outStream,
-            bool changeHash, int? hash, IDictionary<int, BinaryBuilderField> vals)
+            bool changeHash, IDictionary<int, BinaryBuilderField> vals)
         {
             int inStartPos = inStream.Position;
             int outStartPos = outStream.Position;
@@ -613,7 +591,7 @@ namespace Apache.Ignite.Core.Impl.Binary
 
                     inStream.Seek(oldPos, SeekOrigin.Begin);
 
-                    Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                    Mutate0(ctx, inStream, outStream, false, EmptyVals);
 
                     inStream.Seek(inRetPos, SeekOrigin.Begin);
                 }
@@ -678,7 +656,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                                         // Field is not tracked, re-write as is.
                                         inStream.Seek(inField.Offset + inStartPos, SeekOrigin.Begin);
 
-                                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                                        Mutate0(ctx, inStream, outStream, false, EmptyVals);
                                     }
                                 }
                             }
@@ -740,20 +718,13 @@ namespace Apache.Ignite.Core.Impl.Binary
 
                             if (changeHash)
                             {
-                                if (hash != null)
-                                {
-                                    outHash = hash.Value;
-                                }
-                                else
-                                {
-                                    // Get from identity resolver.
-                                    outHash = _desc.EqualityComparer != null
-                                        ? _desc.EqualityComparer.GetHashCode(outStream,
-                                            outStartPos + BinaryObjectHeader.Size,
-                                            schemaPos - outStartPos - BinaryObjectHeader.Size,
-                                            outSchema, outSchemaId, _binary.Marshaller, _desc)
-                                        : 0;
-                                }
+                                // Get from identity resolver.
+                                var comparer = BinaryUtils.GetEqualityComparer(_desc);
+
+                                outHash = comparer.GetHashCode(outStream,
+                                    outStartPos + BinaryObjectHeader.Size,
+                                    schemaPos - outStartPos - BinaryObjectHeader.Size,
+                                    outSchema, outSchemaId, _binary.Marshaller, _desc);
                             }
 
                             var outHeader = new BinaryObjectHeader(inHeader.TypeId, outHash, outLen, 
@@ -816,7 +787,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                 inStream.Seek(port.Offset, SeekOrigin.Begin);
 
                 // Use fresh context to ensure correct binary inversion.
-                Mutate0(new Context(), inStream, outStream, false, 0, EmptyVals);
+                Mutate0(new Context(), inStream, outStream, false, EmptyVals);
             }
         }
 
@@ -838,7 +809,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                     builder._parent._ctx = new Context(_parent._ctx);
 
                 builder.Mutate(inStream, (BinaryHeapStream) outStream, builder._desc,
-                    builder._hashCode, builder._vals);
+                    builder._vals);
             }
         }
 
@@ -972,7 +943,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                     outStream.WriteInt(arrLen);
 
                     for (int i = 0; i < arrLen; i++)
-                        Mutate0(ctx, inStream, outStream, false, 0, null);
+                        Mutate0(ctx, inStream, outStream, false, null);
 
                     break;
 
@@ -984,7 +955,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                     outStream.WriteByte(inStream.ReadByte());
 
                     for (int i = 0; i < colLen; i++)
-                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                        Mutate0(ctx, inStream, outStream, false, EmptyVals);
 
                     break;
 
@@ -997,8 +968,8 @@ namespace Apache.Ignite.Core.Impl.Binary
 
                     for (int i = 0; i < dictLen; i++)
                     {
-                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
-                        Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
+                        Mutate0(ctx, inStream, outStream, false, EmptyVals);
+                        Mutate0(ctx, inStream, outStream, false, EmptyVals);
                     }
 
                     break;

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/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 f00b8f9..2050f67 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -1988,6 +1988,16 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /// <summary>
+        /// Gets the equality comparer.
+        /// </summary>
+        public static IBinaryEqualityComparer GetEqualityComparer(IBinaryTypeDescriptor descriptor)
+        {
+            var res = descriptor != null ? descriptor.EqualityComparer : null;
+
+            return res ?? BinaryArrayEqualityComparer.Instance;
+        }
+
+        /// <summary>
         /// Creates and instance from the type name in reader.
         /// </summary>
         private static T CreateInstance<T>(BinaryReader reader)

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index a943937..5ec649a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1233,10 +1233,10 @@ namespace Apache.Ignite.Core.Impl.Binary
 
                     var len = _stream.Position - pos;
 
-                    var hashCode = desc.EqualityComparer != null
-                        ? desc.EqualityComparer.GetHashCode(Stream, pos + BinaryObjectHeader.Size,
-                            dataEnd - pos - BinaryObjectHeader.Size, _schema, schemaIdx, _marsh, desc)
-                        : obj.GetHashCode();
+                    var comparer = BinaryUtils.GetEqualityComparer(desc);
+
+                    var hashCode = comparer.GetHashCode(Stream, pos + BinaryObjectHeader.Size,
+                            dataEnd - pos - BinaryObjectHeader.Size, _schema, schemaIdx, _marsh, desc);
 
                     var header = new BinaryObjectHeader(desc.TypeId, hashCode, len, schemaId, schemaOffset, flags);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/12e240a2/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs
index 9628688..bd2db95 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs
@@ -43,6 +43,16 @@ namespace Apache.Ignite.Core.Impl.Binary
             Marshaller marshaller, IBinaryTypeDescriptor desc);
 
         /// <summary>
+        /// Returns a hash code for this instance.
+        /// </summary>
+        /// <param name="obj">The object.</param>
+        /// <returns>
+        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
+        /// </returns>
+        int GetHashCode(IBinaryObject obj);
+
+
+        /// <summary>
         /// Returns a value indicating that two binary object are equal.
         /// </summary>
         /// <param name="x">First object.</param>