You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/04/07 15:24:46 UTC
[3/3] ignite git commit: IGNITE-41919 - Removed identity resolvers
IGNITE-41919 - Removed identity resolvers
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c2d8bd9a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c2d8bd9a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c2d8bd9a
Branch: refs/heads/ignite-3477-master
Commit: c2d8bd9a4a369b38f329ba020d5419fc03b2b788
Parents: 872f34a
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Fri Apr 7 18:19:44 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 7 18:19:44 2017 +0300
----------------------------------------------------------------------
.../binary/BinaryAbstractIdentityResolver.java | 53 ---
.../binary/BinaryArrayIdentityResolver.java | 224 -------------
.../binary/BinaryFieldIdentityResolver.java | 307 -----------------
.../ignite/binary/BinaryIdentityResolver.java | 42 ---
.../ignite/binary/BinaryTypeConfiguration.java | 25 --
.../binary/BinaryAbstractIdentityResolver.java | 56 ++++
.../binary/BinaryArrayIdentityResolver.java | 222 +++++++++++++
.../ignite/internal/binary/BinaryContext.java | 4 +-
.../internal/binary/BinaryIdentityResolver.java | 43 +++
.../internal/binary/BinaryObjectExImpl.java | 1 -
.../internal/binary/BinaryWriterExImpl.java | 1 -
.../utils/PlatformConfigurationUtils.java | 64 +---
.../BinaryArrayIdentityResolverSelfTest.java | 4 -
.../BinaryFieldIdentityResolverSelfTest.java | 333 -------------------
...ryIdentityResolverConfigurationSelfTest.java | 138 --------
.../BinaryObjectBuilderAdditionalSelfTest.java | 1 -
...naryObjectBuilderDefaultMappersSelfTest.java | 1 -
.../GridCacheBinaryObjectsAbstractSelfTest.java | 58 +---
.../IgniteBinaryObjectsTestSuite.java | 4 -
...niteCacheAbstractInsertSqlQuerySelfTest.java | 129 -------
.../IgniteCacheInsertSqlQuerySelfTest.java | 40 ---
.../cache/IgniteCacheMergeSqlQuerySelfTest.java | 38 ---
modules/platforms/cpp/binary/Makefile.am | 1 -
.../platforms/cpp/binary/include/Makefile.am | 3 -
.../binary/binary_array_identity_resolver.h | 64 ----
.../ignite/binary/binary_identity_resolver.h | 61 ----
.../include/ignite/binary/binary_object.h | 12 +-
.../binary/include/ignite/binary/binary_type.h | 10 -
.../ignite/impl/binary/binary_type_impl.h | 149 ---------
.../ignite/impl/binary/binary_writer_impl.h | 5 +-
.../cpp/binary/project/vs/binary.vcxproj | 4 -
.../binary/project/vs/binary.vcxproj.filters | 12 -
.../binary/binary_array_identity_resolver.cpp | 42 ---
.../core-test/include/ignite/binary_test_defs.h | 25 --
.../cpp/core-test/include/ignite/complex_type.h | 2 -
.../cpp/core-test/include/ignite/test_type.h | 1 -
.../src/binary_identity_resolver_test.cpp | 254 --------------
.../cpp/core-test/src/cache_invoke_test.cpp | 3 -
.../cpp/core-test/src/cache_query_test.cpp | 2 -
.../platforms/cpp/core-test/src/cache_test.cpp | 1 -
.../cpp/core-test/src/continuous_query_test.cpp | 6 -
.../cpp/odbc-test/include/complex_type.h | 2 -
.../platforms/cpp/odbc-test/include/test_type.h | 1 -
.../Binary/BinaryEqualityComparerTest.cs | 220 +++---------
.../Cache/Query/CacheDmlQueriesTest.cs | 13 +-
.../IgniteConfigurationSerializerTest.cs | 9 +-
.../IgniteConfigurationTest.cs | 7 +-
.../Apache.Ignite.Core.csproj | 5 +-
.../Binary/BinaryArrayEqualityComparer.cs | 160 ---------
.../Binary/BinaryTypeConfiguration.cs | 13 -
.../Apache.Ignite.Core/IgniteConfiguration.cs | 43 ---
.../IgniteConfigurationSection.xsd | 14 -
.../Impl/Binary/BinaryArrayEqualityComparer.cs | 159 +++++++++
.../Binary/BinaryEqualityComparerSerializer.cs | 100 +-----
.../Impl/Binary/BinaryFieldEqualityComparer.cs | 138 --------
.../Impl/Binary/BinaryFullTypeDescriptor.cs | 20 --
.../Impl/Binary/BinaryObject.cs | 2 +-
.../Impl/Binary/BinaryObjectBuilder.cs | 7 +-
.../Binary/BinarySurrogateTypeDescriptor.cs | 6 -
.../Impl/Binary/BinaryUtils.cs | 10 -
.../Impl/Binary/BinaryWriter.cs | 6 +-
.../Impl/Binary/IBinaryEqualityComparer.cs | 63 ----
.../Impl/Binary/IBinaryTypeDescriptor.cs | 5 -
.../Impl/Binary/Marshaller.cs | 24 +-
64 files changed, 568 insertions(+), 2904 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/binary/BinaryAbstractIdentityResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryAbstractIdentityResolver.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryAbstractIdentityResolver.java
deleted file mode 100644
index b3036e2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryAbstractIdentityResolver.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.binary;
-
-/**
- * Abstract identity resolver with common routines.
- */
-public abstract class BinaryAbstractIdentityResolver implements BinaryIdentityResolver {
- /** {@inheritDoc} */
- @Override public int hashCode(BinaryObject obj) {
- if (obj == null)
- throw new BinaryObjectException("Cannot calculate hash code because binary object is null.");
-
- return hashCode0(obj);
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(BinaryObject o1, BinaryObject o2) {
- return o1 == o2 || (o1 != null && o2 != null && equals0(o1, o2));
- }
-
- /**
- * Internal hash code routine.
- *
- * @param obj Object.
- * @return Result.
- */
- protected abstract int hashCode0(BinaryObject obj);
-
- /**
- * Internal equals routine.
- *
- * @param o1 First object.
- * @param o2 Second object.
- * @return Result.
- */
- protected abstract boolean equals0(BinaryObject o1, BinaryObject o2);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/binary/BinaryArrayIdentityResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryArrayIdentityResolver.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryArrayIdentityResolver.java
deleted file mode 100644
index 2f04c02..0000000
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryArrayIdentityResolver.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.binary;
-
-import java.util.Arrays;
-
-import org.apache.ignite.internal.binary.BinaryEnumObjectImpl;
-import org.apache.ignite.internal.binary.BinaryObjectEx;
-import org.apache.ignite.internal.binary.BinaryObjectExImpl;
-import org.apache.ignite.internal.binary.BinaryPrimitives;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Identity resolver implementation which compares raw array content of the binary object.
- * <p>
- * Hash code is calculated in the same way as {@link Arrays#hashCode(byte[])} does.
- */
-public class BinaryArrayIdentityResolver extends BinaryAbstractIdentityResolver {
- /** Singleton instance */
- private static final BinaryArrayIdentityResolver INSTANCE = new BinaryArrayIdentityResolver();
-
- /**
- * Get singleton instance.
- *
- * @return Singleton instance.
- */
- public static BinaryArrayIdentityResolver instance() {
- return INSTANCE;
- }
-
- /**
- * Default constructor.
- */
- public BinaryArrayIdentityResolver() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected int hashCode0(BinaryObject obj) {
- int hash = 1;
-
- if (obj instanceof BinaryObjectExImpl) {
- BinaryObjectExImpl ex = (BinaryObjectExImpl)obj;
-
- int start = ex.dataStartOffset();
- int end = ex.footerStartOffset();
-
- if (ex.hasArray()) {
- // Handle heap object.
- byte[] data = ex.array();
-
- for (int i = start; i < end; i++)
- hash = 31 * hash + data[i];
- }
- else {
- // Handle offheap object.
- long ptr = ex.offheapAddress();
-
- for (int i = start; i < end; i++)
- hash = 31 * hash + BinaryPrimitives.readByte(ptr, i);
- }
- }
- else if (obj instanceof BinaryEnumObjectImpl) {
- int ord = obj.enumOrdinal();
-
- // Construct hash as if it was an int serialized in little-endian form.
- hash = 31 * hash + (ord & 0x000000FF);
- hash = 31 * hash + (ord & 0x0000FF00);
- hash = 31 * hash + (ord & 0x00FF0000);
- hash = 31 * hash + (ord & 0xFF000000);
- }
- else
- throw new BinaryObjectException("Array identity resolver cannot be used with provided BinaryObject " +
- "implementation: " + obj.getClass().getName());
-
- return hash;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean equals0(BinaryObject o1, BinaryObject o2) {
- if (o1 instanceof BinaryObjectEx && o2 instanceof BinaryObjectEx) {
- BinaryObjectEx ex1 = (BinaryObjectEx)o1;
- BinaryObjectEx ex2 = (BinaryObjectEx)o2;
-
- if (ex1.typeId() != ex2.typeId())
- return false;
-
- if (ex1 instanceof BinaryObjectExImpl) {
- // Handle regular object.
- assert ex2 instanceof BinaryObjectExImpl;
-
- BinaryObjectExImpl exx1 = (BinaryObjectExImpl)ex1;
- BinaryObjectExImpl exx2 = (BinaryObjectExImpl)ex2;
-
- if (exx1.hasArray())
- return exx2.hasArray() ? equalsHeap(exx1, exx2) : equalsHeapOffheap(exx1, exx2);
- else
- return exx2.hasArray() ? equalsHeapOffheap(exx2, exx1) : equalsOffheap(exx1, exx2);
- }
- else {
- // Handle enums.
- assert ex1 instanceof BinaryEnumObjectImpl;
- assert ex2 instanceof BinaryEnumObjectImpl;
-
- return ex1.enumOrdinal() == ex2.enumOrdinal();
- }
- }
-
- BinaryObject o = o1 instanceof BinaryObjectEx ? o2 : o1;
-
- throw new BinaryObjectException("Array identity resolver cannot be used with provided BinaryObject " +
- "implementation: " + o.getClass().getName());
- }
-
- /**
- * Compare two heap objects.
- *
- * @param o1 Object 1.
- * @param o2 Object 2.
- * @return Result.
- */
- private static boolean equalsHeap(BinaryObjectExImpl o1, BinaryObjectExImpl o2) {
- byte[] arr1 = o1.array();
- byte[] arr2 = o2.array();
-
- assert arr1 != null && arr2 != null;
-
- int i = o1.dataStartOffset();
- int j = o2.dataStartOffset();
-
- int end = o1.footerStartOffset();
-
- // Check length.
- if (end - i != o2.footerStartOffset() - j)
- return false;
-
- for (; i < end; i++, j++) {
- if (arr1[i] != arr2[j])
- return false;
- }
-
- return true;
- }
-
- /**
- * Compare heap and offheap objects.
- *
- * @param o1 Object 1 (heap).
- * @param o2 Object 2 (offheap).
- * @return Result.
- */
- private static boolean equalsHeapOffheap(BinaryObjectExImpl o1, BinaryObjectExImpl o2) {
- byte[] arr1 = o1.array();
- long ptr2 = o2.offheapAddress();
-
- assert arr1 != null && ptr2 != 0;
-
- int i = o1.dataStartOffset();
- int j = o2.dataStartOffset();
-
- int end = o1.footerStartOffset();
-
- // Check length.
- if (end - i != o2.footerStartOffset() - j)
- return false;
-
- for (; i < end; i++, j++) {
- if (arr1[i] != BinaryPrimitives.readByte(ptr2, j))
- return false;
- }
-
- return true;
- }
-
- /**
- * Compare two offheap objects.
- *
- * @param o1 Object 1.
- * @param o2 Object 2.
- * @return Result.
- */
- private static boolean equalsOffheap(BinaryObjectExImpl o1, BinaryObjectExImpl o2) {
- long ptr1 = o1.offheapAddress();
- long ptr2 = o2.offheapAddress();
-
- assert ptr1 != 0 && ptr2 != 0;
-
- int i = o1.dataStartOffset();
- int j = o2.dataStartOffset();
-
- int end = o1.footerStartOffset();
-
- // Check length.
- if (end - i != o2.footerStartOffset() - j)
- return false;
-
- for (; i < end; i++, j++) {
- if (BinaryPrimitives.readByte(ptr1, i) != BinaryPrimitives.readByte(ptr2, j))
- return false;
- }
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(BinaryArrayIdentityResolver.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/binary/BinaryFieldIdentityResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryFieldIdentityResolver.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryFieldIdentityResolver.java
deleted file mode 100644
index c4fc869..0000000
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryFieldIdentityResolver.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.binary;
-
-import org.apache.ignite.internal.binary.BinaryEnumObjectImpl;
-import org.apache.ignite.internal.binary.BinaryFieldImpl;
-import org.apache.ignite.internal.binary.BinaryObjectExImpl;
-import org.apache.ignite.internal.binary.BinarySerializedFieldComparator;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-import java.util.HashMap;
-
-/**
- * Identity resolver implementation which use the list of provided fields to calculate the hash code and to perform
- * equality checks.
- * <p>
- * Standard polynomial function with multiplier {@code 31} is used to calculate hash code. For example, for three
- * fields {@code [a, b, c]}it would be {@code hash = 31 * (31 * a + b) + c}. Order of fields is important.
- */
-public class BinaryFieldIdentityResolver extends BinaryAbstractIdentityResolver {
- /** Mutex for synchronization. */
- private final Object mux = new Object();
-
- /** Cached single accessor. */
- private volatile FieldAccessor accessor;
-
- /** Cached accessors used when multiple (typeId, schemaId) pairs are met. */
- private volatile HashMap<Long, FieldAccessor> accessors;
-
- /** Field names. */
- private String[] fieldNames;
-
- /**
- * Default constructor.
- */
- public BinaryFieldIdentityResolver() {
- // No-op.
- }
-
- /**
- * Copy constructor.
- *
- * @param other Other instance.
- */
- public BinaryFieldIdentityResolver(BinaryFieldIdentityResolver other) {
- fieldNames = other.fieldNames;
- }
-
- /**
- * @return Fields list to hash/compare objects based upon.
- */
- public String[] getFieldNames() {
- return fieldNames;
- }
-
- /**
- * Set field names.
- *
- * @param fieldNames Field names.
- * @return {@code this} for chaining.
- */
- public BinaryFieldIdentityResolver setFieldNames(String... fieldNames) {
- this.fieldNames = fieldNames;
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode0(BinaryObject obj) {
- if (obj instanceof BinaryObjectExImpl) {
- BinaryObjectExImpl obj0 = (BinaryObjectExImpl)obj;
-
- if (obj0.hasSchema()) {
- // Handle optimized case.
- FieldAccessor accessor = accessor(obj0, obj0.typeId(), obj0.schemaId());
-
- assert accessor != null;
-
- return accessor.hashCode(obj0);
- }
- }
- else if (obj instanceof BinaryEnumObjectImpl)
- throw new BinaryObjectException("Field identity resolver cannot be used with enums: " + obj);
-
- // Handle regular case.
- int hash = 0;
-
- for (String fieldName : fieldNames) {
- Object val = obj.field(fieldName);
-
- hash = 31 * hash + (val != null ? val.hashCode() : 0);
- }
-
- return hash;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals0(BinaryObject o1, BinaryObject o2) {
- if (o1 instanceof BinaryObjectExImpl && o2 instanceof BinaryObjectExImpl) {
- BinaryObjectExImpl ex1 = (BinaryObjectExImpl) o1;
- BinaryObjectExImpl ex2 = (BinaryObjectExImpl) o2;
-
- int typeId = ex1.typeId();
-
- if (typeId != ex2.typeId())
- return false;
-
- if (ex1.hasSchema() && ex2.hasSchema()) {
- // Optimistic case: both objects have schemas.
- int schemaId1 = ex1.schemaId();
- int schemaId2 = ex2.schemaId();
-
- FieldAccessor accessor1 = accessor(ex1, typeId, schemaId1);
-
- FieldAccessor accessor2;
-
- if (schemaId1 == schemaId2)
- accessor2 = accessor1;
- else
- accessor2 = accessor(ex2, typeId, schemaId2);
-
- // Even better case: compare fields without deserialization.
- BinarySerializedFieldComparator comp1 = ex1.createFieldComparator();
- BinarySerializedFieldComparator comp2 = ex2.createFieldComparator();
-
- for (int i = 0; i < fieldNames.length; i++) {
- comp1.findField(accessor1.orders[i]);
- comp2.findField(accessor2.orders[i]);
-
- if (!BinarySerializedFieldComparator.equals(comp1, comp2))
- return false;
- }
-
- return true;
- }
- else
- // Pessimistic case: object of unknown types, or without schemas. Have to read fields in usual way.
- return equalsSlow(ex1, ex2);
- }
-
- if (o1 instanceof BinaryEnumObjectImpl)
- throw new BinaryObjectException("Field identity resolver cannot be used with enums: " + o1);
-
- if (o2 instanceof BinaryEnumObjectImpl)
- throw new BinaryObjectException("Field identity resolver cannot be used with enums: " + o2);
-
- return o1.type().typeId() == o2.type().typeId() && equalsSlow(o1, o2);
- }
-
- /**
- * Slow-path equals routine: regular fields comparison.
- *
- * @param o1 Object 1.
- * @param o2 Object 2.
- * @return Result.
- */
- private boolean equalsSlow(BinaryObject o1, BinaryObject o2) {
- for (String fieldName : fieldNames) {
- Object val1 = o1.field(fieldName);
- Object val2 = o2.field(fieldName);
-
- if (!F.eq(val1, val2))
- return false;
- }
-
- return true;
- }
-
- /**
- * Get fields accessor for the given object.
- *
- * @param obj Object.
- * @param typId Type ID.
- * @param schemaId Schema ID.
- * @return Accessor.
- */
- private FieldAccessor accessor(BinaryObjectExImpl obj, int typId, int schemaId) {
- // Try getting single accessor.
- FieldAccessor res = accessor;
-
- if (res != null && res.applicableTo(typId, schemaId))
- return res;
-
- // Try reading from map.
- long key = ((long)typId << 32) + schemaId;
-
- HashMap<Long, FieldAccessor> accessors0 = accessors;
-
- if (accessors0 != null) {
- res = accessors0.get(key);
-
- if (res != null)
- return res;
- }
-
- // Failed to get from cache, go to locking.
- synchronized (mux) {
- // Create accessor.
- int[] orders = new int[fieldNames.length];
-
- BinaryType type = obj.type();
-
- for (int i = 0; i < fieldNames.length; i++) {
- BinaryFieldImpl field = (BinaryFieldImpl)type.field(fieldNames[i]);
-
- orders[i] = field.fieldOrder(obj);
- }
-
- res = new FieldAccessor(typId, schemaId, orders);
-
- // Set accessor.
- if (accessor == null)
- accessor = res;
- else {
- if (accessors == null) {
- accessor = null;
-
- accessors0 = new HashMap<>();
- }
- else
- accessors0 = new HashMap<>(accessors);
-
- accessors0.put(key, res);
-
- accessors = accessors0;
- }
- }
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(BinaryFieldIdentityResolver.class, this);
- }
-
- /**
- * Optimized fields accessor.
- */
- private static class FieldAccessor {
- /** Type ID. */
- private final int typeId;
-
- /** Schema ID. */
- private final int schemaId;
-
- /** Field orders. */
- private final int[] orders;
-
- /**
- * Constructor.
- *
- * @param typeId Type ID.
- * @param schemaId Schema ID.
- * @param orders Field orders.
- */
- private FieldAccessor(int typeId, int schemaId, int[] orders) {
- this.typeId = typeId;
- this.schemaId = schemaId;
- this.orders = orders;
- }
-
- /**
- * Check whether object is applicable to that hash code accessor.
- * @param expTypeId Expected schema ID.
- * @param expSchemaId Expected schema ID.
- * @return {@code True} if matches.
- */
- private boolean applicableTo(int expTypeId, int expSchemaId) {
- return typeId == expTypeId && schemaId == expSchemaId;
- }
-
- /**
- * Calculate object hash code.
- *
- * @param obj Object.
- * @return Hash code.
- */
- private int hashCode(BinaryObjectExImpl obj) {
- int hash = 0;
-
- for (int order : orders) {
- Object val = obj.fieldByOrder(order);
-
- hash = 31 * hash + (val != null ? val.hashCode() : 0);
- }
-
- return hash;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdentityResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdentityResolver.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdentityResolver.java
deleted file mode 100644
index 9796eca..0000000
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdentityResolver.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.binary;
-
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Interface to compute hash codes for new binary objects and compare them for equality.
- */
-public interface BinaryIdentityResolver {
- /**
- * Compute hash code for binary object.
- *
- * @param obj Binary object.
- * @return Hash code value.
- */
- public int hashCode(BinaryObject obj);
-
- /**
- * Compare two binary objects for equality.
- *
- * @param o1 First object.
- * @param o2 Second object.
- * @return {@code True} if both objects are equal.
- */
- public boolean equals(@Nullable BinaryObject o1, @Nullable BinaryObject o2);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
index 1b2d828..54b853c 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
@@ -43,9 +43,6 @@ public class BinaryTypeConfiguration {
/** Serializer. */
private BinarySerializer serializer;
- /** Identity. */
- private BinaryIdentityResolver identityRslvr;
-
/** Enum flag. */
private boolean isEnum;
@@ -64,7 +61,6 @@ public class BinaryTypeConfiguration {
public BinaryTypeConfiguration(BinaryTypeConfiguration other) {
A.notNull(other, "other");
- identityRslvr = other.identityRslvr;
idMapper = other.idMapper;
isEnum = other.isEnum;
serializer = other.serializer;
@@ -163,27 +159,6 @@ public class BinaryTypeConfiguration {
}
/**
- * Gets identity resolver.
- *
- * @return Identity resolver.
- */
- @Nullable public BinaryIdentityResolver getIdentityResolver() {
- return identityRslvr;
- }
-
- /**
- * Sets identity resolver.
- *
- * @param identityRslvr Identity resolver.
- * @return {@code this} for chaining.
- */
- public BinaryTypeConfiguration setIdentityResolver(@Nullable BinaryIdentityResolver identityRslvr) {
- this.identityRslvr = identityRslvr;
-
- return this;
- }
-
- /**
* Gets whether this is enum type.
*
* @return {@code True} if enum.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryAbstractIdentityResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryAbstractIdentityResolver.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryAbstractIdentityResolver.java
new file mode 100644
index 0000000..066ca80
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryAbstractIdentityResolver.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectException;
+
+/**
+ * Abstract identity resolver with common routines.
+ */
+public abstract class BinaryAbstractIdentityResolver implements BinaryIdentityResolver {
+ /** {@inheritDoc} */
+ @Override public int hashCode(BinaryObject obj) {
+ if (obj == null)
+ throw new BinaryObjectException("Cannot calculate hash code because binary object is null.");
+
+ return hashCode0(obj);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(BinaryObject o1, BinaryObject o2) {
+ return o1 == o2 || (o1 != null && o2 != null && equals0(o1, o2));
+ }
+
+ /**
+ * Internal hash code routine.
+ *
+ * @param obj Object.
+ * @return Result.
+ */
+ protected abstract int hashCode0(BinaryObject obj);
+
+ /**
+ * Internal equals routine.
+ *
+ * @param o1 First object.
+ * @param o2 Second object.
+ * @return Result.
+ */
+ protected abstract boolean equals0(BinaryObject o1, BinaryObject o2);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolver.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolver.java
new file mode 100644
index 0000000..14792e5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolver.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import java.util.Arrays;
+
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Identity resolver implementation which compares raw array content of the binary object.
+ * <p>
+ * Hash code is calculated in the same way as {@link Arrays#hashCode(byte[])} does.
+ */
+public class BinaryArrayIdentityResolver extends BinaryAbstractIdentityResolver {
+ /** Singleton instance */
+ private static final BinaryArrayIdentityResolver INSTANCE = new BinaryArrayIdentityResolver();
+
+ /**
+ * Get singleton instance.
+ *
+ * @return Singleton instance.
+ */
+ public static BinaryArrayIdentityResolver instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Default constructor.
+ */
+ public BinaryArrayIdentityResolver() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected int hashCode0(BinaryObject obj) {
+ int hash = 1;
+
+ if (obj instanceof BinaryObjectExImpl) {
+ BinaryObjectExImpl ex = (BinaryObjectExImpl)obj;
+
+ int start = ex.dataStartOffset();
+ int end = ex.footerStartOffset();
+
+ if (ex.hasArray()) {
+ // Handle heap object.
+ byte[] data = ex.array();
+
+ for (int i = start; i < end; i++)
+ hash = 31 * hash + data[i];
+ }
+ else {
+ // Handle offheap object.
+ long ptr = ex.offheapAddress();
+
+ for (int i = start; i < end; i++)
+ hash = 31 * hash + BinaryPrimitives.readByte(ptr, i);
+ }
+ }
+ else if (obj instanceof BinaryEnumObjectImpl) {
+ int ord = obj.enumOrdinal();
+
+ // Construct hash as if it was an int serialized in little-endian form.
+ hash = 31 * hash + (ord & 0x000000FF);
+ hash = 31 * hash + (ord & 0x0000FF00);
+ hash = 31 * hash + (ord & 0x00FF0000);
+ hash = 31 * hash + (ord & 0xFF000000);
+ }
+ else
+ throw new BinaryObjectException("Array identity resolver cannot be used with provided BinaryObject " +
+ "implementation: " + obj.getClass().getName());
+
+ return hash;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean equals0(BinaryObject o1, BinaryObject o2) {
+ if (o1 instanceof BinaryObjectEx && o2 instanceof BinaryObjectEx) {
+ BinaryObjectEx ex1 = (BinaryObjectEx)o1;
+ BinaryObjectEx ex2 = (BinaryObjectEx)o2;
+
+ if (ex1.typeId() != ex2.typeId())
+ return false;
+
+ if (ex1 instanceof BinaryObjectExImpl) {
+ // Handle regular object.
+ assert ex2 instanceof BinaryObjectExImpl;
+
+ BinaryObjectExImpl exx1 = (BinaryObjectExImpl)ex1;
+ BinaryObjectExImpl exx2 = (BinaryObjectExImpl)ex2;
+
+ if (exx1.hasArray())
+ return exx2.hasArray() ? equalsHeap(exx1, exx2) : equalsHeapOffheap(exx1, exx2);
+ else
+ return exx2.hasArray() ? equalsHeapOffheap(exx2, exx1) : equalsOffheap(exx1, exx2);
+ }
+ else {
+ // Handle enums.
+ assert ex1 instanceof BinaryEnumObjectImpl;
+ assert ex2 instanceof BinaryEnumObjectImpl;
+
+ return ex1.enumOrdinal() == ex2.enumOrdinal();
+ }
+ }
+
+ BinaryObject o = o1 instanceof BinaryObjectEx ? o2 : o1;
+
+ throw new BinaryObjectException("Array identity resolver cannot be used with provided BinaryObject " +
+ "implementation: " + o.getClass().getName());
+ }
+
+ /**
+ * Compare two heap objects.
+ *
+ * @param o1 Object 1.
+ * @param o2 Object 2.
+ * @return Result.
+ */
+ private static boolean equalsHeap(BinaryObjectExImpl o1, BinaryObjectExImpl o2) {
+ byte[] arr1 = o1.array();
+ byte[] arr2 = o2.array();
+
+ assert arr1 != null && arr2 != null;
+
+ int i = o1.dataStartOffset();
+ int j = o2.dataStartOffset();
+
+ int end = o1.footerStartOffset();
+
+ // Check length.
+ if (end - i != o2.footerStartOffset() - j)
+ return false;
+
+ for (; i < end; i++, j++) {
+ if (arr1[i] != arr2[j])
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Compare heap and offheap objects.
+ *
+ * @param o1 Object 1 (heap).
+ * @param o2 Object 2 (offheap).
+ * @return Result.
+ */
+ private static boolean equalsHeapOffheap(BinaryObjectExImpl o1, BinaryObjectExImpl o2) {
+ byte[] arr1 = o1.array();
+ long ptr2 = o2.offheapAddress();
+
+ assert arr1 != null && ptr2 != 0;
+
+ int i = o1.dataStartOffset();
+ int j = o2.dataStartOffset();
+
+ int end = o1.footerStartOffset();
+
+ // Check length.
+ if (end - i != o2.footerStartOffset() - j)
+ return false;
+
+ for (; i < end; i++, j++) {
+ if (arr1[i] != BinaryPrimitives.readByte(ptr2, j))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Compare two offheap objects.
+ *
+ * @param o1 Object 1.
+ * @param o2 Object 2.
+ * @return Result.
+ */
+ private static boolean equalsOffheap(BinaryObjectExImpl o1, BinaryObjectExImpl o2) {
+ long ptr1 = o1.offheapAddress();
+ long ptr2 = o2.offheapAddress();
+
+ assert ptr1 != 0 && ptr2 != 0;
+
+ int i = o1.dataStartOffset();
+ int j = o2.dataStartOffset();
+
+ int end = o1.footerStartOffset();
+
+ // Check length.
+ if (end - i != o2.footerStartOffset() - j)
+ return false;
+
+ for (; i < end; i++, j++) {
+ if (BinaryPrimitives.readByte(ptr1, i) != BinaryPrimitives.readByte(ptr2, j))
+ return false;
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(BinaryArrayIdentityResolver.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/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 00467cb..1ce2d65 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,14 +20,12 @@ 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;
import org.apache.ignite.binary.BinaryInvalidTypeException;
import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryIdentityResolver;
import org.apache.ignite.binary.BinaryReflectiveSerializer;
import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.binary.BinaryType;
@@ -454,7 +452,7 @@ public class BinaryContext {
BinaryIdMapper idMapper = U.firstNotNull(typeCfg.getIdMapper(), globalIdMapper);
BinaryNameMapper nameMapper = U.firstNotNull(typeCfg.getNameMapper(), globalNameMapper);
BinarySerializer serializer = U.firstNotNull(typeCfg.getSerializer(), globalSerializer);
- BinaryIdentityResolver identity = typeCfg.getIdentityResolver();
+ BinaryIdentityResolver identity = BinaryArrayIdentityResolver.instance();
BinaryInternalMapper mapper = resolveMapper(nameMapper, idMapper);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryIdentityResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryIdentityResolver.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryIdentityResolver.java
new file mode 100644
index 0000000..8da28d0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryIdentityResolver.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import org.apache.ignite.binary.BinaryObject;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Interface to compute hash codes for new binary objects and compare them for equality.
+ */
+public interface BinaryIdentityResolver {
+ /**
+ * Compute hash code for binary object.
+ *
+ * @param obj Binary object.
+ * @return Hash code value.
+ */
+ public int hashCode(BinaryObject obj);
+
+ /**
+ * Compare two binary objects for equality.
+ *
+ * @param o1 First object.
+ * @param o2 Second object.
+ * @return {@code True} if both objects are equal.
+ */
+ public boolean equals(@Nullable BinaryObject o1, @Nullable BinaryObject o2);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/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 b153b58..ae9a160 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
@@ -27,7 +27,6 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryIdentityResolver;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.util.typedef.internal.S;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/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 5ae47fc..7b5e9d3 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
@@ -30,7 +30,6 @@ import java.util.Date;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdentityResolver;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.BinaryWriter;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 448788d..1753cfd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -34,9 +34,8 @@ import java.util.ServiceLoader;
import javax.cache.configuration.Factory;
import javax.cache.expiry.ExpiryPolicy;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryArrayIdentityResolver;
-import org.apache.ignite.binary.BinaryFieldIdentityResolver;
-import org.apache.ignite.binary.BinaryIdentityResolver;
+import org.apache.ignite.internal.binary.BinaryArrayIdentityResolver;
+import org.apache.ignite.internal.binary.BinaryIdentityResolver;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.BinaryTypeConfiguration;
@@ -588,23 +587,6 @@ public class PlatformConfigurationUtils {
if (in.readBoolean()) // compact footer is set
cfg.getBinaryConfiguration().setCompactFooter(in.readBoolean());
-
- int typeCnt = in.readInt();
-
- if (typeCnt > 0) {
- Collection<BinaryTypeConfiguration> types = new ArrayList<>(typeCnt);
-
- for (int i = 0; i < typeCnt; i++) {
- BinaryTypeConfiguration type = new BinaryTypeConfiguration(in.readString());
-
- type.setEnum(in.readBoolean());
- type.setIdentityResolver(readBinaryIdentityResolver(in));
-
- types.add(type);
- }
-
- cfg.getBinaryConfiguration().setTypeConfigurations(types);
- }
}
int attrCnt = in.readInt();
@@ -1007,20 +989,6 @@ public class PlatformConfigurationUtils {
w.writeBoolean(true); // binary config exists
w.writeBoolean(true); // compact footer is set
w.writeBoolean(bc.isCompactFooter());
-
- Collection<BinaryTypeConfiguration> types = bc.getTypeConfigurations();
-
- if (types != null) {
- w.writeInt(types.size());
-
- for (BinaryTypeConfiguration type : types) {
- w.writeString(type.getTypeName());
- w.writeBoolean(type.isEnum());
- writeBinaryIdentityResolver(w, type.getIdentityResolver());
- }
- }
- else
- w.writeInt(0);
}
else
w.writeBoolean(false);
@@ -1193,17 +1161,6 @@ public class PlatformConfigurationUtils {
case 1:
return new BinaryArrayIdentityResolver();
-
- case 2:
- int cnt = r.readInt();
-
- String[] fields = new String[cnt];
-
- for (int i = 0; i < cnt; i++)
- fields[i] = r.readString();
-
- return new BinaryFieldIdentityResolver().setFieldNames(fields);
-
default:
assert false;
return null;
@@ -1219,23 +1176,8 @@ public class PlatformConfigurationUtils {
private static void writeBinaryIdentityResolver(BinaryRawWriter w, BinaryIdentityResolver resolver) {
if (resolver instanceof BinaryArrayIdentityResolver)
w.writeByte((byte)1);
- else if (resolver instanceof BinaryFieldIdentityResolver) {
- w.writeByte((byte)2);
-
- String[] fields = ((BinaryFieldIdentityResolver)resolver).getFieldNames();
-
- if (fields != null) {
- w.writeInt(fields.length);
-
- for (String field : fields)
- w.writeString(field);
- }
- else
- w.writeInt(0);
- }
- else {
+ else
w.writeByte((byte)0);
- }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java
index 91500d8..7344cfa 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryArrayIdentityResolverSelfTest.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.binary;
-import org.apache.ignite.binary.BinaryArrayIdentityResolver;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
@@ -81,9 +80,6 @@ public class BinaryArrayIdentityResolverSelfTest extends GridCommonAbstractTest
binTypCfg1.setTypeName(InnerClass.class.getName());
binTypCfg2.setTypeName(InnerClassBinarylizable.class.getName());
- binTypCfg1.setIdentityResolver(BinaryArrayIdentityResolver.instance());
- binTypCfg2.setIdentityResolver(BinaryArrayIdentityResolver.instance());
-
List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();
binTypCfgs.add(binTypCfg1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldIdentityResolverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldIdentityResolverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldIdentityResolverSelfTest.java
deleted file mode 100644
index 853f5d9..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldIdentityResolverSelfTest.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.binary;
-
-import org.apache.ignite.binary.BinaryFieldIdentityResolver;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.eclipse.jetty.util.ConcurrentHashSet;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import static org.junit.Assert.assertNotEquals;
-
-/**
- * Field identity resolver self test.
- */
-public class BinaryFieldIdentityResolverSelfTest extends GridCommonAbstractTest {
- /** Pointers to release. */
- private final Set<Long> ptrs = new ConcurrentHashSet<>();
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- startGrid();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
-
- super.afterTestsStopped();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- for (Long ptr : ptrs)
- GridUnsafe.freeMemory(ptr);
-
- super.afterTest();
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setMarshaller(new BinaryMarshaller());
-
- BinaryConfiguration binCfg = new BinaryConfiguration();
-
- BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration();
- BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration();
-
- binTypCfg1.setTypeName(InnerClass.class.getName());
- binTypCfg2.setTypeName(InnerClassBinarylizable.class.getName());
-
- BinaryFieldIdentityResolver binTypIdentityRslvr = new BinaryFieldIdentityResolver();
-
- binTypIdentityRslvr.setFieldNames("a", "b");
-
- binTypCfg1.setIdentityResolver(binTypIdentityRslvr);
- binTypCfg2.setIdentityResolver(binTypIdentityRslvr);
-
- List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();
-
- binTypCfgs.add(binTypCfg1);
- binTypCfgs.add(binTypCfg2);
-
- binCfg.setTypeConfigurations(binTypCfgs);
-
- cfg.setBinaryConfiguration(binCfg);
-
- return cfg;
- }
-
- /**
- * Test hash code generation for simple object.
- */
- public void testHashCode() {
- // Simple case.
- InnerClass obj = new InnerClass(1, "2", 3);
-
- int expHash = 31 * obj.a + obj.b.hashCode();
-
- assertEquals(expHash, asBinary(obj).hashCode());
- assertEquals(expHash, build(InnerClass.class, "a", obj.a, "b", obj.b, "c", obj.c).hashCode());
-
- // Different fields count.
- assertEquals(expHash, build(InnerClass.class, "a", obj.a, "b", obj.b, "c", obj.c, "d", "d").hashCode());
-
- // Null fields.
- obj = new InnerClass(1, null, 3);
-
- expHash = 31 * obj.a;
-
- assertEquals(expHash, asBinary(obj).hashCode());
- assertEquals(expHash, build(InnerClass.class, "a", obj.a, "b", obj.b, "c", obj.c).hashCode());
- assertEquals(expHash, build(InnerClass.class, "a", obj.a).hashCode());
- }
-
- /**
- * Test hash code generation for simple object.
- */
- public void testHashCodeBinarylizable() {
- // Simple case.
- InnerClassBinarylizable obj = new InnerClassBinarylizable(1, "2", 3);
-
- int expHash = 31 * obj.a + obj.b.hashCode();
-
- assertEquals(expHash, asBinary(obj).hashCode());
- assertEquals(expHash, build(InnerClassBinarylizable.class, "a", obj.a, "b", obj.b, "c", obj.c).hashCode());
-
- // Different fields count.
- assertEquals(expHash, build(InnerClassBinarylizable.class,"a", obj.a, "b", obj.b, "c", obj.c, "d", "d")
- .hashCode());
-
- // Null fields.
- obj = new InnerClassBinarylizable(1, null, 3);
-
- expHash = 31 * obj.a;
-
- assertEquals(expHash, asBinary(obj).hashCode());
- assertEquals(expHash, build(InnerClassBinarylizable.class, "a", obj.a, "b", obj.b, "c", obj.c).hashCode());
- assertEquals(expHash, build(InnerClassBinarylizable.class, "a", obj.a).hashCode());
- }
-
- /**
- * Test equals for simple object.
- */
- public void testEquals() {
- InnerClass obj = new InnerClass(1, "2", 3);
-
- // Positive cases.
- compareTwo(asBinary(obj), asBinary(obj), true);
- compareTwo(asBinary(obj), build(InnerClass.class, "a", obj.a, "b", obj.b), true);
- compareTwo(asBinary(obj), build(InnerClass.class, "a", obj.a, "b", obj.b, "c", obj.c), true);
- compareTwo(asBinary(obj), build(InnerClass.class, "a", obj.a, "b", obj.b, "c", obj.c, "d", "d"), true);
-
- // Negative cases.
- compareTwo(asBinary(obj), build(InnerClass.class, "a", obj.a), false);
- compareTwo(asBinary(obj), build(InnerClass.class, "a", obj.a, "b", obj.b + "1"), false);
- compareTwo(asBinary(obj), build(InnerClass.class, "a", obj.a + 1, "b", obj.b), false);
- }
-
- /**
- * Test equals for simple object.
- */
- public void testEqualsBinarilyzable() {
- InnerClassBinarylizable obj = new InnerClassBinarylizable(1, "2", 3);
-
- // Positive cases.
- compareTwo(asBinary(obj), asBinary(obj), true);
- compareTwo(asBinary(obj), build(InnerClassBinarylizable.class, "a", obj.a, "b", obj.b), true);
- compareTwo(asBinary(obj), build(InnerClassBinarylizable.class, "a", obj.a, "b", obj.b, "c", obj.c),
- true);
- compareTwo(asBinary(obj), build(InnerClassBinarylizable.class, "a", obj.a, "b", obj.b, "c", obj.c, "d", "d"),
- true);
-
- // Negative cases.
- compareTwo(asBinary(obj), build(InnerClassBinarylizable.class, "a", obj.a), false);
- compareTwo(asBinary(obj), build(InnerClassBinarylizable.class, "a", obj.a, "b", obj.b + "1"), false);
- compareTwo(asBinary(obj), build(InnerClassBinarylizable.class, "a", obj.a + 1, "b", obj.b), false);
- }
-
- /**
- * Test equals for different type IDs.
- */
- public void testEqualsDifferenTypes() {
- InnerClass obj1 = new InnerClass(1, "2", 3);
- InnerClassBinarylizable obj2 = new InnerClassBinarylizable(1, "2", 3);
-
- compareTwo(asBinary(obj1), asBinary(obj2), false);
- }
-
- /**
- * Compare two objects in different heap/offheap modes.
- *
- * @param obj1 Object 1.
- * @param obj2 Object 2.
- * @param expRes Expected result.
- */
- private void compareTwo(BinaryObject obj1, BinaryObject obj2, boolean expRes) {
- if (expRes) {
- assertEquals(convert(obj1, false), convert(obj2, false));
- assertEquals(convert(obj1, false), convert(obj2, true));
- assertEquals(convert(obj1, true), convert(obj2, false));
- assertEquals(convert(obj1, true), convert(obj2, true));
- }
- else {
- assertNotEquals(convert(obj1, false), convert(obj2, false));
- assertNotEquals(convert(obj1, false), convert(obj2, true));
- assertNotEquals(convert(obj1, true), convert(obj2, false));
- assertNotEquals(convert(obj1, true), convert(obj2, true));
- }
- }
-
- /**
- * Convert to binary object.
- *
- * @param obj Original object.
- * @return Binary object.
- */
- private BinaryObject asBinary(Object obj) {
- return grid().binary().toBinary(obj);
- }
-
- /**
- * Build object of the given type with provided fields.
- *
- * @param cls Class.
- * @param parts Parts.
- * @return Result.
- */
- private BinaryObject build(Class cls, Object... parts) {
- BinaryObjectBuilder builder = grid().binary().builder(cls.getName());
-
- if (!F.isEmpty(parts)) {
- for (int i = 0; i < parts.length; )
- builder.setField((String)parts[i++], parts[i++]);
- }
-
- return builder.build();
- }
-
- /**
- * Inner class.
- */
- private static class InnerClass {
- /** Field a. */
- public int a;
-
- /** Field b. */
- public String b;
-
- /** Field c. */
- public long c;
-
- /**
- * Constructor.
- *
- * @param a Field a.
- * @param b Field b.
- * @param c Field c.
- */
- public InnerClass(int a, String b, long c) {
- this.a = a;
- this.b = b;
- this.c = c;
- }
- }
-
- /**
- * Convert binary object to it's final state.
- *
- * @param obj Object.
- * @param offheap Offheap flag.
- * @return Result.
- */
- private BinaryObjectExImpl convert(BinaryObject obj, boolean offheap) {
- BinaryObjectExImpl obj0 = (BinaryObjectExImpl)obj;
-
- if (offheap) {
- byte[] arr = obj0.array();
-
- long ptr = GridUnsafe.allocateMemory(arr.length);
-
- ptrs.add(ptr);
-
- GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
-
- obj0 = new BinaryObjectOffheapImpl(obj0.context(), ptr, 0, obj0.array().length);
- }
-
- return obj0;
- }
-
- /**
- * Inner class with Binarylizable interface.
- */
- private static class InnerClassBinarylizable extends InnerClass implements Binarylizable {
- /**
- * Constructor.
- *
- * @param a Field a.
- * @param b Field b.
- * @param c Field c.
- */
- public InnerClassBinarylizable(int a, String b, long c) {
- super(a, b, c);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
- writer.writeLong("c", c);
- writer.writeInt("a", a);
- writer.writeString("b", b);
- }
-
- /** {@inheritDoc} */
- @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
- c = reader.readLong("c");
- a = reader.readInt("a");
- b = reader.readString("b");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryIdentityResolverConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryIdentityResolverConfigurationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryIdentityResolverConfigurationSelfTest.java
deleted file mode 100644
index f56382f..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryIdentityResolverConfigurationSelfTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.binary;
-
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.binary.BinaryArrayIdentityResolver;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Test for identity resolver configuration.
- */
-public class BinaryIdentityResolverConfigurationSelfTest extends GridCommonAbstractTest {
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- super.beforeTestsStarted();
-
- startGrid();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
-
- super.afterTestsStopped();
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setMarshaller(new BinaryMarshaller());
-
- BinaryConfiguration binCfg = new BinaryConfiguration();
-
- BinaryTypeConfiguration binTypCfg = new BinaryTypeConfiguration();
-
- binTypCfg.setTypeName(MyClass.class.getName());
- binTypCfg.setIdentityResolver(new CustomResolver());
-
- List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();
-
- binTypCfgs.add(binTypCfg);
-
- binCfg.setTypeConfigurations(binTypCfgs);
-
- cfg.setBinaryConfiguration(binCfg);
-
- return cfg;
- }
-
- /**
- * Test type resolver.
- */
- public void testTypeResolver() {
- MyClass obj = new MyClass(1, 2);
-
- int expHash = hash(obj.a, obj.b);
-
- BinaryObject binObj1 = binary().toBinary(obj);
- BinaryObject binObj2 =
- binary().builder(MyClass.class.getName()).setField("a", obj.a).setField("b", obj.b).build();
-
- assertEquals(expHash, binObj1.hashCode());
- assertEquals(expHash, binObj2.hashCode());
- }
-
- /**
- * @return Binary interface for current Ignite instance.
- */
- public IgniteBinary binary() {
- return grid().binary();
- }
-
- /**
- * Second hash function.
- *
- * @param a First value.
- * @param b Second value.
- * @return Result.
- */
- public static int hash(Object a, Object b) {
- return 31 * a.hashCode() + b.hashCode();
- }
-
- /**
- * First class.
- */
- private static class MyClass {
- /** Value 1. */
- public int a;
-
- /** Value 2. */
- public int b;
-
- /**
- * Constructor.
- *
- * @param a Value 1.
- * @param b Value 2.
- */
- public MyClass(int a, int b) {
- this.a = a;
- this.b = b;
- }
- }
-
- /**
- * First custom identity resolver.
- */
- private static class CustomResolver extends BinaryArrayIdentityResolver {
- /** {@inheritDoc} */
- @Override protected int hashCode0(BinaryObject obj) {
- return hash(obj.field("a"), obj.field("b"));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/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 09f1c39..6f2a103 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,7 +49,6 @@ 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;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/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 a4d9860..ff6a3b1 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,7 +29,6 @@ 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;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/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 ea151be..134ed68 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
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import java.util.concurrent.Callable;
import javax.cache.Cache;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
@@ -37,12 +36,10 @@ import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.binary.BinaryArrayIdentityResolver;
import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryIdentityResolver;
import org.apache.ignite.binary.BinaryReader;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.binary.BinaryWriter;
@@ -61,12 +58,10 @@ import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryObjectImpl;
import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
-import org.apache.ignite.binary.BinaryFieldIdentityResolver;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.cache.MapCacheStoreStrategy;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P2;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -130,33 +125,6 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
binTypes.add(new BinaryTypeConfiguration() {{
setTypeName("ArrayHashedKey");
-
- setIdentityResolver(new BinaryArrayIdentityResolver());
- }});
-
- binTypes.add(new BinaryTypeConfiguration() {{
- setTypeName("FieldsHashedKey");
-
- BinaryFieldIdentityResolver id = new BinaryFieldIdentityResolver();
- id.setFieldNames("fld1", "fld3");
-
- setIdentityResolver(id);
- }});
-
- binTypes.add(new BinaryTypeConfiguration() {{
- setTypeName("CustomHashedKey");
-
- setIdentityResolver(new IdentityResolver());
- }});
-
- binTypes.add(new BinaryTypeConfiguration() {{
- setTypeName(ComplexBinaryFieldsListHashedKey.class.getName());
-
- BinaryFieldIdentityResolver id = new BinaryFieldIdentityResolver();
-
- id.setFieldNames("secondField", "thirdField");
-
- setIdentityResolver(id);
}});
BinaryConfiguration binCfg = new BinaryConfiguration();
@@ -165,10 +133,8 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
cfg.setBinaryConfiguration(binCfg);
CacheKeyConfiguration arrayHashCfg = new CacheKeyConfiguration("ArrayHashedKey", "fld1");
- CacheKeyConfiguration fieldsHashCfg = new CacheKeyConfiguration("FieldsHashedKey", "fld1");
- CacheKeyConfiguration customHashCfg = new CacheKeyConfiguration("CustomHashedKey", "fld1");
- cfg.setCacheKeyConfiguration(arrayHashCfg, fieldsHashCfg, customHashCfg);
+ cfg.setCacheKeyConfiguration(arrayHashCfg);
GridCacheBinaryObjectsAbstractSelfTest.cfg = cfg;
@@ -937,7 +903,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
// Now let's build an identical key for get
BinaryObjectBuilder bldr = grid(0).binary().builder(ComplexBinaryFieldsListHashedKey.class.getName());
- bldr.setField("firstField", 365);
+ bldr.setField("firstField", 1);
bldr.setField("secondField", "value");
bldr.setField("thirdField", 0x1020304050607080L);
@@ -991,7 +957,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
BinaryObjectBuilder bldr = grid(0).binary().builder("FieldsHashedKey");
bldr.setField("fld1", 5);
- bldr.setField("fld2", 1);
+ bldr.setField("fld2", 100);
bldr.setField("fld3", "abc");
BinaryObject binKey = bldr.build();
@@ -1036,7 +1002,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
BinaryObjectBuilder bldr = grid(0).binary().builder("CustomHashedKey");
bldr.setField("fld1", 5);
- bldr.setField("fld2", "xxx");
+ bldr.setField("fld2", "abc");
BinaryObject binKey = bldr.build();
@@ -1344,22 +1310,6 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
}
/**
- *
- */
- private final static class IdentityResolver implements BinaryIdentityResolver {
- /** {@inheritDoc} */
- @Override public int hashCode(BinaryObject builder) {
- return (Integer) builder.field("fld1") * 31 / 5;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(BinaryObject o1, BinaryObject o2) {
- return o1 == o2 || (o1 != null && o2 != null && F.eq(o1.field("fld1"), o2.field("fld1")));
-
- }
- }
-
- /**
* Key to test puts and gets with
*/
@SuppressWarnings({"ConstantConditions", "unused"})
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 782c274..7cc37e8 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -23,12 +23,10 @@ import org.apache.ignite.internal.binary.BinaryBasicIdMapperSelfTest;
import org.apache.ignite.internal.binary.BinaryBasicNameMapperSelfTest;
import org.apache.ignite.internal.binary.BinaryConfigurationConsistencySelfTest;
import org.apache.ignite.internal.binary.BinaryEnumsSelfTest;
-import org.apache.ignite.internal.binary.BinaryFieldIdentityResolverSelfTest;
import org.apache.ignite.internal.binary.BinaryFieldsHeapSelfTest;
import org.apache.ignite.internal.binary.BinaryFieldsOffheapSelfTest;
import org.apache.ignite.internal.binary.BinaryFooterOffsetsHeapSelfTest;
import org.apache.ignite.internal.binary.BinaryFooterOffsetsOffheapSelfTest;
-import org.apache.ignite.internal.binary.BinaryIdentityResolverConfigurationSelfTest;
import org.apache.ignite.internal.binary.BinaryMarshallerSelfTest;
import org.apache.ignite.internal.binary.BinaryObjectBuilderAdditionalSelfTest;
import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
@@ -98,8 +96,6 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
suite.addTestSuite(BinarySerialiedFieldComparatorSelfTest.class);
suite.addTestSuite(BinaryArrayIdentityResolverSelfTest.class);
- suite.addTestSuite(BinaryFieldIdentityResolverSelfTest.class);
- suite.addTestSuite(BinaryIdentityResolverConfigurationSelfTest.class);
suite.addTestSuite(BinaryConfigurationConsistencySelfTest.class);
suite.addTestSuite(GridBinaryMarshallerCtxDisabledSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java
index 3fde5dd..ea6e79b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractInsertSqlQuerySelfTest.java
@@ -20,14 +20,9 @@ package org.apache.ignite.internal.processors.cache;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryAbstractIdentityResolver;
-import org.apache.ignite.binary.BinaryArrayIdentityResolver;
-import org.apache.ignite.binary.BinaryFieldIdentityResolver;
-import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.cache.CacheAtomicityMode;
@@ -88,23 +83,9 @@ public abstract class IgniteCacheAbstractInsertSqlQuerySelfTest extends GridComm
binCfg.setTypeConfigurations(Arrays.asList(
new BinaryTypeConfiguration() {{
setTypeName(Key.class.getName());
-
- setIdentityResolver(BinaryArrayIdentityResolver.instance());
}},
new BinaryTypeConfiguration() {{
setTypeName(Key2.class.getName());
-
- setIdentityResolver(BinaryArrayIdentityResolver.instance());
- }},
- new BinaryTypeConfiguration() {{
- setTypeName(Key3.class.getName());
-
- setIdentityResolver(new BinaryFieldIdentityResolver().setFieldNames("key"));
- }},
- new BinaryTypeConfiguration() {{
- setTypeName(Key4.class.getName());
-
- setIdentityResolver(new Key4Id());
}}
));
@@ -237,52 +218,6 @@ public abstract class IgniteCacheAbstractInsertSqlQuerySelfTest extends GridComm
}
{
- CacheConfiguration k32pCcfg = cacheConfig("K32P", true, false);
-
- QueryEntity k32p = new QueryEntity(Key3.class.getName(), "Person");
-
- k32p.setKeyFields(new HashSet<>(Arrays.asList("key", "strKey")));
-
- LinkedHashMap<String, String> flds = new LinkedHashMap<>();
-
- flds.put("key", Integer.class.getName());
- flds.put("strKey", String.class.getName());
- flds.put("id", Integer.class.getName());
- flds.put("firstName", String.class.getName());
-
- k32p.setFields(flds);
-
- k32p.setIndexes(Collections.<QueryIndex>emptyList());
-
- k32pCcfg.setQueryEntities(Collections.singletonList(k32p));
-
- ignite(0).createCache(k32pCcfg);
- }
-
- {
- CacheConfiguration k42pCcfg = cacheConfig("K42P", true, false);
-
- QueryEntity k42p = new QueryEntity(Key4.class.getName(), "Person");
-
- k42p.setKeyFields(new HashSet<>(Arrays.asList("key", "strKey")));
-
- LinkedHashMap<String, String> flds = new LinkedHashMap<>();
-
- flds.put("key", Integer.class.getName());
- flds.put("strKey", String.class.getName());
- flds.put("id", Integer.class.getName());
- flds.put("firstName", String.class.getName());
-
- k42p.setFields(flds);
-
- k42p.setIndexes(Collections.<QueryIndex>emptyList());
-
- k42pCcfg.setQueryEntities(Collections.singletonList(k42p));
-
- ignite(0).createCache(k42pCcfg);
- }
-
- {
CacheConfiguration i2iCcfg = cacheConfig("I2I", true, false);
QueryEntity i2i = new QueryEntity(Integer.class.getName(), Integer.class.getName());
@@ -310,11 +245,6 @@ public abstract class IgniteCacheAbstractInsertSqlQuerySelfTest extends GridComm
ignite(0).cache("K22P").clear();
ignite(0).cache("I2I").clear();
- if (isBinaryMarshaller()) {
- ignite(0).cache("K32P").clear();
- ignite(0).cache("K42P").clear();
- }
-
super.afterTest();
}
@@ -444,65 +374,6 @@ public abstract class IgniteCacheAbstractInsertSqlQuerySelfTest extends GridComm
/**
*
*/
- final static class Key3 implements Serializable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- public Key3(int key) {
- this.key = key;
- this.strKey = Integer.toString(key);
- }
-
- /** */
- @QuerySqlField
- public final int key;
-
- /** */
- @QuerySqlField
- public final String strKey;
- }
-
- /**
- *
- */
- final static class Key4 implements Serializable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- public Key4(int key) {
- this.key = key;
- this.strKey = Integer.toString(key);
- }
-
- /** */
- @QuerySqlField
- public final int key;
-
- /** */
- @QuerySqlField
- public final String strKey;
- }
-
- /**
- *
- */
- final static class Key4Id extends BinaryAbstractIdentityResolver {
- /** {@inheritDoc} */
- @Override protected int hashCode0(BinaryObject obj) {
- return (int) obj.field("key") * 100;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean equals0(BinaryObject o1, BinaryObject o2) {
- return (int) o1.field("key") == (int) o2.field("key");
- }
- }
-
- /**
- *
- */
protected static class Person implements Serializable {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
index 8a4d1cd..27f9569 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInsertSqlQuerySelfTest.java
@@ -173,46 +173,6 @@ public class IgniteCacheInsertSqlQuerySelfTest extends IgniteCacheAbstractInsert
/**
*
*/
- public void testFieldsListIdentity() {
- if (!isBinaryMarshaller())
- return;
-
- fail("https://issues.apache.org/jira/browse/IGNITE-4889");
-
- IgniteCache<Key3, Person> p = ignite(0).cache("K32P").withKeepBinary();
-
- p.query(new SqlFieldsQuery(
- "insert into Person (key, strKey, id, firstName) values (1, 'aa', ?, ?), (2, 'bb', 2, 'Alex')")
- .setArgs(1, "Sergi"));
-
- assertEquals(createPerson(1, "Sergi"), p.get(new Key3(1)));
-
- assertEquals(createPerson(2, "Alex"), p.get(new Key3(2)));
- }
-
- /**
- *
- */
- public void testCustomIdentity() {
- if (!isBinaryMarshaller())
- return;
-
- fail("https://issues.apache.org/jira/browse/IGNITE-4889");
-
- IgniteCache<Key4, Person> p = ignite(0).cache("K42P").withKeepBinary();
-
- p.query(new SqlFieldsQuery(
- "insert into Person (key, strKey, id, firstName) values (1, 'aa', ?, ?), (2, 'bb', 2, 'Alex')")
- .setArgs(1, "Sergi"));
-
- assertEquals(createPerson(1, "Sergi"), p.get(new Key4(1)));
-
- assertEquals(createPerson(2, "Alex"), p.get(new Key4(2)));
- }
-
- /**
- *
- */
public void testUuidHandling() {
IgniteCache<UUID, Integer> p = ignite(0).cache("U2I");