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:44 UTC
[1/3] ignite git commit: IGNITE-41919 - Removed identity resolvers
Repository: ignite
Updated Branches:
refs/heads/ignite-3477-master 872f34ad1 -> c2d8bd9a4
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs
index 6400751..5f28270 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryEqualityComparerSerializer.cs
@@ -1,99 +1 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Binary
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Binary;
-
- /// <summary>
- /// Reads and writes <see cref="IBinaryEqualityComparer"/>.
- /// </summary>
- internal static class BinaryEqualityComparerSerializer
- {
- /// <summary>
- /// Comparer type.
- /// </summary>
- private enum Type : byte
- {
- None = 0,
- Array = 1,
- Field = 2
- }
-
- /// <summary>
- /// Writes an instance.
- /// </summary>
- public static void Write(IBinaryRawWriter writer, IBinaryEqualityComparer comparer)
- {
- if (comparer == null)
- {
- writer.WriteByte((byte) Type.None);
- return;
- }
-
- var arrCmp = comparer as BinaryArrayEqualityComparer;
-
- if (arrCmp != null)
- {
- writer.WriteByte((byte) Type.Array);
- return;
- }
-
- var fieldCmp = (BinaryFieldEqualityComparer) comparer;
-
- writer.WriteByte((byte) Type.Field);
-
- fieldCmp.Validate();
-
- writer.WriteInt(fieldCmp.FieldNames.Count);
-
- foreach (var field in fieldCmp.FieldNames)
- writer.WriteString(field);
- }
-
- /// <summary>
- /// Reads an instance.
- /// </summary>
- /// <param name="reader">The reader.</param>
- /// <returns></returns>
- public static IEqualityComparer<IBinaryObject> Read(IBinaryRawReader reader)
- {
- var type = (Type) reader.ReadByte();
-
- switch (type)
- {
- case Type.None:
- return null;
-
- case Type.Array:
- return new BinaryArrayEqualityComparer();
-
- case Type.Field:
- return new BinaryFieldEqualityComparer
- {
- FieldNames = Enumerable.Range(0, reader.ReadInt()).Select(x => reader.ReadString()).ToArray()
- };
-
- default:
- throw new ArgumentOutOfRangeException("reader", type, "Invalid EqualityComparer type code");
- }
- }
- }
-}
+\ufeff
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFieldEqualityComparer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFieldEqualityComparer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFieldEqualityComparer.cs
deleted file mode 100644
index 433657a..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFieldEqualityComparer.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Binary
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Binary.IO;
- using Apache.Ignite.Core.Impl.Common;
-
- /// <summary>
- /// Uses a set of binary object fields to calculate hash code and check equality.
- /// Not implemented for now, will be done as part of IGNITE-4397.
- /// </summary>
- internal class BinaryFieldEqualityComparer : IEqualityComparer<IBinaryObject>, IBinaryEqualityComparer
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="BinaryFieldEqualityComparer"/> class.
- /// </summary>
- public BinaryFieldEqualityComparer()
- {
- // No-op.
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="BinaryFieldEqualityComparer"/> class.
- /// </summary>
- /// <param name="fieldNames">The field names for comparison.</param>
- public BinaryFieldEqualityComparer(params string[] fieldNames)
- {
- IgniteArgumentCheck.NotNullOrEmpty(fieldNames, "fieldNames");
-
- FieldNames = fieldNames;
- }
-
- /// <summary>
- /// Gets or sets the field names to be used for equality comparison.
- /// </summary>
- public ICollection<string> FieldNames { get; set; }
-
- /// <summary>
- /// Determines whether the specified objects are equal.
- /// </summary>
- /// <param name="x">The first object to compare.</param>
- /// <param name="y">The second object to compare.</param>
- /// <returns>
- /// true if the specified objects are equal; otherwise, false.
- /// </returns>
- public bool Equals(IBinaryObject x, IBinaryObject y)
- {
- throw new NotSupportedException(GetType() + "is not intended for direct usage.");
- }
-
- /// <summary>
- /// Returns a hash code for this instance.
- /// </summary>
- /// <param name="obj">The object.</param>
- /// <returns>
- /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
- /// </returns>
- public int GetHashCode(IBinaryObject obj)
- {
- throw new NotSupportedException(GetType() + "is not intended for direct usage.");
- }
-
- /** <inheritdoc /> */
- int IBinaryEqualityComparer.GetHashCode(IBinaryStream stream, int startPos, int length,
- BinaryObjectSchemaHolder schema, int schemaId, Marshaller marshaller, IBinaryTypeDescriptor desc)
- {
- Debug.Assert(stream != null);
- Debug.Assert(startPos >= 0);
- Debug.Assert(length >= 0);
- Debug.Assert(schema != null);
- Debug.Assert(marshaller != null);
- Debug.Assert(desc != null);
-
- Validate();
-
- stream.Flush();
-
- // Preserve stream position.
- var pos = stream.Position;
-
- var reader = marshaller.StartUnmarshal(stream, BinaryMode.ForceBinary);
- var fields = schema.GetFullSchema(schemaId);
-
- int hash = 0;
-
- foreach (var fieldName in FieldNames)
- {
- int fieldId = BinaryUtils.FieldId(desc.TypeId, fieldName, desc.NameMapper, desc.IdMapper);
- int fieldHash = 0; // Null (missing) field hash code is 0.
- int fieldPos;
-
- if (fields.TryGetValue(fieldId, out fieldPos))
- {
- stream.Seek(startPos + fieldPos - BinaryObjectHeader.Size, SeekOrigin.Begin);
- var fieldVal = reader.Deserialize<object>();
- fieldHash = fieldVal != null ? fieldVal.GetHashCode() : 0;
- }
-
- hash = 31 * hash + fieldHash;
- }
-
- // Restore stream position.
- stream.Seek(pos, SeekOrigin.Begin);
-
- return hash;
- }
-
- /// <summary>
- /// Validates this instance.
- /// </summary>
- public void Validate()
- {
- if (FieldNames == null || FieldNames.Count == 0)
- throw new IgniteException("BinaryFieldEqualityComparer.FieldNames can not be null or empty.");
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs
index 6a911ad..e38b5ba 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryFullTypeDescriptor.cs
@@ -20,7 +20,6 @@ namespace Apache.Ignite.Core.Impl.Binary
using System;
using System.Collections.Generic;
using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Binary.Structure;
/// <summary>
@@ -67,9 +66,6 @@ namespace Apache.Ignite.Core.Impl.Binary
/** Enum flag. */
private readonly bool _isEnum;
- /** Comparer. */
- private readonly IBinaryEqualityComparer _equalityComparer;
-
/** Register flag. */
private readonly bool _isRegistered;
@@ -86,7 +82,6 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <param name="keepDeserialized">Whether to cache deserialized value in IBinaryObject</param>
/// <param name="affKeyFieldName">Affinity field key name.</param>
/// <param name="isEnum">Enum flag.</param>
- /// <param name="comparer">Equality comparer.</param>
/// <param name="isRegistered">Registered flag.</param>
public BinaryFullTypeDescriptor(
Type type,
@@ -99,7 +94,6 @@ namespace Apache.Ignite.Core.Impl.Binary
bool keepDeserialized,
string affKeyFieldName,
bool isEnum,
- IEqualityComparer<IBinaryObject> comparer,
bool isRegistered = true)
{
_type = type;
@@ -113,13 +107,6 @@ namespace Apache.Ignite.Core.Impl.Binary
_affKeyFieldName = affKeyFieldName;
_isEnum = isEnum;
- _equalityComparer = comparer as IBinaryEqualityComparer;
-
- if (comparer != null && _equalityComparer == null)
- throw new IgniteException(string.Format("Unsupported IEqualityComparer<IBinaryObject> " +
- "implementation: {0}. Only predefined implementations " +
- "are supported.", comparer.GetType()));
-
_isRegistered = isRegistered;
_schema = new BinaryObjectSchema();
}
@@ -145,7 +132,6 @@ namespace Apache.Ignite.Core.Impl.Binary
_keepDeserialized = desc._keepDeserialized;
_affKeyFieldName = desc._affKeyFieldName;
_isEnum = desc._isEnum;
- _equalityComparer = desc._equalityComparer;
_isRegistered = isRegistered;
_schema = desc._schema;
@@ -231,12 +217,6 @@ namespace Apache.Ignite.Core.Impl.Binary
get { return _isEnum; }
}
- /** <inheritdoc/> */
- public IBinaryEqualityComparer EqualityComparer
- {
- get { return _equalityComparer; }
- }
-
/** <inheritDoc /> */
public BinaryStructure WriterTypeStructure
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
index 21a5323..c8c904d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObject.cs
@@ -258,7 +258,7 @@ namespace Apache.Ignite.Core.Impl.Binary
var desc = _marsh.GetDescriptor(true, TypeId);
- return BinaryUtils.GetEqualityComparer(desc).Equals(this, that);
+ return BinaryArrayEqualityComparer.Equals(this, that);
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
index e4fb10a..41c7305 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -722,12 +722,9 @@ namespace Apache.Ignite.Core.Impl.Binary
if (changeHash)
{
// Get from identity resolver.
- var comparer = BinaryUtils.GetEqualityComparer(_desc);
-
- outHash = comparer.GetHashCode(outStream,
+ outHash = BinaryArrayEqualityComparer.GetHashCode(outStream,
outStartPos + BinaryObjectHeader.Size,
- schemaPos - outStartPos - BinaryObjectHeader.Size,
- outSchema, outSchemaId, _binary.Marshaller, _desc);
+ schemaPos - outStartPos - BinaryObjectHeader.Size);
}
var outHeader = new BinaryObjectHeader(inHeader.TypeId, outHash, outLen,
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
index 8c7e5e9..7efbe68 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySurrogateTypeDescriptor.cs
@@ -135,12 +135,6 @@ namespace Apache.Ignite.Core.Impl.Binary
get { return false; }
}
- /** <inheritdoc/> */
- public IBinaryEqualityComparer EqualityComparer
- {
- get { return null; }
- }
-
/** <inheritDoc /> */
public BinaryStructure WriterTypeStructure
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index bb58ea5..7a7b7f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -2010,16 +2010,6 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
- /// Gets the equality comparer.
- /// </summary>
- public static IBinaryEqualityComparer GetEqualityComparer(IBinaryTypeDescriptor descriptor)
- {
- var res = descriptor != null ? descriptor.EqualityComparer : null;
-
- return res ?? BinaryArrayEqualityComparer.Instance;
- }
-
- /// <summary>
/// Creates and instance from the type name in reader.
/// </summary>
private static T CreateInstance<T>(BinaryReader reader)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index 1388d16..12cc026 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1218,10 +1218,8 @@ namespace Apache.Ignite.Core.Impl.Binary
var len = _stream.Position - pos;
- var comparer = BinaryUtils.GetEqualityComparer(desc);
-
- var hashCode = comparer.GetHashCode(Stream, pos + BinaryObjectHeader.Size,
- dataEnd - pos - BinaryObjectHeader.Size, _schema, schemaIdx, _marsh, desc);
+ var hashCode = BinaryArrayEqualityComparer.GetHashCode(Stream, pos + BinaryObjectHeader.Size,
+ dataEnd - pos - BinaryObjectHeader.Size);
var header = new BinaryObjectHeader(desc.IsRegistered ? desc.TypeId : BinaryUtils.TypeUnregistered,
hashCode, len, schemaId, schemaOffset, flags);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs
deleted file mode 100644
index bd2db95..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryEqualityComparer.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Binary
-{
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl.Binary.IO;
-
- /// <summary>
- /// Internal comparer interface for <see cref="BinaryTypeConfiguration.EqualityComparer"/> implementations,
- /// provides more efficient API.
- /// </summary>
- internal interface IBinaryEqualityComparer
- {
- /// <summary>
- /// Returns a hash code for the binary object in specified stream at specified position.
- /// </summary>
- /// <param name="stream">Stream.</param>
- /// <param name="startPos">Data start position (right after the header).</param>
- /// <param name="length">Data length (without header and schema).</param>
- /// <param name="schema">Schema holder.</param>
- /// <param name="schemaId">Schema identifier.</param>
- /// <param name="marshaller">Marshaller.</param>
- /// <param name="desc">Type descriptor.</param>
- /// <returns>
- /// A hash code for the object in the stream.
- /// </returns>
- int GetHashCode(IBinaryStream stream, int startPos, int length, BinaryObjectSchemaHolder schema, int schemaId,
- Marshaller marshaller, IBinaryTypeDescriptor desc);
-
- /// <summary>
- /// Returns a hash code for this instance.
- /// </summary>
- /// <param name="obj">The object.</param>
- /// <returns>
- /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
- /// </returns>
- int GetHashCode(IBinaryObject obj);
-
-
- /// <summary>
- /// Returns a value indicating that two binary object are equal.
- /// </summary>
- /// <param name="x">First object.</param>
- /// <param name="y">Second object.</param>
- /// <returns>True when objects are equal; otherwise false.</returns>
- bool Equals(IBinaryObject x, IBinaryObject y);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs
index 6bec70f..4bd7e73 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IBinaryTypeDescriptor.cs
@@ -78,11 +78,6 @@ namespace Apache.Ignite.Core.Impl.Binary
bool IsEnum { get; }
/// <summary>
- /// Gets the equality comparer.
- /// </summary>
- IBinaryEqualityComparer EqualityComparer { get; }
-
- /// <summary>
/// Write type structure.
/// </summary>
BinaryStructure WriterTypeStructure { get; }
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 5a4460a..61439b1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -452,7 +452,7 @@ namespace Apache.Ignite.Core.Impl.Binary
if (meta != BinaryType.Empty)
{
desc = new BinaryFullTypeDescriptor(null, meta.TypeId, meta.TypeName, true, null, null, null, false,
- meta.AffinityKeyFieldName, meta.IsEnum, null);
+ meta.AffinityKeyFieldName, meta.IsEnum);
_idToDesc.GetOrAdd(typeKey, _ => desc);
@@ -480,14 +480,6 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
- /// Gets the user type descriptors.
- /// </summary>
- public ICollection<BinaryFullTypeDescriptor> GetUserTypeDescriptors()
- {
- return _typeNameToDesc.Values;
- }
-
- /// <summary>
/// Add user type.
/// </summary>
/// <param name="type">The type.</param>
@@ -506,7 +498,7 @@ namespace Apache.Ignite.Core.Impl.Binary
desc = desc == null
? new BinaryFullTypeDescriptor(type, typeId, typeName, true, _cfg.DefaultNameMapper,
- _cfg.DefaultIdMapper, ser, false, null, type.IsEnum, null, registered)
+ _cfg.DefaultIdMapper, ser, false, null, type.IsEnum, registered)
: new BinaryFullTypeDescriptor(desc, type, ser, registered);
if (RegistrationDisabled)
@@ -575,7 +567,7 @@ namespace Apache.Ignite.Core.Impl.Binary
var serializer = GetSerializer(cfg, typeCfg, type, typeId, nameMapper, idMapper, _log);
AddType(type, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, serializer,
- affKeyFld, type.IsEnum, typeCfg.EqualityComparer);
+ affKeyFld, type.IsEnum);
}
else
{
@@ -585,7 +577,7 @@ namespace Apache.Ignite.Core.Impl.Binary
int typeId = BinaryUtils.TypeId(typeName, nameMapper, idMapper);
AddType(null, typeId, typeName, true, keepDeserialized, nameMapper, idMapper, null,
- typeCfg.AffinityKeyFieldName, typeCfg.IsEnum, typeCfg.EqualityComparer);
+ typeCfg.AffinityKeyFieldName, typeCfg.IsEnum);
}
}
@@ -652,11 +644,9 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <param name="serializer">Serializer.</param>
/// <param name="affKeyFieldName">Affinity key field name.</param>
/// <param name="isEnum">Enum flag.</param>
- /// <param name="comparer">Comparer.</param>
private void AddType(Type type, int typeId, string typeName, bool userType,
bool keepDeserialized, IBinaryNameMapper nameMapper, IBinaryIdMapper idMapper,
- IBinarySerializerInternal serializer, string affKeyFieldName, bool isEnum,
- IEqualityComparer<IBinaryObject> comparer)
+ IBinarySerializerInternal serializer, string affKeyFieldName, bool isEnum)
{
long typeKey = BinaryUtils.TypeKey(userType, typeId);
@@ -677,7 +667,7 @@ namespace Apache.Ignite.Core.Impl.Binary
throw new BinaryObjectException("Conflicting type name: " + typeName);
var descriptor = new BinaryFullTypeDescriptor(type, typeId, typeName, userType, nameMapper, idMapper,
- serializer, keepDeserialized, affKeyFieldName, isEnum, comparer);
+ serializer, keepDeserialized, affKeyFieldName, isEnum);
if (type != null)
_typeToDesc.GetOrAdd(type, x => descriptor);
@@ -703,7 +693,7 @@ namespace Apache.Ignite.Core.Impl.Binary
typeId = BinaryUtils.TypeId(type.Name, null, null);
AddType(type, typeId, BinaryUtils.GetTypeName(type), false, false, null, null, serializer, affKeyFldName,
- false, null);
+ false);
}
/// <summary>
[3/3] ignite git commit: IGNITE-41919 - Removed identity resolvers
Posted by ag...@apache.org.
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");
[2/3] ignite git commit: IGNITE-41919 - Removed identity resolvers
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
index e8c4e75..c92c7dc 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheMergeSqlQuerySelfTest.java
@@ -123,44 +123,6 @@ public class IgniteCacheMergeSqlQuerySelfTest extends IgniteCacheAbstractInsertS
/**
*
*/
- 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(
- "merge 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(
- "merge 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 testNestedFieldsHandling() {
IgniteCache<Integer, AllTypes> p = ignite(0).cache("I2AT");
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/Makefile.am b/modules/platforms/cpp/binary/Makefile.am
index d310f33..d3c2072 100644
--- a/modules/platforms/cpp/binary/Makefile.am
+++ b/modules/platforms/cpp/binary/Makefile.am
@@ -52,7 +52,6 @@ libignite_binary_la_SOURCES = \
src/binary/binary_reader.cpp \
src/binary/binary_type.cpp \
src/binary/binary_raw_reader.cpp \
- src/binary/binary_array_identity_resolver.cpp \
src/impl/binary/binary_type_manager.cpp \
src/impl/binary/binary_utils.cpp \
src/impl/binary/binary_reader_impl.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/Makefile.am b/modules/platforms/cpp/binary/include/Makefile.am
index 9c51326..a73d5de 100644
--- a/modules/platforms/cpp/binary/include/Makefile.am
+++ b/modules/platforms/cpp/binary/include/Makefile.am
@@ -27,8 +27,6 @@ nobase_include_HEADERS = \
ignite/binary/binary_consts.h \
ignite/binary/binary_type.h \
ignite/binary/binary_object.h \
- ignite/binary/binary_identity_resolver.h \
- ignite/binary/binary_array_identity_resolver.h \
ignite/impl/binary/binary_type_handler.h \
ignite/impl/binary/binary_id_resolver.h \
ignite/impl/binary/binary_type_manager.h \
@@ -42,7 +40,6 @@ nobase_include_HEADERS = \
ignite/impl/binary/binary_utils.h \
ignite/impl/binary/binary_object_header.h \
ignite/impl/binary/binary_object_impl.h \
- ignite/impl/binary/binary_type_impl.h \
ignite/impl/interop/interop_memory.h \
ignite/impl/interop/interop.h \
ignite/impl/interop/interop_stream_position_guard.h \
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/include/ignite/binary/binary_array_identity_resolver.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_array_identity_resolver.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_array_identity_resolver.h
deleted file mode 100644
index 70c5ed4..0000000
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_array_identity_resolver.h
+++ /dev/null
@@ -1,64 +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.
- */
-
-/**
- * @file
- * Declares ignite::binary::BinaryArrayIdentityResolver class template.
- */
-
-#ifndef _IGNITE_BINARY_BINARY_ARRAY_IDENTITY_RESOLVER
-#define _IGNITE_BINARY_BINARY_ARRAY_IDENTITY_RESOLVER
-
-#include <stdint.h>
-
-#include <ignite/common/common.h>
-#include <ignite/binary/binary_identity_resolver.h>
-
-namespace ignite
-{
- namespace binary
- {
- class BinaryObject;
-
- /**
- * Binary array identity resolver.
- */
- class IGNITE_IMPORT_EXPORT BinaryArrayIdentityResolver : public BinaryIdentityResolver
- {
- public:
- /**
- * Default constructor.
- */
- BinaryArrayIdentityResolver();
-
- /**
- * Destructor.
- */
- virtual ~BinaryArrayIdentityResolver();
-
- /**
- * Get binary object hash code.
- *
- * @param obj Binary object.
- * @return Hash code.
- */
- virtual int32_t GetHashCode(const BinaryObject& obj);
- };
- }
-}
-
-#endif //_IGNITE_BINARY_BINARY_ARRAY_IDENTITY_RESOLVER
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/include/ignite/binary/binary_identity_resolver.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_identity_resolver.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_identity_resolver.h
deleted file mode 100644
index ce10012..0000000
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_identity_resolver.h
+++ /dev/null
@@ -1,61 +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.
- */
-
-/**
- * @file
- * Declares ignite::binary::BinaryIdentityResolver class.
- */
-
-#ifndef _IGNITE_BINARY_BINARY_IDENTITY_RESOLVER
-#define _IGNITE_BINARY_BINARY_IDENTITY_RESOLVER
-
-#include <stdint.h>
-
-#include <ignite/common/common.h>
-
-#include <ignite/binary/binary_object.h>
-
-namespace ignite
-{
- namespace binary
- {
- /**
- * Binary identity resolver.
- */
- class IGNITE_IMPORT_EXPORT BinaryIdentityResolver
- {
- public:
- /**
- * Destructor.
- */
- virtual ~BinaryIdentityResolver()
- {
- // No-op.
- }
-
- /**
- * Get binary object hash code.
- *
- * @param obj Binary object.
- * @return Hash code.
- */
- virtual int32_t GetHashCode(const BinaryObject& obj) = 0;
- };
- }
-}
-
-#endif //_IGNITE_BINARY_BINARY_IDENTITY_RESOLVER
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h
index ff4bd10..4edbe84 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_object.h
@@ -29,10 +29,16 @@
namespace ignite
{
- namespace binary
+ namespace impl
{
- class BinaryArrayIdentityResolver;
+ namespace binary
+ {
+ class BinaryWriterImpl;
+ }
+ }
+ namespace binary
+ {
/**
* Binary object.
*
@@ -41,7 +47,7 @@ namespace ignite
*/
class IGNITE_IMPORT_EXPORT BinaryObject
{
- friend class BinaryArrayIdentityResolver;
+ friend class ignite::impl::binary::BinaryWriterImpl;
public:
/// @cond INTERNAL
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
index f65c652..6657313 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
@@ -87,16 +87,6 @@ int32_t GetFieldId(const char* name) \
}
/**
- * @def IGNITE_BINARY_GET_HASH_CODE_ZERO(T)
- * Implementation of GetHashCode() function which always returns 0.
- */
-#define IGNITE_BINARY_GET_HASH_CODE_ZERO(T) \
-int32_t GetHashCode(const T& obj) \
-{ \
- return 0; \
-}
-
-/**
* @def IGNITE_BINARY_IS_NULL_FALSE(T)
* Implementation of IsNull() function which always returns false.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
deleted file mode 100644
index 08c60c0..0000000
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
+++ /dev/null
@@ -1,149 +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.
- */
-
-#ifndef _IGNITE_IMPL_BINARY_BINARY_TYPE_IMP
-#define _IGNITE_IMPL_BINARY_BINARY_TYPE_IMP
-
-#include <stdint.h>
-
-#include <ignite/common/utils.h>
-
-#include <ignite/binary/binary_type.h>
-#include <ignite/binary/binary_object.h>
-#include <ignite/binary/binary_array_identity_resolver.h>
-
-#include <ignite/reference.h>
-
-/**
- * Some SFINAE magic to check existence of the specified method with the
- * specified signature in the BinaryType<T> class.
- *
- * This macro declares checker for the method.
- */
-#define IGNITE_DECLARE_BINARY_TYPE_METHOD_CHECKER(method, sign) \
- template<typename T> \
- class IsDeclaredBinaryType##method \
- { \
- typedef char one; \
- typedef char two[2]; \
- \
- template<class U, U> struct test; \
- \
- template<typename C> static one& helper(test<sign, &C::method>*); \
- template<typename C> static two& helper(...); \
- \
- public: \
- const static bool value = \
- (sizeof(helper< ignite::binary::BinaryType<T> >(0)) == sizeof(one)); \
- }
-
-namespace ignite
-{
- namespace impl
- {
- namespace binary
- {
- IGNITE_DECLARE_BINARY_TYPE_METHOD_CHECKER(GetHashCode, int32_t(ignite::binary::BinaryType<T>::*)(const T&));
- IGNITE_DECLARE_BINARY_TYPE_METHOD_CHECKER(GetIdentityResolver,
- ignite::Reference<ignite::binary::BinaryIdentityResolver>(ignite::binary::BinaryType<T>::*)());
-
- /**
- * This type is used to get hash code for binary types which have not
- * GetHashCode nor GetIdentityResolver methods defined.
- */
- template<typename T>
- struct HashCodeGetterDefault
- {
- static int32_t Get(const T&, const ignite::binary::BinaryObject& obj)
- {
- ignite::binary::BinaryArrayIdentityResolver arrayResolver;
-
- return arrayResolver.GetHashCode(obj);
- }
- };
-
- /**
- * This type is used to get hash code for binary types which have not
- * GetIdentityResolver method defined but have GetHashCode.
- */
- template<typename T>
- struct HashCodeGetterHashCode
- {
- static int32_t Get(const T& obj, const ignite::binary::BinaryObject&)
- {
- ignite::binary::BinaryType<T> bt;
-
- return bt.GetHashCode(obj);
- }
- };
-
- /**
- * This type is used to get hash code for binary types which have
- * GetIdentityResolver method defined.
- */
- template<typename T>
- struct HashCodeGetterResolver
- {
- static int32_t Get(const T&, const ignite::binary::BinaryObject& obj)
- {
- ignite::binary::BinaryType<T> bt;
- ignite::Reference<ignite::binary::BinaryIdentityResolver> resolver = bt.GetIdentityResolver();
-
- return resolver.Get()->GetHashCode(obj);
- }
- };
-
- /**
- * Get hash code for the specified object.
- * Determines the best method to use based on user-defined methods.
- *
- * @param obj Object reference.
- * @param binObj Binary representation reference.
- * @return Hash code for the object.
- */
- template<typename T>
- int32_t GetHashCode(const T& obj, const ignite::binary::BinaryObject& binObj)
- {
- using namespace common;
-
- typedef typename Conditional<
- // Checking if the BinaryType<T>::GetIdentityResolver declared
- IsDeclaredBinaryTypeGetIdentityResolver<T>::value,
-
- // True case. Using user-provided resolver.
- HashCodeGetterResolver<T>,
-
- // False case. Adding condition.
- typename Conditional<
- // Checking if the BinaryType<T>::GetHashCode declared
- IsDeclaredBinaryTypeGetHashCode<T>::value,
-
- // True case - using BinaryType<T>::GetHashCode().
- HashCodeGetterHashCode<T>,
-
- // False case. Using default getter.
- HashCodeGetterDefault<T>
- >::type
- >::type HashCodeGetter;
-
- return HashCodeGetter::Get(obj, binObj);
- }
- }
- }
-}
-
-#endif //_IGNITE_IMPL_BINARY_BINARY_TYPE_IMP
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
index 50b2375..5670193 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
@@ -31,7 +31,6 @@
#include "ignite/impl/binary/binary_type_manager.h"
#include "ignite/impl/binary/binary_utils.h"
#include "ignite/impl/binary/binary_schema.h"
-#include "ignite/impl/binary/binary_type_impl.h"
#include "ignite/impl/binary/binary_type_manager.h"
#include "ignite/binary/binary_consts.h"
#include "ignite/binary/binary_type.h"
@@ -721,7 +720,9 @@ namespace ignite
// at this point that underlying memory contains valid binary object.
ignite::binary::BinaryObject binObj(*stream->GetMemory(), pos, &idRslvr, metaMgr);
- stream->WriteInt32(hashPos, impl::binary::GetHashCode<T>(obj, binObj));
+ int32_t hash = BinaryUtils::GetDataHashCode(binObj.impl.GetData(), binObj.impl.GetLength());
+
+ stream->WriteInt32(hashPos, hash);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/project/vs/binary.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/project/vs/binary.vcxproj b/modules/platforms/cpp/binary/project/vs/binary.vcxproj
index 5a01465..21f1248 100644
--- a/modules/platforms/cpp/binary/project/vs/binary.vcxproj
+++ b/modules/platforms/cpp/binary/project/vs/binary.vcxproj
@@ -181,8 +181,6 @@
<ClInclude Include="..\..\include\ignite\binary\binary_consts.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_containers.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_object.h" />
- <ClInclude Include="..\..\include\ignite\binary\binary_identity_resolver.h" />
- <ClInclude Include="..\..\include\ignite\binary\binary_array_identity_resolver.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_raw_reader.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_raw_writer.h" />
<ClInclude Include="..\..\include\ignite\binary\binary_reader.h" />
@@ -196,7 +194,6 @@
<ClInclude Include="..\..\include\ignite\impl\binary\binary_reader_impl.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_schema.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_type_handler.h" />
- <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_impl.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_type_manager.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_type_snapshot.h" />
<ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater.h" />
@@ -209,7 +206,6 @@
<ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h" />
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\src\binary\binary_array_identity_resolver.cpp" />
<ClCompile Include="..\..\src\binary\binary_containers.cpp" />
<ClCompile Include="..\..\src\binary\binary_raw_reader.cpp" />
<ClCompile Include="..\..\src\binary\binary_raw_writer.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters b/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
index 05a21aa..27e4ad8 100644
--- a/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
+++ b/modules/platforms/cpp/binary/project/vs/binary.vcxproj.filters
@@ -97,15 +97,6 @@
<ClInclude Include="..\..\include\ignite\impl\binary\binary_object_impl.h">
<Filter>Code\impl\binary</Filter>
</ClInclude>
- <ClInclude Include="..\..\include\ignite\binary\binary_array_identity_resolver.h">
- <Filter>Code\binary</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\binary\binary_identity_resolver.h">
- <Filter>Code\binary</Filter>
- </ClInclude>
- <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_impl.h">
- <Filter>Code\impl\binary</Filter>
- </ClInclude>
<ClInclude Include="..\..\include\ignite\impl\binary\binary_field_meta.h">
<Filter>Code\impl\binary</Filter>
</ClInclude>
@@ -165,9 +156,6 @@
<ClCompile Include="..\..\src\impl\binary\binary_object_impl.cpp">
<Filter>Code\impl\binary</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\binary\binary_array_identity_resolver.cpp">
- <Filter>Code\binary</Filter>
- </ClCompile>
<ClCompile Include="..\..\src\impl\binary\binary_field_meta.cpp">
<Filter>Code\impl\binary</Filter>
</ClCompile>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/binary/src/binary/binary_array_identity_resolver.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_array_identity_resolver.cpp b/modules/platforms/cpp/binary/src/binary/binary_array_identity_resolver.cpp
deleted file mode 100644
index 6338842..0000000
--- a/modules/platforms/cpp/binary/src/binary/binary_array_identity_resolver.cpp
+++ /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.
- */
-
-#include <ignite/binary/binary_object.h>
-#include <ignite/impl/binary/binary_utils.h>
-
-#include <ignite/binary/binary_array_identity_resolver.h>
-
-namespace ignite
-{
- namespace binary
- {
- BinaryArrayIdentityResolver::BinaryArrayIdentityResolver()
- {
- // No-op.
- }
-
- BinaryArrayIdentityResolver::~BinaryArrayIdentityResolver()
- {
- // No-op.
- }
-
- int32_t BinaryArrayIdentityResolver::GetHashCode(const BinaryObject& obj)
- {
- return impl::binary::BinaryUtils::GetDataHashCode(obj.impl.GetData(), obj.impl.GetLength());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
index 196c6d3..07e8a14 100644
--- a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
+++ b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
@@ -156,11 +156,6 @@ namespace ignite
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryInner& obj)
- {
- return obj.GetValue();
- }
-
bool IsNull(const gt::BinaryInner& obj)
{
return obj.GetValue() == 0;
@@ -200,11 +195,6 @@ namespace ignite
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryInner& obj)
- {
- return obj.GetValue();
- }
-
bool IsNull(const gt::BinaryInner& obj)
{
return obj.GetValue() == 0;
@@ -246,11 +236,6 @@ namespace ignite
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryOuter& obj)
- {
- return obj.GetValue() + obj.GetInner().GetValue();
- }
-
bool IsNull(const gt::BinaryOuter& obj)
{
return obj.GetValue() == 0 && obj.GetInner().GetValue();
@@ -294,11 +279,6 @@ namespace ignite
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryFields& obj)
- {
- return obj.val1 + obj.val2 + obj.rawVal1 + obj.rawVal2;
- }
-
bool IsNull(const gt::BinaryFields& obj)
{
return false;
@@ -352,11 +332,6 @@ namespace ignite
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::PureRaw& obj)
- {
- return GetBinaryStringHashCode(obj.val1.c_str()) ^ obj.val2;
- }
-
bool IsNull(const gt::PureRaw& obj)
{
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/include/ignite/complex_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/complex_type.h b/modules/platforms/cpp/core-test/include/ignite/complex_type.h
index cb4a8a1..1a97c7b 100644
--- a/modules/platforms/cpp/core-test/include/ignite/complex_type.h
+++ b/modules/platforms/cpp/core-test/include/ignite/complex_type.h
@@ -77,7 +77,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(InnerObject)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(InnerObject)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(InnerObject)
IGNITE_BINARY_IS_NULL_FALSE(InnerObject)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(InnerObject)
@@ -106,7 +105,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ComplexType)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ComplexType)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(ComplexType)
IGNITE_BINARY_IS_NULL_FALSE(ComplexType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/include/ignite/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/test_type.h b/modules/platforms/cpp/core-test/include/ignite/test_type.h
index d1dd967..d66c668 100644
--- a/modules/platforms/cpp/core-test/include/ignite/test_type.h
+++ b/modules/platforms/cpp/core-test/include/ignite/test_type.h
@@ -107,7 +107,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestType)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestType)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(TestType)
IGNITE_BINARY_IS_NULL_FALSE(TestType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestType)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp b/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
index 55b77bd..b6831c3 100644
--- a/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
@@ -30,7 +30,6 @@
#include "ignite/cache/query/query_sql_fields.h"
#include "ignite/ignite.h"
#include "ignite/ignition.h"
-#include "ignite/binary/binary_array_identity_resolver.h"
#include "ignite/test_utils.h"
#include "ignite/complex_type.h"
@@ -134,56 +133,6 @@ struct TestUserClassBase
};
struct DefaultHashing : TestUserClassBase {};
-struct GetHashDefined : TestUserClassBase {};
-struct ResolverDefined : TestUserClassBase {};
-struct BothDefined : TestUserClassBase {};
-
-struct ComplexType2 : ComplexType { };
-
-struct CustomIdResolver : binary::BinaryIdentityResolver
-{
- int32_t GetHashCode(const BinaryObject& obj)
- {
- int32_t field;
- try
- {
- ResolverDefined res = obj.Deserialize<ResolverDefined>();
-
- field = res.field;
- }
- catch (const IgniteError&)
- {
- BothDefined res = obj.Deserialize<BothDefined>();
-
- field = res.field;
- }
-
- return field * 42;
- }
-};
-
-struct CustomFieldIdResolver : binary::BinaryIdentityResolver
-{
- static int32_t lastHash;
-
- int32_t GetHashCode(const BinaryObject& obj)
- {
- int32_t hash = 0;
-
- if (obj.HasField("objField"))
- {
- BinaryObject inner = obj.GetField<BinaryObject>("objField");
-
- hash = inner.GetField<int32_t>("f1");
- }
-
- lastHash = hash;
-
- return hash;
- }
-};
-
-int32_t CustomFieldIdResolver::lastHash = 0;
namespace ignite
{
@@ -213,99 +162,6 @@ namespace ignite
}
};
- template<>
- struct BinaryType<GetHashDefined>
- {
- IGNITE_BINARY_GET_TYPE_ID_AS_HASH(GetHashDefined)
- IGNITE_BINARY_GET_TYPE_NAME_AS_IS(GetHashDefined)
- IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_IS_NULL_FALSE(GetHashDefined)
- IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(GetHashDefined)
-
- int32_t GetHashCode(const GetHashDefined& obj)
- {
- return obj.field * 10;
- }
-
- void Write(BinaryWriter& writer, const GetHashDefined& obj)
- {
- writer.WriteInt32("field", obj.field);
- }
-
- GetHashDefined Read(BinaryReader& reader)
- {
- GetHashDefined val;
-
- val.field = reader.ReadInt32("field");
-
- return val;
- }
- };
-
- template<>
- struct BinaryType<ResolverDefined>
- {
- IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ResolverDefined)
- IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ResolverDefined)
- IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_IS_NULL_FALSE(ResolverDefined)
- IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ResolverDefined)
-
- ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
- {
- return ignite::MakeReferenceFromCopy(CustomIdResolver());
- }
-
- void Write(BinaryWriter& writer, const ResolverDefined& obj)
- {
- writer.WriteInt32("field", obj.field);
- }
-
- ResolverDefined Read(BinaryReader& reader)
- {
- ResolverDefined val;
-
- val.field = reader.ReadInt32("field");
-
- return val;
- }
- };
-
- template<>
- struct BinaryType<BothDefined>
- {
- IGNITE_BINARY_GET_TYPE_ID_AS_HASH(BothDefined)
- IGNITE_BINARY_GET_TYPE_NAME_AS_IS(BothDefined)
- IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_IS_NULL_FALSE(BothDefined)
- IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(BothDefined)
-
- int32_t GetHashCode(const GetHashDefined& obj)
- {
- return obj.field * 10;
- }
-
- ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
- {
- return ignite::MakeReferenceFromCopy(CustomIdResolver());
- }
-
- void Write(BinaryWriter& writer, const BothDefined& obj)
- {
- writer.WriteInt32("field", obj.field);
- }
-
- BothDefined Read(BinaryReader& reader)
- {
- BothDefined val;
-
- val.field = reader.ReadInt32("field");
-
- return val;
- }
- };
-
-
/**
* Binary type definition for CompositeKey.
*/
@@ -367,42 +223,6 @@ namespace ignite
return val;
}
};
-
- /**
- * Binary type definition for ComplexType2.
- */
- template<>
- struct BinaryType<ComplexType2>
- {
- IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ComplexType2)
- IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ComplexType2)
- IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_IS_NULL_FALSE(ComplexType2)
- IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType2)
-
- ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
- {
- return ignite::MakeReferenceFromCopy(CustomFieldIdResolver());
- }
-
- void Write(BinaryWriter& writer, ComplexType2 obj)
- {
- writer.WriteInt32("i32Field", obj.i32Field);
- writer.WriteObject("objField", obj.objField);
- writer.WriteString("strField", obj.strField);
- }
-
- ComplexType2 Read(BinaryReader& reader)
- {
- ComplexType2 obj;
-
- obj.i32Field = reader.ReadInt32("i32Field");
- obj.objField = reader.ReadObject<InnerObject>("objField");
- obj.strField = reader.ReadString("strField");
-
- return obj;
- }
- };
}
}
@@ -439,20 +259,6 @@ void FillMem(InteropMemory& mem, const T& value)
stream.Synchronize();
}
-template<typename R, typename T>
-int32_t CalculateHashCode(const T& value)
-{
- InteropUnpooledMemory mem(1024);
-
- FillMem<T>(mem, value);
-
- BinaryObject obj(mem, 0, 0, 0);
-
- R resolver;
-
- return resolver.GetHashCode(obj);
-}
-
template<typename T>
int32_t RetrieveHashCode(const T& value)
{
@@ -490,19 +296,6 @@ BOOST_AUTO_TEST_CASE(GetDataHashCode)
BOOST_CHECK_EQUAL(BinaryUtils::GetDataHashCode(data9, sizeof(data9)), 0x000D9F41);
}
-BOOST_AUTO_TEST_CASE(ArrayIdentityResolver)
-{
- using namespace binary;
-
- CompositeKey key1("Some test garbage, one-two-three...",
- Timestamp(109917, 130347199), Guid(0xACC064DF54EE9670, 0x065CF938F56E5E3B));
-
- CompositeKeySimple key2("!!!!!!!!!!!!!!!!", Timestamp(324140, 334685375), 89563963);
-
- BOOST_CHECK_EQUAL(CalculateHashCode<BinaryArrayIdentityResolver>(key1), 0xC298792B);
- BOOST_CHECK_EQUAL(CalculateHashCode<BinaryArrayIdentityResolver>(key2), 0x53207175);
-}
-
BOOST_AUTO_TEST_CASE(IdentityEquilityWithGuid)
{
Ignite grid = ignite_test::StartNode("cache-identity.xml");
@@ -557,51 +350,4 @@ BOOST_AUTO_TEST_CASE(TestDefaultHashing)
BOOST_CHECK_EQUAL(RetrieveHashCode(val), 0x01F91B0E);
}
-BOOST_AUTO_TEST_CASE(TestGetHashDefined)
-{
- GetHashDefined val;
- val.field = 1337;
-
- BOOST_CHECK_EQUAL(RetrieveHashCode(val), val.field * 10);
-}
-
-BOOST_AUTO_TEST_CASE(TestResolverDefined)
-{
- ResolverDefined val;
- val.field = 1337;
-
- BOOST_CHECK_EQUAL(RetrieveHashCode(val), val.field * 42);
-}
-
-BOOST_AUTO_TEST_CASE(TestBothDefined)
-{
- BothDefined val;
- val.field = 1337;
-
- BOOST_CHECK_EQUAL(RetrieveHashCode(val), val.field * 42);
-}
-
-BOOST_AUTO_TEST_CASE(ComplexTypeWithFieldsIdentityResolver)
-{
- BOOST_CHECKPOINT("Node startup");
- Ignite node = ignite_test::StartNode("cache-identity.xml");
-
- ComplexType2 key;
-
- key.strField = "ComplexType2";
- key.i32Field = 58943095;
- key.objField.f1 = 812;
- key.objField.f2 = "InnerType";
-
- int32_t value = -12345890;
-
- BOOST_CHECKPOINT("Cache creation");
- Cache<ComplexType2, int32_t> cache = node.GetOrCreateCache<ComplexType2, int32_t>("cache3");
-
- BOOST_CHECKPOINT("Value Put");
- cache.Put(key, value);
-
- BOOST_CHECK_EQUAL(key.objField.f1, CustomFieldIdResolver::lastHash);
-}
-
BOOST_AUTO_TEST_SUITE_END()
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp b/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
index 4f1f30a..f094d1c 100644
--- a/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
@@ -129,7 +129,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(CacheEntryModifier)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(CacheEntryModifier)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(CacheEntryModifier)
IGNITE_BINARY_IS_NULL_FALSE(CacheEntryModifier)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(CacheEntryModifier)
@@ -240,7 +239,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Divisor)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Divisor)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(Divisor)
IGNITE_BINARY_IS_NULL_FALSE(Divisor)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Divisor)
@@ -361,7 +359,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(CharRemover)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(CharRemover)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(CharRemover)
IGNITE_BINARY_IS_NULL_FALSE(CharRemover)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(CharRemover)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index bfd45d1..2c4d3b5 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -245,7 +245,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(QueryPerson)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(QueryPerson)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(QueryPerson)
IGNITE_BINARY_IS_NULL_FALSE(QueryPerson)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(QueryPerson)
@@ -275,7 +274,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(QueryRelation)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(QueryRelation)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(QueryRelation)
IGNITE_BINARY_IS_NULL_FALSE(QueryRelation)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(QueryRelation)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_test.cpp b/modules/platforms/cpp/core-test/src/cache_test.cpp
index a9ee47e..d269f65 100644
--- a/modules/platforms/cpp/core-test/src/cache_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_test.cpp
@@ -53,7 +53,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Person)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Person)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(Person)
IGNITE_BINARY_IS_NULL_FALSE(Person)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Person)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/continuous_query_test.cpp b/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
index c52baaf..46ffc2f 100644
--- a/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
@@ -265,7 +265,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestEntry)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestEntry)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(TestEntry)
IGNITE_BINARY_IS_NULL_FALSE(TestEntry)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestEntry)
@@ -298,11 +297,6 @@ namespace ignite
}
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- int32_t GetHashCode(const RangeFilter<K,V>&)
- {
- return 0;
- }
-
bool IsNull(const RangeFilter<K,V>&)
{
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/odbc-test/include/complex_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/complex_type.h b/modules/platforms/cpp/odbc-test/include/complex_type.h
index a84b033..99b18ca 100644
--- a/modules/platforms/cpp/odbc-test/include/complex_type.h
+++ b/modules/platforms/cpp/odbc-test/include/complex_type.h
@@ -64,7 +64,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestObject)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestObject)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(TestObject)
IGNITE_BINARY_IS_NULL_FALSE(TestObject)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestObject)
@@ -93,7 +92,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ComplexType)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ComplexType)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(ComplexType)
IGNITE_BINARY_IS_NULL_FALSE(ComplexType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/cpp/odbc-test/include/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/test_type.h b/modules/platforms/cpp/odbc-test/include/test_type.h
index 51271b5..7728338 100644
--- a/modules/platforms/cpp/odbc-test/include/test_type.h
+++ b/modules/platforms/cpp/odbc-test/include/test_type.h
@@ -107,7 +107,6 @@ namespace ignite
IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestType)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestType)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(TestType)
IGNITE_BINARY_IS_NULL_FALSE(TestType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestType)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryEqualityComparerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryEqualityComparerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryEqualityComparerTest.cs
index 7c6d769..4dc4d93 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryEqualityComparerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryEqualityComparerTest.cs
@@ -17,10 +17,7 @@
namespace Apache.Ignite.Core.Tests.Binary
{
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Binary.IO;
using NUnit.Framework;
@@ -31,87 +28,46 @@ namespace Apache.Ignite.Core.Tests.Binary
public class BinaryEqualityComparerTest
{
/// <summary>
- /// Tests common public methods logic.
+ /// Tests simple equality.
/// </summary>
[Test]
- [SuppressMessage("ReSharper", "ReturnValueOfPureMethodIsNotUsed")]
- public void TestPublicMethods()
+ public void TestSimpleEquality()
{
- var cmps = new IEqualityComparer<IBinaryObject>[]
- {
- new BinaryArrayEqualityComparer()
- //new BinaryFieldEqualityComparer()
- };
-
var obj = GetBinaryObject(1, "x", 0);
- foreach (var cmp in cmps)
- {
- Assert.IsTrue(cmp.Equals(null, null));
- Assert.IsTrue(cmp.Equals(obj, obj));
-
- Assert.IsFalse(cmp.Equals(obj, null));
- Assert.IsFalse(cmp.Equals(null, obj));
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(null, null));
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(obj, obj));
- Assert.AreEqual(0, cmp.GetHashCode(null));
- Assert.AreNotEqual(0, cmp.GetHashCode(obj));
- }
- }
-
- /// <summary>
- /// Tests the custom comparer.
- /// </summary>
- [Test]
- public void TestCustomComparer()
- {
- var ex = Assert.Throws<IgniteException>(() => Ignition.Start(
- new IgniteConfiguration(TestUtils.GetTestConfiguration())
- {
- BinaryConfiguration = new BinaryConfiguration
- {
- TypeConfigurations = new[]
- {
- new BinaryTypeConfiguration(typeof(Foo))
- {
- EqualityComparer = new MyComparer()
- }
- }
- }
- }));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj, null));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(null, obj));
- Assert.IsNotNull(ex.InnerException);
- Assert.AreEqual("Unsupported IEqualityComparer<IBinaryObject> implementation: " +
- "Apache.Ignite.Core.Tests.Binary.BinaryEqualityComparerTest+MyComparer. " +
- "Only predefined implementations are supported.", ex.InnerException.Message);
+ Assert.AreEqual(0, BinaryArrayEqualityComparer.GetHashCode(null));
+ Assert.AreNotEqual(0, BinaryArrayEqualityComparer.GetHashCode(obj));
}
/// <summary>
- /// Tests the array comparer.
+ /// Tests hash code on a stream.
/// </summary>
[Test]
- public void TestArrayComparer()
+ public void TestStreamHashCode()
{
- var cmp = (IBinaryEqualityComparer) new BinaryArrayEqualityComparer();
-
var ms = new BinaryHeapStream(10);
- Assert.AreEqual(1, cmp.GetHashCode(ms, 0, 0, null, 0, null, null));
+ Assert.AreEqual(1, BinaryArrayEqualityComparer.GetHashCode(ms, 0, 0));
ms.WriteByte(1);
- Assert.AreEqual(31 + 1, cmp.GetHashCode(ms, 0, 1, null, 0, null, null));
+ Assert.AreEqual(31 + 1, BinaryArrayEqualityComparer.GetHashCode(ms, 0, 1));
ms.WriteByte(3);
- Assert.AreEqual((31 + 1) * 31 + 3, cmp.GetHashCode(ms, 0, 2, null, 0, null, null));
+ Assert.AreEqual((31 + 1) * 31 + 3, BinaryArrayEqualityComparer.GetHashCode(ms, 0, 2));
}
/// <summary>
- /// Tests public methods of array comparer.
+ /// Tests binary objects comparisons.
/// </summary>
[Test]
- public void TestArrayComparerPublic()
+ public void TestBinaryObjects()
{
- var cmp = new BinaryArrayEqualityComparer();
-
var obj1 = GetBinaryObject(1, "foo", 11);
var obj2 = GetBinaryObject(1, "bar", 11);
var obj3 = GetBinaryObject(2, "foo", 11);
@@ -120,30 +76,30 @@ namespace Apache.Ignite.Core.Tests.Binary
var obj6 = GetBinaryObject(1, "foo", 12);
// Equals.
- Assert.IsTrue(cmp.Equals(obj1, obj1));
- Assert.IsTrue(cmp.Equals(obj1, obj5));
- Assert.IsFalse(cmp.Equals(obj1, obj2));
- Assert.IsFalse(cmp.Equals(obj1, obj3));
- Assert.IsFalse(cmp.Equals(obj1, obj4));
- Assert.IsFalse(cmp.Equals(obj1, obj6));
-
- Assert.IsTrue(cmp.Equals(obj2, obj2));
- Assert.IsFalse(cmp.Equals(obj2, obj5));
- Assert.IsFalse(cmp.Equals(obj2, obj3));
- Assert.IsFalse(cmp.Equals(obj2, obj4));
- Assert.IsFalse(cmp.Equals(obj2, obj6));
-
- Assert.IsTrue(cmp.Equals(obj3, obj3));
- Assert.IsFalse(cmp.Equals(obj3, obj5));
- Assert.IsFalse(cmp.Equals(obj3, obj4));
- Assert.IsFalse(cmp.Equals(obj3, obj6));
-
- Assert.IsTrue(cmp.Equals(obj4, obj4));
- Assert.IsFalse(cmp.Equals(obj4, obj5));
- Assert.IsFalse(cmp.Equals(obj4, obj6));
-
- Assert.IsTrue(cmp.Equals(obj5, obj5));
- Assert.IsFalse(cmp.Equals(obj5, obj6));
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(obj1, obj1));
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(obj1, obj5));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj1, obj2));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj1, obj3));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj1, obj4));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj1, obj6));
+
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(obj2, obj2));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj2, obj5));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj2, obj3));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj2, obj4));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj2, obj6));
+
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(obj3, obj3));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj3, obj5));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj3, obj4));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj3, obj6));
+
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(obj4, obj4));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj4, obj5));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj4, obj6));
+
+ Assert.IsTrue(BinaryArrayEqualityComparer.Equals(obj5, obj5));
+ Assert.IsFalse(BinaryArrayEqualityComparer.Equals(obj5, obj6));
// BinaryObject.GetHashCode.
Assert.AreEqual(1934949494, obj1.GetHashCode());
@@ -151,75 +107,21 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(1424415317, obj3.GetHashCode());
Assert.AreEqual(1771330338, obj4.GetHashCode());
Assert.AreEqual(obj1.GetHashCode(), obj5.GetHashCode());
- Assert.AreEqual(1934979285, cmp.GetHashCode(obj6));
+ Assert.AreEqual(1934979285, BinaryArrayEqualityComparer.GetHashCode(obj6));
// Comparer.GetHashCode.
- Assert.AreEqual(2001751043, cmp.GetHashCode(GetBinaryObject(0, null, 0)));
- Assert.AreEqual(194296580, cmp.GetHashCode(GetBinaryObject(1, null, 0)));
- Assert.AreEqual(1934949494, cmp.GetHashCode(obj1));
- Assert.AreEqual(-2013102781, cmp.GetHashCode(obj2));
- Assert.AreEqual(1424415317, cmp.GetHashCode(obj3));
- Assert.AreEqual(1771330338, cmp.GetHashCode(obj4));
- Assert.AreEqual(cmp.GetHashCode(obj1), cmp.GetHashCode(obj5));
- Assert.AreEqual(1934979285, cmp.GetHashCode(obj6));
+ Assert.AreEqual(2001751043, BinaryArrayEqualityComparer.GetHashCode(GetBinaryObject(0, null, 0)));
+ Assert.AreEqual(194296580, BinaryArrayEqualityComparer.GetHashCode(GetBinaryObject(1, null, 0)));
+ Assert.AreEqual(1934949494, BinaryArrayEqualityComparer.GetHashCode(obj1));
+ Assert.AreEqual(-2013102781, BinaryArrayEqualityComparer.GetHashCode(obj2));
+ Assert.AreEqual(1424415317, BinaryArrayEqualityComparer.GetHashCode(obj3));
+ Assert.AreEqual(1771330338, BinaryArrayEqualityComparer.GetHashCode(obj4));
+ Assert.AreEqual(BinaryArrayEqualityComparer.GetHashCode(obj1), BinaryArrayEqualityComparer.GetHashCode(obj5));
+ Assert.AreEqual(1934979285, BinaryArrayEqualityComparer.GetHashCode(obj6));
// GetHashCode consistency.
foreach (var obj in new[] {obj1, obj2, obj3, obj4, obj5, obj6})
- Assert.AreEqual(obj.GetHashCode(), cmp.GetHashCode(obj));
- }
-
- /// <summary>
- /// Tests the field comparer.
- /// </summary>
- [Test]
- public void TestFieldComparer()
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new[]
- {
- new BinaryTypeConfiguration(typeof(Foo))
- {
- EqualityComparer = new BinaryFieldEqualityComparer("Name", "Id")
- }
- }
- });
-
- var val = new Foo {Id = 58, Name = "John"};
- var binObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(val), BinaryMode.ForceBinary);
- var expHash = val.Name.GetHashCode() * 31 + val.Id.GetHashCode();
- Assert.AreEqual(expHash, binObj.GetHashCode());
-
- val = new Foo {Id = 95};
- binObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(val), BinaryMode.ForceBinary);
- expHash = val.Id.GetHashCode();
- Assert.AreEqual(expHash, binObj.GetHashCode());
- }
-
- /// <summary>
- /// Tests the field comparer validation.
- /// </summary>
- [Test]
- public void TestFieldComparerValidation()
- {
- var ex = Assert.Throws<IgniteException>(() => Ignition.Start(
- new IgniteConfiguration(TestUtils.GetTestConfiguration())
- {
- BinaryConfiguration = new BinaryConfiguration
- {
- TypeConfigurations = new[]
- {
- new BinaryTypeConfiguration(typeof(Foo))
- {
- EqualityComparer = new BinaryFieldEqualityComparer()
- }
- }
- }
- }));
-
- Assert.IsNotNull(ex.InnerException);
- Assert.AreEqual("BinaryFieldEqualityComparer.FieldNames can not be null or empty.",
- ex.InnerException.Message);
+ Assert.AreEqual(obj.GetHashCode(), BinaryArrayEqualityComparer.GetHashCode(obj));
}
/// <summary>
@@ -227,16 +129,7 @@ namespace Apache.Ignite.Core.Tests.Binary
/// </summary>
private static IBinaryObject GetBinaryObject(int id, string name, int raw)
{
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new[]
- {
- new BinaryTypeConfiguration(typeof(Foo))
- {
- EqualityComparer = new BinaryArrayEqualityComparer()
- }
- }
- });
+ var marsh = new Marshaller(new BinaryConfiguration(typeof(Foo)));
var bytes = marsh.Marshal(new Foo {Id = id, Name = name, Raw = raw});
@@ -265,18 +158,5 @@ namespace Apache.Ignite.Core.Tests.Binary
Raw = reader.GetRawReader().ReadInt();
}
}
-
- private class MyComparer : IEqualityComparer<IBinaryObject>
- {
- public bool Equals(IBinaryObject x, IBinaryObject y)
- {
- return true;
- }
-
- public int GetHashCode(IBinaryObject obj)
- {
- return 0;
- }
- }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
index a6a295b..d687894 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheDmlQueriesTest.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Binary;
using NUnit.Framework;
/// <summary>
@@ -39,17 +38,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
{
var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
{
- BinaryConfiguration = new BinaryConfiguration(typeof(Foo))
- {
- TypeConfigurations =
- {
- new BinaryTypeConfiguration(typeof(Key)),
- new BinaryTypeConfiguration(typeof(Key2))
- {
- EqualityComparer = new BinaryFieldEqualityComparer("Hi", "Lo")
- }
- }
- }
+ BinaryConfiguration = new BinaryConfiguration(typeof(Foo), typeof(Key), typeof(Key2))
};
Ignition.Start(cfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 7e44a7a..532f6d5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -45,7 +45,6 @@ namespace Apache.Ignite.Core.Tests
using Apache.Ignite.Core.Discovery.Tcp;
using Apache.Ignite.Core.Discovery.Tcp.Multicast;
using Apache.Ignite.Core.Events;
- using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Lifecycle;
using Apache.Ignite.Core.Log;
@@ -76,7 +75,6 @@ namespace Apache.Ignite.Core.Tests
</types>
<typeConfigurations>
<binaryTypeConfiguration affinityKeyFieldName='affKeyFieldName' isEnum='true' keepDeserialized='True' typeName='typeName'>
- <equalityComparer type='BinaryArrayEqualityComparer' />
<idMapper type='Apache.Ignite.Core.Tests.Binary.IdMapper, Apache.Ignite.Core.Tests' />
<nameMapper type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+NameMapper, Apache.Ignite.Core.Tests' />
<serializer type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+TestSerializer, Apache.Ignite.Core.Tests' />
@@ -234,7 +232,6 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual("affKeyFieldName", binType.AffinityKeyFieldName);
Assert.IsTrue(binType.IsEnum);
Assert.AreEqual(true, binType.KeepDeserialized);
- Assert.IsInstanceOf<BinaryArrayEqualityComparer>(binType.EqualityComparer);
Assert.IsInstanceOf<IdMapper>(binType.IdMapper);
Assert.IsInstanceOf<NameMapper>(binType.NameMapper);
Assert.IsInstanceOf<TestSerializer>(binType.Serializer);
@@ -585,8 +582,7 @@ namespace Apache.Ignite.Core.Tests
TypeName = "typeName",
IdMapper = new IdMapper(),
NameMapper = new NameMapper(),
- Serializer = new TestSerializer(),
- EqualityComparer = new BinaryArrayEqualityComparer()
+ Serializer = new TestSerializer()
},
new BinaryTypeConfiguration
{
@@ -594,8 +590,7 @@ namespace Apache.Ignite.Core.Tests
KeepDeserialized = false,
AffinityKeyFieldName = "affKeyFieldName",
TypeName = "typeName2",
- Serializer = new BinaryReflectiveSerializer(),
- EqualityComparer = new BinaryFieldEqualityComparer()
+ Serializer = new BinaryReflectiveSerializer()
}
},
Types = new[] {typeof (string).FullName},
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index ee36e5d..8358f69 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -34,7 +34,6 @@ namespace Apache.Ignite.Core.Tests
using Apache.Ignite.Core.Discovery.Tcp.Static;
using Apache.Ignite.Core.Events;
using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Tests.Plugin;
using Apache.Ignite.Core.Transactions;
using NUnit.Framework;
@@ -183,9 +182,6 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual("affKey", typ.AffinityKeyFieldName);
Assert.AreEqual(false, typ.KeepDeserialized);
- CollectionAssert.AreEqual(new[] {"fld1", "fld2"},
- ((BinaryFieldEqualityComparer)typ.EqualityComparer).FieldNames);
-
Assert.IsNotNull(resCfg.PluginConfigurations);
Assert.AreEqual(cfg.PluginConfigurations, resCfg.PluginConfigurations);
}
@@ -523,8 +519,7 @@ namespace Apache.Ignite.Core.Tests
TypeName = "myType",
IsEnum = true,
AffinityKeyFieldName = "affKey",
- KeepDeserialized = false,
- EqualityComparer = new BinaryFieldEqualityComparer("fld1", "fld2")
+ KeepDeserialized = false
}
}
},
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index c999d84..1a758ce 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -91,9 +91,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Binary\BinaryArrayEqualityComparer.cs" />
<Compile Include="Common\ExceptionFactory.cs" />
- <Compile Include="Impl\Binary\BinaryFieldEqualityComparer.cs" />
<Compile Include="Binary\BinaryReflectiveSerializer.cs" />
<Compile Include="Common\JavaException.cs" />
<Compile Include="DataStructures\Configuration\Package-Info.cs" />
@@ -101,10 +99,9 @@
<Compile Include="Discovery\Tcp\Multicast\Package-Info.cs" />
<Compile Include="Discovery\Tcp\Package-Info.cs" />
<Compile Include="Discovery\Tcp\Static\Package-Info.cs" />
- <Compile Include="Impl\Binary\BinaryEqualityComparerSerializer.cs" />
+ <Compile Include="Impl\Binary\BinaryArrayEqualityComparer.cs" />
<Compile Include="Impl\Binary\BinaryProcessor.cs" />
<Compile Include="Impl\Binary\BinaryReflectiveSerializerInternal.cs" />
- <Compile Include="Impl\Binary\IBinaryEqualityComparer.cs" />
<Compile Include="Impl\Binary\IBinarySerializerInternal.cs" />
<Compile Include="Binary\Package-Info.cs" />
<Compile Include="Cache\Affinity\AffinityKey.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs
deleted file mode 100644
index 7f8048a..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryArrayEqualityComparer.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-\ufeff/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Binary
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
- using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Binary.IO;
-
- /// <summary>
- /// Compares binary object equality using underlying byte array.
- /// </summary>
- public sealed class BinaryArrayEqualityComparer : IEqualityComparer<IBinaryObject>, IBinaryEqualityComparer,
- IBinaryStreamProcessor<KeyValuePair<int,int>, int>
- {
- /// <summary>
- /// Singleton instance.
- /// </summary>
- [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes",
- Justification = "Type is immutable.")]
- public static readonly BinaryArrayEqualityComparer Instance = new BinaryArrayEqualityComparer();
-
- /// <summary>
- /// Determines whether the specified objects are equal.
- /// </summary>
- /// <param name="x">The first object to compare.</param>
- /// <param name="y">The second object to compare.</param>
- /// <returns>
- /// true if the specified objects are equal; otherwise, false.
- /// </returns>
- public bool Equals(IBinaryObject x, IBinaryObject y)
- {
- if (x == null)
- return y == null;
-
- if (y == null)
- return false;
-
- if (ReferenceEquals(x, y))
- return true;
-
- var binx = GetBinaryObject(x);
- var biny = GetBinaryObject(y);
-
- var lenx = GetDataLength(binx);
- var leny = GetDataLength(biny);
-
- if (lenx != leny)
- return false;
-
- var startx = GetDataStart(binx);
- var starty = GetDataStart(biny);
-
- var arrx = binx.Data;
- var arry = biny.Data;
-
- for (var i = 0; i < lenx; i++)
- {
- if (arrx[i + startx] != arry[i + starty])
- return false;
- }
-
- return true;
- }
-
- /// <summary>
- /// Returns a hash code for this instance.
- /// </summary>
- /// <param name="obj">The object.</param>
- /// <returns>
- /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
- /// </returns>
- public int GetHashCode(IBinaryObject obj)
- {
- if (obj == null)
- return 0;
-
- var binObj = GetBinaryObject(obj);
-
- var arg = new KeyValuePair<int, int>(GetDataStart(binObj), GetDataLength(binObj));
-
- using (var stream = new BinaryHeapStream(binObj.Data))
- {
- return stream.Apply(this, arg);
- }
- }
-
- /** <inheritdoc /> */
- int IBinaryEqualityComparer.GetHashCode(IBinaryStream stream, int startPos, int length,
- BinaryObjectSchemaHolder schema, int schemaId, Marshaller marshaller, IBinaryTypeDescriptor desc)
- {
- Debug.Assert(stream != null);
- Debug.Assert(startPos >= 0);
- Debug.Assert(length >= 0);
-
- var arg = new KeyValuePair<int, int>(startPos, length);
-
- return stream.Apply(this, arg);
- }
-
- /** <inheritdoc /> */
- unsafe int IBinaryStreamProcessor<KeyValuePair<int, int>, int>.Invoke(byte* data, KeyValuePair<int, int> arg)
- {
- var hash = 1;
- var ptr = data + arg.Key;
-
- for (var i = 0; i < arg.Value; i++)
- hash = 31 * hash + *(ptr + i);
-
- return hash;
- }
-
- /// <summary>
- /// Casts to <see cref="BinaryObject"/> or throws an error.
- /// </summary>
- private static BinaryObject GetBinaryObject(IBinaryObject obj)
- {
- var binObj = obj as BinaryObject;
-
- if (binObj != null)
- return binObj;
-
- throw new NotSupportedException(string.Format("{0} of type {1} is not supported.",
- typeof(IBinaryObject), obj.GetType()));
- }
-
- /// <summary>
- /// Gets the non-raw data length.
- /// </summary>
- private static int GetDataLength(BinaryObject binObj)
- {
- return binObj.Header.FooterStartOffset - BinaryObjectHeader.Size;
- }
-
- /// <summary>
- /// Gets the data starting position.
- /// </summary>
- private static int GetDataStart(BinaryObject binObj)
- {
- return binObj.Offset + BinaryObjectHeader.Size;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
index 722197c..d342fa5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryTypeConfiguration.cs
@@ -70,7 +70,6 @@ namespace Apache.Ignite.Core.Binary
TypeName = cfg.TypeName;
KeepDeserialized = cfg.KeepDeserialized;
IsEnum = cfg.IsEnum;
- EqualityComparer = cfg.EqualityComparer;
}
/// <summary>
@@ -115,18 +114,6 @@ namespace Apache.Ignite.Core.Binary
public bool IsEnum { get; set; }
/// <summary>
- /// Gets or sets the equality comparer to compute hash codes and compare objects
- /// in <see cref="IBinaryObject"/> form.
- /// This comparer is important only for types that are used as cache keys.
- /// <para />
- /// Null means legacy behavior: hash code is computed by calling <see cref="object.GetHashCode"/>, equality is
- /// computed by comparing bytes in serialized (binary) form.
- /// <para />
- /// Only predefined implementations are supported: <see cref="BinaryArrayEqualityComparer"/>.
- /// </summary>
- public IEqualityComparer<IBinaryObject> EqualityComparer { get; set; }
-
- /// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index dc1a88c..a3f5daf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -271,30 +271,6 @@ namespace Apache.Ignite.Core
{
writer.WriteBoolean(false);
}
-
- // Send only descriptors with non-null EqualityComparer to preserve old behavior where
- // remote nodes can have no BinaryConfiguration.
-
- if (BinaryConfiguration.TypeConfigurations != null &&
- BinaryConfiguration.TypeConfigurations.Any(x => x.EqualityComparer != null))
- {
- // Create a new marshaller to reuse type name resolver mechanism.
- var types = new Marshaller(BinaryConfiguration).GetUserTypeDescriptors()
- .Where(x => x.EqualityComparer != null).ToList();
-
- writer.WriteInt(types.Count);
-
- foreach (var type in types)
- {
- writer.WriteString(BinaryUtils.SimpleTypeName(type.TypeName));
- writer.WriteBoolean(type.IsEnum);
- BinaryEqualityComparerSerializer.Write(writer, type.EqualityComparer);
- }
- }
- else
- {
- writer.WriteInt(0);
- }
}
else
{
@@ -428,25 +404,6 @@ namespace Apache.Ignite.Core
if (r.ReadBoolean())
BinaryConfiguration.CompactFooter = r.ReadBoolean();
-
- var typeCount = r.ReadInt();
-
- if (typeCount > 0)
- {
- var types = new List<BinaryTypeConfiguration>(typeCount);
-
- for (var i = 0; i < typeCount; i++)
- {
- types.Add(new BinaryTypeConfiguration
- {
- TypeName = r.ReadString(),
- IsEnum = r.ReadBoolean(),
- EqualityComparer = BinaryEqualityComparerSerializer.Read(r)
- });
- }
-
- BinaryConfiguration.TypeConfigurations = types;
- }
}
// User attributes
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 649129a..f041a8f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -144,20 +144,6 @@
</xs:attribute>
</xs:complexType>
</xs:element>
- <xs:element name="equalityComparer" minOccurs="0">
- <xs:annotation>
- <xs:documentation>
- Equality comparer to compute hash codes and compare objects in IBinaryObject form.
- </xs:documentation>
- </xs:annotation>
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>Assembly-qualified type name.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
</xs:all>
<xs:attribute name="typeName" type="xs:string">
<xs:annotation>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c2d8bd9a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryArrayEqualityComparer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryArrayEqualityComparer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryArrayEqualityComparer.cs
new file mode 100644
index 0000000..8ba409b
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryArrayEqualityComparer.cs
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
+
+ /// <summary>
+ /// Compares binary object equality using underlying byte array.
+ /// </summary>
+ internal static class BinaryArrayEqualityComparer
+ {
+ /** */
+ private static readonly HashStreamProcessor HashCodeProcessor = new HashStreamProcessor();
+
+ /// <summary>
+ /// Determines whether the specified objects are equal.
+ /// </summary>
+ /// <param name="x">The first object to compare.</param>
+ /// <param name="y">The second object to compare.</param>
+ /// <returns>
+ /// true if the specified objects are equal; otherwise, false.
+ /// </returns>
+ public static bool Equals(IBinaryObject x, IBinaryObject y)
+ {
+ if (x == null)
+ return y == null;
+
+ if (y == null)
+ return false;
+
+ if (ReferenceEquals(x, y))
+ return true;
+
+ var binx = GetBinaryObject(x);
+ var biny = GetBinaryObject(y);
+
+ var lenx = GetDataLength(binx);
+ var leny = GetDataLength(biny);
+
+ if (lenx != leny)
+ return false;
+
+ var startx = GetDataStart(binx);
+ var starty = GetDataStart(biny);
+
+ var arrx = binx.Data;
+ var arry = biny.Data;
+
+ for (var i = 0; i < lenx; i++)
+ {
+ if (arrx[i + startx] != arry[i + starty])
+ return false;
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Returns a hash code for this instance.
+ /// </summary>
+ /// <param name="obj">The object.</param>
+ /// <returns>
+ /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
+ /// </returns>
+ public static int GetHashCode(IBinaryObject obj)
+ {
+ if (obj == null)
+ return 0;
+
+ var binObj = GetBinaryObject(obj);
+
+ var arg = new KeyValuePair<int, int>(GetDataStart(binObj), GetDataLength(binObj));
+
+ using (var stream = new BinaryHeapStream(binObj.Data))
+ {
+ return stream.Apply(HashCodeProcessor, arg);
+ }
+ }
+
+ /** <inheritdoc /> */
+ public static int GetHashCode(IBinaryStream stream, int startPos, int length)
+ {
+ Debug.Assert(stream != null);
+ Debug.Assert(startPos >= 0);
+ Debug.Assert(length >= 0);
+
+ var arg = new KeyValuePair<int, int>(startPos, length);
+
+ return stream.Apply(HashCodeProcessor, arg);
+ }
+
+ /// <summary>
+ /// Casts to <see cref="BinaryObject"/> or throws an error.
+ /// </summary>
+ private static BinaryObject GetBinaryObject(IBinaryObject obj)
+ {
+ var binObj = obj as BinaryObject;
+
+ if (binObj != null)
+ return binObj;
+
+ throw new NotSupportedException(string.Format("{0} of type {1} is not supported.",
+ typeof(IBinaryObject), obj.GetType()));
+ }
+
+ /// <summary>
+ /// Gets the non-raw data length.
+ /// </summary>
+ private static int GetDataLength(BinaryObject binObj)
+ {
+ return binObj.Header.FooterStartOffset - BinaryObjectHeader.Size;
+ }
+
+ /// <summary>
+ /// Gets the data starting position.
+ /// </summary>
+ private static int GetDataStart(BinaryObject binObj)
+ {
+ return binObj.Offset + BinaryObjectHeader.Size;
+ }
+
+ /// <summary>
+ /// Hash code calculating stream processor.
+ /// </summary>
+ private class HashStreamProcessor : IBinaryStreamProcessor<KeyValuePair<int, int>, int>
+ {
+ /** <inheritdoc /> */
+ public unsafe int Invoke(byte* data, KeyValuePair<int, int> arg)
+ {
+ var hash = 1;
+ var ptr = data + arg.Key;
+
+ for (var i = 0; i < arg.Value; i++)
+ hash = 31 * hash + *(ptr + i);
+
+ return hash;
+ }
+ }
+ }
+}