ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-4558 Use BinaryArrayIdentityResolver by default. This closes #1649.
Date Mon, 27 Mar 2017 10:54:10 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 282b334f7 -> 24f90d6d2


IGNITE-4558 Use BinaryArrayIdentityResolver by default. This closes #1649.


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

Branch: refs/heads/master
Commit: 24f90d6d242c3d10bddc83ef6123def8c367f399
Parents: 282b334
Author: Evgenii Zhuravlev <ezhuravlev@gridgain.com>
Authored: Mon Mar 27 13:53:48 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Mon Mar 27 13:53:48 2017 +0300

----------------------------------------------------------------------
 .../ignite/binary/BinaryObjectBuilder.java      |  10 --
 .../store/jdbc/CacheAbstractJdbcStore.java      |  24 ++--
 .../cache/store/jdbc/CacheJdbcPojoStore.java    |  18 +--
 .../internal/binary/BinaryClassDescriptor.java  |  23 +---
 .../ignite/internal/binary/BinaryContext.java   |   5 +-
 .../internal/binary/BinaryObjectExImpl.java     |   4 -
 .../ignite/internal/binary/BinaryUtils.java     |   5 +-
 .../internal/binary/BinaryWriterExImpl.java     |  45 ++-----
 .../binary/builder/BinaryObjectBuilderImpl.java |  20 +--
 .../processors/cache/GridCacheUtils.java        |   4 -
 .../ignite/internal/util/IgniteUtils.java       |  10 --
 .../binary/BinaryMarshallerSelfTest.java        |   4 -
 .../BinaryObjectBuilderAdditionalSelfTest.java  |   9 +-
 ...naryObjectBuilderDefaultMappersSelfTest.java | 127 +++++--------------
 ...ridCacheStoreManagerDeserializationTest.java |   1 -
 .../cache/GridCacheUtilsSelfTest.java           |   4 -
 ...calCacheStoreManagerDeserializationTest.java |   2 +-
 .../IgniteCacheBinaryObjectsScanSelfTest.java   |   2 +-
 .../GridCacheBinaryObjectsAbstractSelfTest.java |  36 ------
 .../CacheContinuousQueryVariationsTest.java     |   5 +
 .../query/h2/DmlStatementsProcessor.java        |  35 -----
 .../processors/query/h2/IgniteH2Indexing.java   |  26 ++--
 22 files changed, 97 insertions(+), 322 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
index 21f1c37..15bd799 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObjectBuilder.java
@@ -127,16 +127,6 @@ public interface BinaryObjectBuilder {
     public BinaryObjectBuilder removeField(String fieldName);
 
     /**
-     * Sets hash code for resulting binary object returned by {@link #build()} method.
-     * <p>
-     * If not set {@code 0} is used.
-     *
-     * @param hashCode Hash code.
-     * @return {@code this} instance for chaining.
-     */
-    public BinaryObjectBuilder hashCode(int hashCode);
-
-    /**
      * Builds binary object.
      *
      * @return Binary object.

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index 7af238b..41709a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -215,15 +215,13 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
      * @param typeName Type name.
      * @param typeKind Type kind.
      * @param flds Fields descriptors.
-     * @param hashFlds Field names for hash code calculation.
      * @param loadColIdxs Select query columns index.
      * @param rs ResultSet.
      * @return Constructed object.
      * @throws CacheLoaderException If failed to construct cache object.
      */
     protected abstract <R> R buildObject(@Nullable String cacheName, String typeName, TypeKind typeKind,
-        JdbcTypeField[] flds, Collection<String> hashFlds, Map<String, Integer> loadColIdxs, ResultSet rs)
-        throws CacheLoaderException;
+        JdbcTypeField[] flds, Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException;
 
     /**
      * Calculate type ID for object.
@@ -457,8 +455,11 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                     ResultSet rs = stmt.executeQuery();
 
                     while (rs.next()) {
-                        K key = buildObject(em.cacheName, em.keyType(), em.keyKind(), em.keyColumns(), em.keyCols, em.loadColIdxs, rs);
-                        V val = buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(), null, em.loadColIdxs, rs);
+                        K key = buildObject(em.cacheName, em.keyType(), em.keyKind(), em.keyColumns(),
+                            em.loadColIdxs, rs);
+
+                        V val = buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(),
+                            em.loadColIdxs, rs);
 
                         clo.apply(key, val);
                     }
@@ -875,7 +876,7 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
             ResultSet rs = stmt.executeQuery();
 
             if (rs.next())
-                return buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(), null, em.loadColIdxs, rs);
+                return buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(), em.loadColIdxs, rs);
         }
         catch (SQLException e) {
             throw new CacheLoaderException("Failed to load object [table=" + em.fullTableName() +
@@ -1993,8 +1994,8 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                     colIdxs.put(meta.getColumnLabel(i).toUpperCase(), i);
 
                 while (rs.next()) {
-                    K1 key = buildObject(em.cacheName, em.keyType(), em.keyKind(), em.keyColumns(), em.keyCols, colIdxs, rs);
-                    V1 val = buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(), null, colIdxs, rs);
+                    K1 key = buildObject(em.cacheName, em.keyType(), em.keyKind(), em.keyColumns(), colIdxs, rs);
+                    V1 val = buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(), colIdxs, rs);
 
                     clo.apply(key, val);
                 }
@@ -2089,8 +2090,11 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                 Map<K1, V1> entries = U.newHashMap(keys.size());
 
                 while (rs.next()) {
-                    K1 key = buildObject(em.cacheName, em.keyType(), em.keyKind(), em.keyColumns(), em.keyCols, em.loadColIdxs, rs);
-                    V1 val = buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(), null, em.loadColIdxs, rs);
+                    K1 key = buildObject(em.cacheName, em.keyType(), em.keyKind(), em.keyColumns(),
+                        em.loadColIdxs, rs);
+
+                    V1 val = buildObject(em.cacheName, em.valueType(), em.valueKind(), em.valueColumns(),
+                        em.loadColIdxs, rs);
 
                     entries.put(key, val);
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
index b9f6e8a..00a8ade 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
@@ -126,7 +126,7 @@ public class CacheJdbcPojoStore<K, V> extends CacheAbstractJdbcStore<K, V> {
 
     /** {@inheritDoc} */
     @Override protected <R> R buildObject(@Nullable String cacheName, String typeName, TypeKind typeKind,
-        JdbcTypeField[] flds, Collection<String> hashFlds, Map<String, Integer> loadColIdxs, ResultSet rs)
+        JdbcTypeField[] flds, Map<String, Integer> loadColIdxs, ResultSet rs)
         throws CacheLoaderException {
         switch (typeKind) {
             case BUILT_IN:
@@ -134,7 +134,7 @@ public class CacheJdbcPojoStore<K, V> extends CacheAbstractJdbcStore<K, V> {
             case POJO:
                 return (R)buildPojoObject(cacheName, typeName, flds, loadColIdxs, rs);
             default:
-                return (R)buildBinaryObject(typeName, flds, hashFlds, loadColIdxs, rs);
+                return (R)buildBinaryObject(typeName, flds, loadColIdxs, rs);
         }
     }
 
@@ -233,35 +233,23 @@ public class CacheJdbcPojoStore<K, V> extends CacheAbstractJdbcStore<K, V> {
      *
      * @param typeName Type name.
      * @param fields Fields descriptors.
-     * @param hashFields Collection of fields to build hash for.
      * @param loadColIdxs Select query columns index.
      * @param rs ResultSet.
      * @return Constructed binary object.
      * @throws CacheLoaderException If failed to construct binary object.
      */
-    protected Object buildBinaryObject(String typeName, JdbcTypeField[] fields,
-        Collection<String> hashFields, Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException {
+    protected Object buildBinaryObject(String typeName, JdbcTypeField[] fields, Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException {
         try {
             BinaryObjectBuilder builder = ignite.binary().builder(typeName);
 
-            boolean calcHash = hashFields != null;
-
-            Collection<Object> hashValues = calcHash ? new ArrayList<>(hashFields.size()) : null;
-
             for (JdbcTypeField field : fields) {
                 Integer colIdx = columnIndex(loadColIdxs, field.getDatabaseFieldName());
 
                 Object colVal = transformer.getColumnValue(rs, colIdx, field.getJavaFieldType());
 
                 builder.setField(field.getJavaFieldName(), colVal, (Class<Object>)field.getJavaFieldType());
-
-                if (calcHash)
-                    hashValues.add(colVal);
             }
 
-            if (calcHash)
-                builder.hashCode(hasher.hashCode(hashValues));
-
             return builder.build();
         }
         catch (SQLException e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index 32db1f7..7eaf6c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -43,7 +43,6 @@ import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
 import org.apache.ignite.internal.processors.query.QueryUtils;
 import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.IgniteUtils;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -120,9 +119,6 @@ public class BinaryClassDescriptor {
     private final boolean excluded;
 
     /** */
-    private final boolean overridesHashCode;
-
-    /** */
     private final Class<?>[] intfs;
 
     /** Whether stable schema was published. */
@@ -176,8 +172,6 @@ public class BinaryClassDescriptor {
         this.mapper = mapper;
         this.registered = registered;
 
-        overridesHashCode = IgniteUtils.overridesEqualsAndHashCode(cls);
-
         schemaReg = ctx.schemaRegistry(typeId);
 
         excluded = MarshallerExclusions.isExcluded(cls);
@@ -744,7 +738,7 @@ public class BinaryClassDescriptor {
                         else
                             ((Binarylizable)obj).writeBinary(writer);
 
-                        postWrite(writer, obj);
+                        postWrite(writer);
 
                         // Check whether we need to update metadata.
                         if (obj.getClass() != BinaryMetadata.class) {
@@ -800,7 +794,7 @@ public class BinaryClassDescriptor {
 
                         writer.schemaId(stableSchema.schemaId());
 
-                        postWrite(writer, obj);
+                        postWrite(writer);
                         postWriteHashCode(writer, obj);
                     }
                     finally {
@@ -903,18 +897,9 @@ public class BinaryClassDescriptor {
      * Post-write phase.
      *
      * @param writer Writer.
-     * @param obj Object.
      */
-    private void postWrite(BinaryWriterExImpl writer, Object obj) {
-        if (obj instanceof CacheObjectImpl)
-            writer.postWrite(userType, registered, 0, false);
-        else if (obj instanceof BinaryObjectEx) {
-            boolean flagSet = ((BinaryObjectEx)obj).isFlagSet(BinaryUtils.FLAG_EMPTY_HASH_CODE);
-
-            writer.postWrite(userType, registered, obj.hashCode(), !flagSet);
-        }
-        else
-            writer.postWrite(userType, registered, obj.hashCode(), overridesHashCode);
+    private void postWrite(BinaryWriterExImpl writer) {
+        writer.postWrite(userType, registered);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 3517b8c..febfb04 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.binary;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.binary.BinaryArrayIdentityResolver;
 import org.apache.ignite.binary.BinaryBasicIdMapper;
 import org.apache.ignite.binary.BinaryBasicNameMapper;
 import org.apache.ignite.binary.BinaryIdMapper;
@@ -1234,7 +1235,9 @@ public class BinaryContext {
      * @return Type identity.
      */
     public BinaryIdentityResolver identity(int typeId) {
-        return identities.get(typeId);
+        BinaryIdentityResolver rslvr = identities.get(typeId);
+
+        return rslvr != null ? rslvr : BinaryArrayIdentityResolver.instance();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
index 5b5aeba..88ae832 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
@@ -23,7 +23,6 @@ import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.Map;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryArrayIdentityResolver;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.binary.BinaryObjectException;
@@ -160,9 +159,6 @@ public abstract class BinaryObjectExImpl implements BinaryObjectEx {
 
         BinaryIdentityResolver identity = context().identity(typeId());
 
-        if (identity == null)
-            identity = BinaryArrayIdentityResolver.instance();
-
         return identity.equals(this, (BinaryObject)other);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 28659ab..d3ff2ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -110,9 +110,6 @@ public class BinaryUtils {
     /** Flag: compact footer, no field IDs. */
     public static final short FLAG_COMPACT_FOOTER = 0x0020;
 
-    /** Flag: no hash code has been set. */
-    public static final short FLAG_EMPTY_HASH_CODE = 0x0040;
-
     /** Offset which fits into 1 byte. */
     public static final int OFFSET_1 = 1;
 
@@ -142,7 +139,7 @@ public class BinaryUtils {
     /** FNV1 hash prime. */
     private static final int FNV1_PRIME = 0x01000193;
 
-    /**
+    /*
      * Static class initializer.
      */
     static {

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index b091001..5ae47fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -247,10 +247,8 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
      *
      * @param userType User type flag.
      * @param registered Whether type is registered.
-     * @param hashCode Hash code.
-     * @param isHashCodeSet Hash code presence flag.
      */
-    public void postWrite(boolean userType, boolean registered, int hashCode, boolean isHashCodeSet) {
+    public void postWrite(boolean userType, boolean registered) {
         short flags;
         boolean useCompactFooter;
 
@@ -307,9 +305,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
             }
         }
 
-        if (!isHashCodeSet)
-            flags |= BinaryUtils.FLAG_EMPTY_HASH_CODE;
-
         // Actual write.
         int retPos = out.position();
 
@@ -319,7 +314,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
         out.unsafeWriteByte(GridBinaryMarshaller.PROTO_VER);
         out.unsafeWriteShort(flags);
         out.unsafeWriteInt(registered ? typeId : GridBinaryMarshaller.UNREGISTERED_TYPE_ID);
-        out.unsafeWriteInt(hashCode);
+        out.unsafePosition(start + GridBinaryMarshaller.TOTAL_LEN_POS);
         out.unsafeWriteInt(retPos - start);
         out.unsafeWriteInt(finalSchemaId);
         out.unsafeWriteInt(offset);
@@ -337,35 +332,23 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
 
         BinaryIdentityResolver identity = ctx.identity(typeId);
 
-        if (identity != null) {
-            if (out.hasArray()) {
-                // Heap.
-                byte[] data = out.array();
-
-                BinaryObjectImpl obj = new BinaryObjectImpl(ctx, data, start);
-
-                short flags = BinaryPrimitives.readShort(data, start + GridBinaryMarshaller.FLAGS_POS);
-
-                BinaryPrimitives.writeShort(data, start + GridBinaryMarshaller.FLAGS_POS,
-                    (short) (flags & ~BinaryUtils.FLAG_EMPTY_HASH_CODE));
-
-                BinaryPrimitives.writeInt(data, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj));
-            }
-            else {
-                // Offheap.
-                long ptr = out.rawOffheapPointer();
+        if (out.hasArray()) {
+            // Heap.
+            byte[] data = out.array();
 
-                assert ptr != 0;
+            BinaryObjectImpl obj = new BinaryObjectImpl(ctx, data, start);
 
-                BinaryObjectOffheapImpl obj = new BinaryObjectOffheapImpl(ctx, ptr, start, out.capacity());
+            BinaryPrimitives.writeInt(data, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj));
+        }
+        else {
+            // Offheap.
+            long ptr = out.rawOffheapPointer();
 
-                short flags = BinaryPrimitives.readShort(ptr, start + GridBinaryMarshaller.FLAGS_POS);
+            assert ptr != 0;
 
-                BinaryPrimitives.writeShort(ptr, start + GridBinaryMarshaller.FLAGS_POS,
-                    (short) (flags & ~BinaryUtils.FLAG_EMPTY_HASH_CODE));
+            BinaryObjectOffheapImpl obj = new BinaryObjectOffheapImpl(ctx, ptr, start, out.capacity());
 
-                BinaryPrimitives.writeInt(ptr, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj));
-            }
+            BinaryPrimitives.writeInt(ptr, start + GridBinaryMarshaller.HASH_CODE_POS, identity.hashCode(obj));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index fd6c351..4ab9df8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -85,12 +85,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
     /** Context of BinaryObject reading process. Or {@code null} if object is not created from BinaryObject. */
     private final BinaryBuilderReader reader;
 
-    /** */
-    private int hashCode;
-
-    /** */
-    private boolean isHashCodeSet;
-
     /**
      * @param clsName Class name.
      * @param ctx Binary context.
@@ -122,7 +116,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
      */
     public BinaryObjectBuilderImpl(BinaryObjectImpl obj) {
         this(new BinaryBuilderReader(obj), obj.start());
-        isHashCodeSet = !obj.isFlagSet(BinaryUtils.FLAG_EMPTY_HASH_CODE);
         reader.registerObject(this);
     }
 
@@ -143,7 +136,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
 
         int typeId = reader.readIntPositioned(start + GridBinaryMarshaller.TYPE_ID_POS);
         ctx = reader.binaryContext();
-        hashCode = reader.readIntPositioned(start + GridBinaryMarshaller.HASH_CODE_POS);
 
         if (typeId == GridBinaryMarshaller.UNREGISTERED_TYPE_ID) {
             int mark = reader.position();
@@ -338,7 +330,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
             }
 
             //noinspection NumberEquality
-            writer.postWrite(true, registeredType, hashCode, isHashCodeSet);
+            writer.postWrite(true, registeredType);
 
             // Update metadata if needed.
             int schemaId = writer.schemaId();
@@ -432,16 +424,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
         return fieldsMeta;
     }
 
-    /** {@inheritDoc} */
-    @SuppressWarnings("UnnecessaryBoxing")
-    @Override public BinaryObjectBuilderImpl hashCode(int hashCode) {
-        this.hashCode = hashCode;
-
-        isHashCodeSet = true;
-
-        return this;
-    }
-
     /**
      * Get field position and length.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 7131612..bce054a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1115,10 +1115,6 @@ public class GridCacheUtils {
         if (!U.overridesEqualsAndHashCode(key))
             throw new IllegalArgumentException("Cache key must override hashCode() and equals() methods: " +
                 key.getClass().getName());
-
-        if (U.isHashCodeEmpty(key))
-            throw new IllegalArgumentException("Cache key created with BinaryBuilder is missing hash code - " +
-                "please set it explicitly during building by using BinaryBuilder.hashCode(int)");
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 4620f12..2106bd4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -8539,16 +8539,6 @@ public abstract class IgniteUtils {
     }
 
     /**
-     * @param obj Object.
-     * @return {@code True} if given object is a {@link BinaryObjectEx} and
-     * has {@link BinaryUtils#FLAG_EMPTY_HASH_CODE} set
-     */
-    public static boolean isHashCodeEmpty(Object obj) {
-        return obj != null && obj instanceof BinaryObjectEx &&
-            ((BinaryObjectEx)obj).isFlagSet(BinaryUtils.FLAG_EMPTY_HASH_CODE);
-    }
-
-    /**
      * Checks if error is MAC invalid argument error which ususally requires special handling.
      *
      * @param e Exception.

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index 1cac1a8..ee72919 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -695,8 +695,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        assertEquals(obj.hashCode(), po.hashCode());
-
         assertEquals(obj, po.deserialize());
 
         assertEquals(obj.b, (byte)po.field("b"));
@@ -781,8 +779,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
 
         BinaryObject po = marshal(obj, marsh);
 
-        assertEquals(obj.hashCode(), po.hashCode());
-
         assertEquals(obj, po.deserialize());
 
         assertEquals(obj.b, (byte)po.field("_b"));

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
index 100f109..09f1c39 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
@@ -49,6 +49,7 @@ import junit.framework.TestCase;
 import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryArrayIdentityResolver;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.binary.BinaryObjectException;
@@ -896,11 +897,9 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
 
         BinaryObjectBuilderImpl mutableObj = wrap(obj);
 
-        assertEquals(obj.hashCode(), mutableObj.build().hashCode());
+        BinaryObject bo = mutableObj.build();
 
-        mutableObj.hashCode(25);
-
-        assertEquals(25, mutableObj.build().hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(bo), bo.hashCode());
     }
 
     /**
@@ -1377,7 +1376,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
             jcache(0, "partitioned").withKeepBinary();
 
         BinaryObjectBuilder keyBuilder = ignite(0).binary().builder("keyType")
-            .setField("F1", "V1").hashCode("V1".hashCode());
+            .setField("F1", "V1");
 
         BinaryObjectBuilder valBuilder = ignite(0).binary().builder("valueType")
             .setField("F2", "V2")

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
index a4388a1..a4d9860 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -29,6 +29,7 @@ import java.util.UUID;
 import junit.framework.TestCase;
 import org.apache.ignite.IgniteBinary;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryArrayIdentityResolver;
 import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryNameMapper;
 import org.apache.ignite.binary.BinaryObject;
@@ -132,8 +133,6 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testNullField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(42);
-
         builder.setField("objField", (Object)null);
 
         builder.setField("otherField", "value");
@@ -142,7 +141,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
 
         assertNull(obj.field("objField"));
         assertEquals("value", obj.field("otherField"));
-        assertEquals(42, obj.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(obj), obj.hashCode());
 
         builder = builder(obj);
 
@@ -153,7 +152,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
 
         assertNull(obj.field("otherField"));
         assertEquals("value", obj.field("objField"));
-        assertEquals(42, obj.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(obj), obj.hashCode());
     }
 
     /**
@@ -162,14 +161,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testByteField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("byteField", (byte)1);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
     }
@@ -180,14 +177,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testShortField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("shortField", (short)1);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals((short)1, po.<Short>field("shortField").shortValue());
     }
@@ -198,14 +193,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testIntField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("intField", 1);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(1, po.<Integer>field("intField").intValue());
     }
@@ -216,14 +209,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testLongField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("longField", 1L);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(1L, po.<Long>field("longField").longValue());
     }
@@ -234,14 +225,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testFloatField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("floatField", 1.0f);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
     }
@@ -252,14 +241,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testDoubleField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("doubleField", 1.0d);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
     }
@@ -270,14 +257,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testCharField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("charField", (char)1);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals((char)1, po.<Character>field("charField").charValue());
     }
@@ -305,14 +290,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testBooleanField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("booleanField", true);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(po.<Boolean>field("booleanField"));
     }
@@ -323,14 +306,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testDecimalField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("decimalField", BigDecimal.TEN);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
     }
@@ -341,14 +322,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testStringField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("stringField", "str");
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals("str", po.<String>field("stringField"));
     }
@@ -378,8 +357,6 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testUuidField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         UUID uuid = UUID.randomUUID();
 
         builder.setField("uuidField", uuid);
@@ -387,7 +364,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(uuid, po.<UUID>field("uuidField"));
     }
@@ -398,14 +375,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testByteArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("byteArrayField", new byte[] {1, 2, 3});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new byte[] {1, 2, 3}, po.<byte[]>field("byteArrayField")));
     }
@@ -416,14 +391,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testShortArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("shortArrayField", new short[] {1, 2, 3});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new short[] {1, 2, 3}, po.<short[]>field("shortArrayField")));
     }
@@ -434,14 +407,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testIntArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("intArrayField", new int[] {1, 2, 3});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("intArrayField")));
     }
@@ -452,14 +423,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testLongArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("longArrayField", new long[] {1, 2, 3});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new long[] {1, 2, 3}, po.<long[]>field("longArrayField")));
     }
@@ -470,14 +439,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testFloatArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("floatArrayField", new float[] {1, 2, 3});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new float[] {1, 2, 3}, po.<float[]>field("floatArrayField")));
     }
@@ -488,14 +455,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testDoubleArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("doubleArrayField", new double[] {1, 2, 3});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new double[] {1, 2, 3}, po.<double[]>field("doubleArrayField")));
     }
@@ -506,14 +471,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testCharArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("charArrayField", new char[] {1, 2, 3});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new char[] {1, 2, 3}, po.<char[]>field("charArrayField")));
     }
@@ -524,14 +487,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testBooleanArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("booleanArrayField", new boolean[] {true, false});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         boolean[] arr = po.field("booleanArrayField");
 
@@ -547,14 +508,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testDecimalArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("decimalArrayField", new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN}, po.<String[]>field("decimalArrayField")));
     }
@@ -565,14 +524,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testStringArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("stringArrayField", new String[] {"str1", "str2", "str3"});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(new String[] {"str1", "str2", "str3"}, po.<String[]>field("stringArrayField")));
     }
@@ -610,8 +567,6 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testUuidArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID()};
 
         builder.setField("uuidArrayField", arr);
@@ -619,7 +574,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
     }
@@ -630,14 +585,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testObjectField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("objectField", new Value(1));
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
     }
@@ -648,14 +601,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testObjectArrayField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("objectArrayField", new Value[] {new Value(1), new Value(2)});
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         Object[] arr = po.field("objectArrayField");
 
@@ -671,15 +622,13 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testCollectionField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
         builder.setField("collectionField2", Arrays.asList(new Value(1), new Value(2)), Collection.class);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         List<Value> list = po.field("collectionField");
 
@@ -700,15 +649,13 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testMapField() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
         builder.setField("mapField2", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)), Map.class);
 
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         // Test non-standard map.
         Map<Key, Value> map = po.field("mapField");
@@ -733,8 +680,6 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testSeveralFields() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("i", 111);
         builder.setField("f", 111.111f);
         builder.setField("iArr", new int[] {1, 2, 3});
@@ -744,7 +689,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
         BinaryObject po = builder.build();
 
         assertEquals(expectedHashCode("Class"), po.type().typeId());
-        assertEquals(100, po.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), po.hashCode());
 
         assertEquals(111, po.<Integer>field("i").intValue());
         assertEquals(111.111f, po.<Float>field("f").floatValue(), 0);
@@ -765,8 +710,6 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testOffheapBinary() throws Exception {
         BinaryObjectBuilder builder = builder("Class");
 
-        builder.hashCode(100);
-
         builder.setField("i", 111);
         builder.setField("f", 111.111f);
         builder.setField("iArr", new int[] {1, 2, 3});
@@ -799,7 +742,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
             assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
 
             assertEquals(expectedHashCode("Class"), offheapObj.type().typeId());
-            assertEquals(100, offheapObj.hashCode());
+            assertEquals(BinaryArrayIdentityResolver.instance().hashCode(po), offheapObj.hashCode());
 
             assertEquals(111, offheapObj.<Integer>field("i").intValue());
             assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
@@ -827,14 +770,12 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testBuildAndDeserialize() throws Exception {
         BinaryObjectBuilder builder = builder(Value.class.getName());
 
-        builder.hashCode(100);
-
         builder.setField("i", 1);
 
         BinaryObject bo = builder.build();
 
         assertEquals(expectedHashCode(Value.class.getName()), bo.type().typeId());
-        assertEquals(100, bo.hashCode());
+        assertEquals(BinaryArrayIdentityResolver.instance().hashCode(bo), bo.hashCode());
 
         assertEquals(1, bo.<Value>deserialize().i);
     }
@@ -874,8 +815,6 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
     public void testMetaData() throws Exception {
         BinaryObjectBuilder builder = builder("org.test.MetaTest");
 
-        builder.hashCode(100);
-
         builder.setField("intField", 1);
         builder.setField("byteArrayField", new byte[] {1, 2, 3});
 
@@ -897,8 +836,6 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
 
         builder = builder("org.test.MetaTest");
 
-        builder.hashCode(100);
-
         builder.setField("intField", 2);
         builder.setField("uuidField", UUID.randomUUID());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java
index 2c22758..73d01fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManagerDeserializationTest.java
@@ -279,7 +279,6 @@ public class GridCacheStoreManagerDeserializationTest extends GridCommonAbstract
 
         for (int i = 0; i < 1; i++) {
             builder.setField("id", i);
-            builder.hashCode(i);
 
             entity = builder.build();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java
index d30aad5..e28daf3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheUtilsSelfTest.java
@@ -143,10 +143,6 @@ public class GridCacheUtilsSelfTest extends GridCommonAbstractTest {
         BinaryObjectBuilderImpl binBuilder = new BinaryObjectBuilderImpl(binaryContext(),
             EqualsAndHashCode.class.getName());
 
-        assertThrowsForInvalidKey(binBuilder.build());
-
-        binBuilder.hashCode(0xFE12);
-
         BinaryObject binObj = binBuilder.build();
 
         CU.validateCacheKey(binObj);

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java
index b86fe53..827b3cf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridLocalCacheStoreManagerDeserializationTest.java
@@ -86,7 +86,7 @@ public class GridLocalCacheStoreManagerDeserializationTest extends GridCacheStor
 
         final BinaryObjectBuilder builder = grid.binary().builder("custom_type");
 
-        final BinaryObject entity = builder.setField("id", 0).hashCode(0).build();
+        final BinaryObject entity = builder.setField("id", 0).build();
 
         cache.put(entity, entity);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
index fbc065d..666505b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryObjectsScanSelfTest.java
@@ -127,7 +127,7 @@ public class IgniteCacheBinaryObjectsScanSelfTest extends GridCommonAbstractTest
             assertEquals(PERSON_CLS_NAME, entry.getValue().getClass().getName());
         }
 
-        entries = cache.query(new ScanQuery<>(1)).getAll();
+        entries = cache.query(new ScanQuery<>(1023)).getAll();
 
         assertFalse(entries.isEmpty());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
index f3b14b1..ea151be 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -926,42 +926,6 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
     }
 
     /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings({ "ThrowableResultOfMethodCallIgnored", "unchecked" })
-    public void testPutWithoutHashCode() throws Exception {
-        final IgniteCache c = jcache(0);
-
-        GridCacheAdapter<Object, Object> cache0 = grid(0).context().cache().internalCache(null);
-
-        cache0.forceKeyCheck();
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            /** {@inheritDoc} */
-            @Override public Object call() throws Exception {
-                c.put(new TestObject(5), 5);
-                return null;
-            }
-        }, IllegalArgumentException.class, "Cache key must override hashCode() and equals() methods: ");
-
-        BinaryObjectBuilder bldr = grid(0).binary().builder(TestObject.class.getName());
-        bldr.setField("val", 5);
-
-        final BinaryObject binKey = bldr.build();
-
-        cache0.forceKeyCheck();
-
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            /** {@inheritDoc} */
-            @Override public Object call() throws Exception {
-                c.put(binKey, 5);
-                return null;
-            }
-        }, IllegalArgumentException.class, "Cache key created with BinaryBuilder is missing hash code - " +
-            "please set it explicitly during building by using BinaryBuilder.hashCode(int)");
-    }
-
-    /**
      *
      */
     @SuppressWarnings("unchecked")

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java
index bd5a122..ab086bc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryVariationsTest.java
@@ -713,6 +713,11 @@ public class CacheContinuousQueryVariationsTest extends IgniteCacheConfigVariati
                         cache.remove(key);
                         cache.remove(key);
 
+                        //Wait when remove event will be added to evts
+                        while (evts.size() != 10) {
+                            Thread.sleep(100);
+                        }
+                        
                         evts.clear();
 
                         log.info("Finish iteration: " + i);

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
index cbf39f6..c064fa1 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
@@ -41,7 +41,6 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryArrayIdentityResolver;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.cache.query.SqlFieldsQuery;
@@ -979,45 +978,11 @@ public class DmlStatementsProcessor {
 
             if (val instanceof BinaryObjectBuilder)
                 val = ((BinaryObjectBuilder) val).build();
-
-            if (key instanceof BinaryObject)
-                key = updateHashCodeIfNeeded(cctx, (BinaryObject) key);
-
-            if (val instanceof BinaryObject)
-                val = updateHashCodeIfNeeded(cctx, (BinaryObject) val);
         }
 
         return new IgniteBiTuple<>(key, val);
     }
 
-    /**
-     * Set hash code to binary object if it does not have one.
-     *
-     * @param cctx Cache context.
-     * @param binObj Binary object.
-     * @return Binary object with hash code set.
-     */
-    private BinaryObject updateHashCodeIfNeeded(GridCacheContext cctx, BinaryObject binObj) {
-        if (U.isHashCodeEmpty(binObj)) {
-            if (WARNED_TYPES.add(binObj.type().typeId()))
-                U.warn(indexing.getLogger(), "Binary object's type does not have identity resolver explicitly set, therefore " +
-                    "BinaryArrayIdentityResolver is used to generate hash codes for its instances, and therefore " +
-                    "hash code of this binary object will most likely not match that of its non serialized form. " +
-                    "For finer control over identity of this type, please update your BinaryConfiguration accordingly." +
-                    " [typeId=" + binObj.type().typeId() + ", typeName=" + binObj.type().typeName() + ']');
-
-            int hash = BinaryArrayIdentityResolver.instance().hashCode(binObj);
-
-            // Empty hash code means no identity set for the type, therefore, we can safely set hash code
-            // via this Builder as it won't be overwritten.
-            return cctx.grid().binary().builder(binObj)
-                .hashCode(hash)
-                .build();
-        }
-        else
-            return binObj;
-    }
-
     /** */
     private final static class InsertEntryProcessor implements EntryProcessor<Object, Object, Boolean> {
         /** Value to set. */

http://git-wip-us.apache.org/repos/asf/ignite/blob/24f90d6d/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index b0d3850..79121e4 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1967,11 +1967,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             SysProperties.serializeJavaObject = false;
         }
 
-        if (JdbcUtils.serializer != null)
-            U.warn(log, "Custom H2 serialization is already configured, will override.");
-
-        JdbcUtils.serializer = h2Serializer();
-
         String dbName = (ctx != null ? ctx.localNodeId() : UUID.randomUUID()).toString();
 
         dbUrl = "jdbc:h2:mem:" + dbName + DB_OPTIONS;
@@ -2027,6 +2022,11 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             }, CLEANUP_STMT_CACHE_PERIOD, CLEANUP_STMT_CACHE_PERIOD);
         }
 
+        if (JdbcUtils.serializer != null)
+            U.warn(log, "Custom H2 serialization is already configured, will override.");
+
+        JdbcUtils.serializer = h2Serializer();
+
         // TODO https://issues.apache.org/jira/browse/IGNITE-2139
         // registerMBean(igniteInstanceName, this, GridH2IndexingSpiMBean.class);
     }
@@ -2122,16 +2122,16 @@ public class IgniteH2Indexing implements GridQueryIndexing {
      */
     private JavaObjectSerializer h2Serializer() {
         return new JavaObjectSerializer() {
-                @Override public byte[] serialize(Object obj) throws Exception {
-                    return U.marshal(marshaller, obj);
-                }
+            @Override public byte[] serialize(Object obj) throws Exception {
+                return U.marshal(marshaller, obj);
+            }
 
-                @Override public Object deserialize(byte[] bytes) throws Exception {
-                    ClassLoader clsLdr = ctx != null ? U.resolveClassLoader(ctx.config()) : null;
+            @Override public Object deserialize(byte[] bytes) throws Exception {
+                ClassLoader clsLdr = ctx != null ? U.resolveClassLoader(ctx.config()) : null;
 
-                    return U.unmarshal(marshaller, bytes, clsLdr);
-                }
-            };
+                return U.unmarshal(marshaller, bytes, clsLdr);
+            }
+        };
     }
 
     /**


Mime
View raw message