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 2015/11/21 23:45:29 UTC
[01/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Repository: ignite
Updated Branches:
refs/heads/ignite-1.5 5d224f192 -> 13e11b32b
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
deleted file mode 100644
index 16c68e1..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/PortableConfigurationTest.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Cache;
- using NUnit.Framework;
-
- /// <summary>
- /// Portable configuration tests.
- /// </summary>
- public class PortableConfigurationTest
- {
- /** Cache. */
- private ICache<int, TestGenericPortableBase> _cache;
-
- /** Random generator. */
- private static readonly Random Rnd = new Random();
-
- /** Test types for code config */
- private static readonly Type[] TestTypes = {
- typeof (TestGenericPortable<int>),
- typeof (TestGenericPortable<string>),
- typeof (TestGenericPortable<TestGenericPortable<int>>),
- typeof (TestGenericPortable<List<Tuple<int, string>>>),
- typeof (TestGenericPortable<int, string>),
- typeof (TestGenericPortable<int, TestGenericPortable<string>>),
- typeof (TestGenericPortable<int, string, Type>),
- typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
- };
-
- /** Test types for xml config */
- private static readonly Type[] TestTypesXml = {
- typeof (TestGenericPortable<long>),
- typeof (TestGenericPortable<Type>),
- typeof (TestGenericPortable<TestGenericPortable<long>>),
- typeof (TestGenericPortable<List<Tuple<long, string>>>),
- typeof (TestGenericPortable<long, string>),
- typeof (TestGenericPortable<long, TestGenericPortable<string>>),
- typeof (TestGenericPortable<long, string, Type>),
- typeof (TestGenericPortable<long, string, TestGenericPortable<long, string, Type>>)
- };
-
- /// <summary>
- /// Starts the grid with provided config.
- /// </summary>
- /// <param name="binaryConfiguration">The portable configuration.</param>
- private void StartGrid(BinaryConfiguration binaryConfiguration)
- {
- Ignition.StopAll(true);
-
- var grid = Ignition.Start(new IgniteConfiguration
- {
- SpringConfigUrl = "config\\cache-portables.xml",
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = TestUtils.TestJavaOptions(),
- BinaryConfiguration = binaryConfiguration
- });
-
- _cache = grid.GetCache<int, TestGenericPortableBase>(null);
- }
-
- /// <summary>
- /// Test fixture tear-down routine.
- /// </summary>
- [TestFixtureTearDown]
- public void TestFixtureTearDown()
- {
- Ignition.StopAll(true);
- }
-
- /// <summary>
- /// Tests the configuration set in code.
- /// </summary>
- [Test]
- public void TestCodeConfiguration()
- {
- StartGrid(new BinaryConfiguration
- {
- TypeConfigurations = TestTypes.Select(x => new BinaryTypeConfiguration(x)).ToList()
- });
-
- CheckPortableTypes(TestTypes);
- }
-
- /// <summary>
- /// Tests the configuration set in xml.
- /// </summary>
- [Test]
- public void TestXmlConfiguration()
- {
- StartGrid(null);
-
- CheckPortableTypes(TestTypesXml);
- }
-
- /// <summary>
- /// Checks that specified types are portable and can be successfully used in cache.
- /// </summary>
- private void CheckPortableTypes(IEnumerable<Type> testTypes)
- {
- int key = 0;
-
- foreach (var typ in testTypes)
- {
- key += 1;
-
- var inst = CreateInstance(typ);
-
- _cache.Put(key, inst);
-
- var result = _cache.Get(key);
-
- Assert.AreEqual(inst.Prop, result.Prop);
-
- Assert.AreEqual(typ, result.GetType());
- }
- }
-
- /// <summary>
- /// Creates the instance of specified test portable type and sets a value on it.
- /// </summary>
- private static TestGenericPortableBase CreateInstance(Type type)
- {
- var inst = (TestGenericPortableBase)Activator.CreateInstance(type);
-
- inst.Prop = Rnd.Next(int.MaxValue);
-
- return inst;
- }
- }
-
- public abstract class TestGenericPortableBase
- {
- public object Prop { get; set; }
- }
-
- public class TestGenericPortable<T> : TestGenericPortableBase
- {
- public T Prop1 { get; set; }
- }
-
- public class TestGenericPortable<T1, T2> : TestGenericPortableBase
- {
- public T1 Prop1 { get; set; }
- public T2 Prop2 { get; set; }
- }
-
- public class TestGenericPortable<T1, T2, T3> : TestGenericPortableBase
- {
- public T1 Prop1 { get; set; }
- public T2 Prop2 { get; set; }
- public T3 Prop3 { get; set; }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs
new file mode 100644
index 0000000..c2e38bb
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/BinarizablePerson.cs
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Query
+{
+ using Apache.Ignite.Core.Binary;
+
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class BinarizablePerson : IBinarizable
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinarizablePerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public BinarizablePerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address.
+ /// </summary>
+ public string Address { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+
+ /** <ineritdoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteString("name", Name);
+ writer.WriteString("address", Address);
+ writer.WriteInt("age", Age);
+ }
+
+ /** <ineritdoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Name = reader.ReadString("name");
+ Address = reader.ReadString("address");
+ Age = reader.ReadInt("age");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs
new file mode 100644
index 0000000..b7e9524
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitBinarizablePerson.cs
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Query
+{
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class ImplicitBinarizablePerson
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ImplicitBinarizablePerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public ImplicitBinarizablePerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
deleted file mode 100644
index f80c4eb..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/ImplicitPortablePerson.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Query
-{
- /// <summary>
- /// Test person.
- /// </summary>
- internal class ImplicitPortablePerson
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ImplicitPortablePerson"/> class.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="age">The age.</param>
- public ImplicitPortablePerson(string name, int age)
- {
- Name = name;
- Age = age;
- }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs
new file mode 100644
index 0000000..5ae4159
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefBinarizablePerson.cs
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Query
+{
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ internal class NoDefBinarizablePerson
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ public int Age { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
deleted file mode 100644
index 16bd07d..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/NoDefPortablePerson.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Query
-{
- /// <summary>
- /// Test person.
- /// </summary>
- internal class NoDefPortablePerson
- {
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
deleted file mode 100644
index 08134fd..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Query/PortablePerson.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Query
-{
- using Apache.Ignite.Core.Binary;
-
- /// <summary>
- /// Test person.
- /// </summary>
- internal class PortablePerson : IBinarizable
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="PortablePerson"/> class.
- /// </summary>
- /// <param name="name">The name.</param>
- /// <param name="age">The age.</param>
- public PortablePerson(string name, int age)
- {
- Name = name;
- Age = age;
- }
-
- /// <summary>
- /// Gets or sets the name.
- /// </summary>
- public string Name { get; set; }
-
- /// <summary>
- /// Gets or sets the address.
- /// </summary>
- public string Address { get; set; }
-
- /// <summary>
- /// Gets or sets the age.
- /// </summary>
- public int Age { get; set; }
-
- /** <ineritdoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteString("name", Name);
- writer.WriteString("address", Address);
- writer.WriteInt("age", Age);
- }
-
- /** <ineritdoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Name = reader.ReadString("name");
- Address = reader.ReadString("address");
- Age = reader.ReadInt("age");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
index 1fe6a21..1797337 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServiceProxyTest.cs
@@ -42,8 +42,8 @@ namespace Apache.Ignite.Core.Tests.Services
{
TypeConfigurations = new[]
{
- new BinaryTypeConfiguration(typeof (TestPortableClass)),
- new BinaryTypeConfiguration(typeof (CustomExceptionPortable))
+ new BinaryTypeConfiguration(typeof (TestBinarizableClass)),
+ new BinaryTypeConfiguration(typeof (CustomExceptionBinarizable))
}
});
@@ -54,10 +54,10 @@ namespace Apache.Ignite.Core.Tests.Services
private readonly PlatformMemoryManager _memory = new PlatformMemoryManager(1024);
/** */
- protected bool KeepPortable;
+ protected bool KeepBinary;
/** */
- protected bool SrvKeepPortable;
+ protected bool SrvKeepBinary;
/// <summary>
/// Initializes a new instance of the <see cref="ServiceProxyTest"/> class.
@@ -196,13 +196,13 @@ namespace Apache.Ignite.Core.Tests.Services
}
[Test]
- public void TestPortableMarshallingException()
+ public void TestBinarizableMarshallingException()
{
var prx = GetProxy();
- var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(false, false));
+ var ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionBinarizableMethod(false, false));
- if (KeepPortable)
+ if (KeepBinary)
{
Assert.AreEqual("Proxy method invocation failed with a binary error. " +
"Examine BinaryCause for details.", ex.Message);
@@ -219,15 +219,15 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.IsNotNull(ex.InnerException);
}
- ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, false));
+ ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionBinarizableMethod(true, false));
Assert.IsTrue(ex.ToString().Contains(
- "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
- "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
+ "Call completed with error, but error serialization failed [errType=CustomExceptionBinarizable, " +
+ "serializationErrMsg=Expected exception in CustomExceptionBinarizable.WriteBinary]"));
- ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionPortableMethod(true, true));
+ ex = Assert.Throws<ServiceInvocationException>(() => prx.CustomExceptionBinarizableMethod(true, true));
Assert.IsTrue(ex.ToString().Contains(
- "Call completed with error, but error serialization failed [errType=CustomExceptionPortable, " +
- "serializationErrMsg=Expected exception in CustomExceptionPortable.WritePortable]"));
+ "Call completed with error, but error serialization failed [errType=CustomExceptionBinarizable, " +
+ "serializationErrMsg=Expected exception in CustomExceptionBinarizable.WriteBinary]"));
}
/// <summary>
@@ -266,7 +266,7 @@ namespace Apache.Ignite.Core.Tests.Services
using (var outStream = new PlatformMemoryStream(_memory.Allocate()))
{
// 1) Write to a stream
- inStream.WriteBool(SrvKeepPortable); // WriteProxyMethod does not do this, but Java does
+ inStream.WriteBool(SrvKeepBinary); // WriteProxyMethod does not do this, but Java does
ServiceProxySerializer.WriteProxyMethod(_marsh.StartMarshal(inStream), method, args);
@@ -290,7 +290,7 @@ namespace Apache.Ignite.Core.Tests.Services
outStream.Seek(0, SeekOrigin.Begin);
- return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepPortable);
+ return ServiceProxySerializer.ReadInvocationResult(outStream, _marsh, KeepBinary);
}
}
@@ -354,16 +354,16 @@ namespace Apache.Ignite.Core.Tests.Services
void CustomExceptionMethod();
/** */
- void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
+ void CustomExceptionBinarizableMethod(bool throwOnWrite, bool throwOnRead);
/** */
- TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2);
+ TestBinarizableClass BinarizableArgMethod(int arg1, IBinaryObject arg2);
/** */
- IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2);
+ IBinaryObject BinarizableResultMethod(int arg1, TestBinarizableClass arg2);
/** */
- IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2);
+ IBinaryObject BinarizableArgAndResultMethod(int arg1, IBinaryObject arg2);
/** */
int AmbiguousMethod(int arg);
@@ -414,16 +414,16 @@ namespace Apache.Ignite.Core.Tests.Services
void CustomExceptionMethod();
/** */
- void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead);
+ void CustomExceptionBinarizableMethod(bool throwOnWrite, bool throwOnRead);
/** */
- TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2);
+ TestBinarizableClass BinarizableArgMethod(int arg1, IBinaryObject arg2);
/** */
- IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2);
+ IBinaryObject BinarizableResultMethod(int arg1, TestBinarizableClass arg2);
/** */
- IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2);
+ IBinaryObject BinarizableArgAndResultMethod(int arg1, IBinaryObject arg2);
/** */
void MissingMethod();
@@ -444,7 +444,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// <summary>
/// Initializes a new instance of the <see cref="TestIgniteService"/> class.
/// </summary>
- /// <param name="igniteBinary">The portables.</param>
+ /// <param name="igniteBinary">Binary.</param>
public TestIgniteService(IIgniteBinary igniteBinary)
{
_igniteBinary = igniteBinary;
@@ -520,27 +520,27 @@ namespace Apache.Ignite.Core.Tests.Services
}
/** <inheritdoc /> */
- public void CustomExceptionPortableMethod(bool throwOnWrite, bool throwOnRead)
+ public void CustomExceptionBinarizableMethod(bool throwOnWrite, bool throwOnRead)
{
- throw new CustomExceptionPortable {ThrowOnRead = throwOnRead, ThrowOnWrite = throwOnWrite};
+ throw new CustomExceptionBinarizable {ThrowOnRead = throwOnRead, ThrowOnWrite = throwOnWrite};
}
/** <inheritdoc /> */
- public TestPortableClass PortableArgMethod(int arg1, IBinaryObject arg2)
+ public TestBinarizableClass BinarizableArgMethod(int arg1, IBinaryObject arg2)
{
- return arg2.Deserialize<TestPortableClass>();
+ return arg2.Deserialize<TestBinarizableClass>();
}
/** <inheritdoc /> */
- public IBinaryObject PortableResultMethod(int arg1, TestPortableClass arg2)
+ public IBinaryObject BinarizableResultMethod(int arg1, TestBinarizableClass arg2)
{
return _igniteBinary.ToBinary<IBinaryObject>(arg2);
}
/** <inheritdoc /> */
- public IBinaryObject PortableArgAndResultMethod(int arg1, IBinaryObject arg2)
+ public IBinaryObject BinarizableArgAndResultMethod(int arg1, IBinaryObject arg2)
{
- return _igniteBinary.ToBinary<IBinaryObject>(arg2.Deserialize<TestPortableClass>());
+ return _igniteBinary.ToBinary<IBinaryObject>(arg2.Deserialize<TestBinarizableClass>());
}
/** <inheritdoc /> */
@@ -595,7 +595,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// <summary>
/// Custom non-serializable exception.
/// </summary>
- private class CustomExceptionPortable : Exception, IBinarizable
+ private class CustomExceptionBinarizable : Exception, IBinarizable
{
/** */
public bool ThrowOnWrite { get; set; }
@@ -609,7 +609,7 @@ namespace Apache.Ignite.Core.Tests.Services
writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
if (ThrowOnWrite)
- throw new Exception("Expected exception in CustomExceptionPortable.WritePortable");
+ throw new Exception("Expected exception in CustomExceptionBinarizable.WriteBinary");
}
/** <inheritdoc /> */
@@ -618,14 +618,14 @@ namespace Apache.Ignite.Core.Tests.Services
ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
if (ThrowOnRead)
- throw new Exception("Expected exception in CustomExceptionPortable.ReadPortable");
+ throw new Exception("Expected exception in CustomExceptionBinarizable.ReadBinary");
}
}
/// <summary>
- /// Portable object for method argument/result.
+ /// Binarizable object for method argument/result.
/// </summary>
- protected class TestPortableClass : IBinarizable
+ protected class TestBinarizableClass : IBinarizable
{
/** */
public string Prop { get; set; }
@@ -643,7 +643,7 @@ namespace Apache.Ignite.Core.Tests.Services
writer.WriteBoolean("ThrowOnRead", ThrowOnRead);
if (ThrowOnWrite)
- throw new Exception("Expected exception in TestPortableClass.WritePortable");
+ throw new Exception("Expected exception in TestBinarizableClass.WriteBinary");
}
/** <inheritdoc /> */
@@ -653,89 +653,89 @@ namespace Apache.Ignite.Core.Tests.Services
ThrowOnRead = reader.ReadBoolean("ThrowOnRead");
if (ThrowOnRead)
- throw new Exception("Expected exception in TestPortableClass.ReadPortable");
+ throw new Exception("Expected exception in TestBinarizableClass.ReadBinary");
}
}
}
/// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client.
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepBinary mode enabled on client.
/// </summary>
- public class ServiceProxyTestKeepPortableClient : ServiceProxyTest
+ public class ServiceProxyTestKeepBinaryClient : ServiceProxyTest
{
/// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClient"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepBinaryClient"/> class.
/// </summary>
- public ServiceProxyTestKeepPortableClient()
+ public ServiceProxyTestKeepBinaryClient()
{
- KeepPortable = true;
+ KeepBinary = true;
}
[Test]
- public void TestPortableMethods()
+ public void TestBinarizableMethods()
{
var prx = GetProxy();
- var obj = new TestPortableClass { Prop = "PropValue" };
+ var obj = new TestBinarizableClass { Prop = "PropValue" };
- var result = prx.PortableResultMethod(1, obj);
+ var result = prx.BinarizableResultMethod(1, obj);
- Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
+ Assert.AreEqual(obj.Prop, result.Deserialize<TestBinarizableClass>().Prop);
}
}
/// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on server.
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepBinary mode enabled on server.
/// </summary>
- public class ServiceProxyTestKeepPortableServer : ServiceProxyTest
+ public class ServiceProxyTestKeepBinaryServer : ServiceProxyTest
{
/// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableServer"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepBinaryServer"/> class.
/// </summary>
- public ServiceProxyTestKeepPortableServer()
+ public ServiceProxyTestKeepBinaryServer()
{
- SrvKeepPortable = true;
+ SrvKeepBinary = true;
}
[Test]
- public void TestPortableMethods()
+ public void TestBinarizableMethods()
{
var prx = GetProxy();
- var obj = new TestPortableClass { Prop = "PropValue" };
+ var obj = new TestBinarizableClass { Prop = "PropValue" };
var portObj = IgniteBinary.ToBinary<IBinaryObject>(obj);
- var result = prx.PortableArgMethod(1, portObj);
+ var result = prx.BinarizableArgMethod(1, portObj);
Assert.AreEqual(obj.Prop, result.Prop);
}
}
/// <summary>
- /// Tests <see cref="ServiceProxySerializer"/> functionality with keepPortable mode enabled on client and on server.
+ /// Tests <see cref="ServiceProxySerializer"/> functionality with keepBinary mode enabled on client and on server.
/// </summary>
- public class ServiceProxyTestKeepPortableClientServer : ServiceProxyTest
+ public class ServiceProxyTestKeepBinaryClientServer : ServiceProxyTest
{
/// <summary>
- /// Initializes a new instance of the <see cref="ServiceProxyTestKeepPortableClientServer"/> class.
+ /// Initializes a new instance of the <see cref="ServiceProxyTestKeepBinaryClientServer"/> class.
/// </summary>
- public ServiceProxyTestKeepPortableClientServer()
+ public ServiceProxyTestKeepBinaryClientServer()
{
- KeepPortable = true;
- SrvKeepPortable = true;
+ KeepBinary = true;
+ SrvKeepBinary = true;
}
[Test]
- public void TestPortableMethods()
+ public void TestBinarizableMethods()
{
var prx = GetProxy();
- var obj = new TestPortableClass { Prop = "PropValue" };
+ var obj = new TestBinarizableClass { Prop = "PropValue" };
var portObj = IgniteBinary.ToBinary<IBinaryObject>(obj);
- var result = prx.PortableArgAndResultMethod(1, portObj);
+ var result = prx.BinarizableArgAndResultMethod(1, portObj);
- Assert.AreEqual(obj.Prop, result.Deserialize<TestPortableClass>().Prop);
+ Assert.AreEqual(obj.Prop, result.Deserialize<TestBinarizableClass>().Prop);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
index c4b5776..33f255e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -102,7 +102,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// Tests deployment.
/// </summary>
[Test]
- public void TestDeploy([Values(true, false)] bool portable)
+ public void TestDeploy([Values(true, false)] bool binarizable)
{
var cfg = new ServiceConfiguration
{
@@ -110,7 +110,7 @@ namespace Apache.Ignite.Core.Tests.Services
MaxPerNodeCount = 3,
TotalCount = 3,
NodeFilter = new NodeFilter {NodeId = Grid1.GetCluster().GetLocalNode().Id},
- Service = portable ? new TestIgniteServicePortable() : new TestIgniteServiceSerializable()
+ Service = binarizable ? new TestIgniteServiceBinarizable() : new TestIgniteServiceSerializable()
};
Services.Deploy(cfg);
@@ -161,7 +161,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestDeployKeyAffinitySingleton()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
Services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, AffKey);
@@ -176,13 +176,13 @@ namespace Apache.Ignite.Core.Tests.Services
/// Tests key affinity singleton deployment.
/// </summary>
[Test]
- public void TestDeployKeyAffinitySingletonPortable()
+ public void TestDeployKeyAffinitySingletonBinarizable()
{
var services = Services.WithKeepBinary();
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
- var affKey = new PortableObject {Val = AffKey};
+ var affKey = new BinarizableObject {Val = AffKey};
services.DeployKeyAffinitySingleton(SvcName, svc, CacheName, affKey);
@@ -213,7 +213,7 @@ namespace Apache.Ignite.Core.Tests.Services
{
for (var i = 0; i < 10; i++)
{
- Services.DeployNodeSingleton(SvcName + i, new TestIgniteServicePortable());
+ Services.DeployNodeSingleton(SvcName + i, new TestIgniteServiceBinarizable());
Assert.IsNotNull(Services.GetService<ITestIgniteService>(SvcName + i));
}
@@ -236,7 +236,7 @@ namespace Apache.Ignite.Core.Tests.Services
/// Tests service proxy.
/// </summary>
[Test]
- public void TestGetServiceProxy([Values(true, false)] bool portable)
+ public void TestGetServiceProxy([Values(true, false)] bool binarizable)
{
// Test proxy without a service
var prx = Services.GetServiceProxy<ITestIgniteService>(SvcName);
@@ -247,8 +247,8 @@ namespace Apache.Ignite.Core.Tests.Services
Assert.AreEqual("Failed to find deployed service: " + SvcName, ex.Message);
// Deploy to grid2 & grid3
- var svc = portable
- ? new TestIgniteServicePortable {TestProperty = 17}
+ var svc = binarizable
+ ? new TestIgniteServiceBinarizable {TestProperty = 17}
: new TestIgniteServiceSerializable {TestProperty = 17};
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id, Grid3.GetCluster().GetLocalNode().Id).GetServices()
@@ -300,7 +300,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestDuckTyping([Values(true, false)] bool local)
{
- var svc = new TestIgniteServicePortable {TestProperty = 33};
+ var svc = new TestIgniteServiceBinarizable {TestProperty = 33};
// Deploy locally or to the remote node
var nodeId = (local ? Grid1 : Grid2).GetCluster().GetLocalNode().Id;
@@ -358,12 +358,12 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Tests the client portable flag.
+ /// Tests the client binary flag.
/// </summary>
[Test]
- public void TestWithKeepPortableClient()
+ public void TestWithKeepBinaryClient()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
// Deploy to grid2
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary()
@@ -372,22 +372,22 @@ namespace Apache.Ignite.Core.Tests.Services
// Get proxy
var prx = Services.WithKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
- var obj = new PortableObject {Val = 11};
+ var obj = new BinarizableObject {Val = 11};
var res = (IBinaryObject) prx.Method(obj);
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
res = (IBinaryObject) prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
}
/// <summary>
- /// Tests the server portable flag.
+ /// Tests the server binary flag.
/// </summary>
[Test]
- public void TestWithKeepPortableServer()
+ public void TestWithKeepBinaryServer()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
// Deploy to grid2
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithServerKeepBinary()
@@ -396,22 +396,22 @@ namespace Apache.Ignite.Core.Tests.Services
// Get proxy
var prx = Services.WithServerKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
- var obj = new PortableObject { Val = 11 };
+ var obj = new BinarizableObject { Val = 11 };
- var res = (PortableObject) prx.Method(obj);
+ var res = (BinarizableObject) prx.Method(obj);
Assert.AreEqual(11, res.Val);
- res = (PortableObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
+ res = (BinarizableObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
Assert.AreEqual(11, res.Val);
}
/// <summary>
- /// Tests server and client portable flag.
+ /// Tests server and client binary flag.
/// </summary>
[Test]
- public void TestWithKeepPortableBoth()
+ public void TestWithKeepBinaryBoth()
{
- var svc = new TestIgniteServicePortable();
+ var svc = new TestIgniteServiceBinarizable();
// Deploy to grid2
Grid1.GetCluster().ForNodeIds(Grid2.GetCluster().GetLocalNode().Id).GetServices().WithKeepBinary().WithServerKeepBinary()
@@ -420,13 +420,13 @@ namespace Apache.Ignite.Core.Tests.Services
// Get proxy
var prx = Services.WithKeepBinary().WithServerKeepBinary().GetServiceProxy<ITestIgniteService>(SvcName);
- var obj = new PortableObject { Val = 11 };
+ var obj = new BinarizableObject { Val = 11 };
var res = (IBinaryObject)prx.Method(obj);
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
res = (IBinaryObject)prx.Method(Grid1.GetBinary().ToBinary<IBinaryObject>(obj));
- Assert.AreEqual(11, res.Deserialize<PortableObject>().Val);
+ Assert.AreEqual(11, res.Deserialize<BinarizableObject>().Val);
}
/// <summary>
@@ -484,7 +484,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestMarshalExceptionOnRead()
{
- var svc = new TestIgniteServicePortableErr();
+ var svc = new TestIgniteServiceBinarizableErr();
var ex = Assert.Throws<IgniteException>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
Assert.AreEqual("Expected exception", ex.Message);
@@ -497,7 +497,7 @@ namespace Apache.Ignite.Core.Tests.Services
[Test]
public void TestMarshalExceptionOnWrite()
{
- var svc = new TestIgniteServicePortableErr {ThrowOnWrite = true};
+ var svc = new TestIgniteServiceBinarizableErr {ThrowOnWrite = true};
var ex = Assert.Throws<Exception>(() => Services.DeployMultiple(SvcName, svc, Grids.Length, 1));
Assert.AreEqual("Expected exception", ex.Message);
@@ -570,9 +570,9 @@ namespace Apache.Ignite.Core.Tests.Services
{
TypeConfigurations = new List<BinaryTypeConfiguration>
{
- new BinaryTypeConfiguration(typeof(TestIgniteServicePortable)),
- new BinaryTypeConfiguration(typeof(TestIgniteServicePortableErr)),
- new BinaryTypeConfiguration(typeof(PortableObject))
+ new BinaryTypeConfiguration(typeof(TestIgniteServiceBinarizable)),
+ new BinaryTypeConfiguration(typeof(TestIgniteServiceBinarizableErr)),
+ new BinaryTypeConfiguration(typeof(BinarizableObject))
}
}
};
@@ -734,11 +734,11 @@ namespace Apache.Ignite.Core.Tests.Services
if (context.AffinityKey != null && !(context.AffinityKey is int))
{
- var portableObject = context.AffinityKey as IBinaryObject;
+ var binaryObj = context.AffinityKey as IBinaryObject;
- var key = portableObject != null
- ? portableObject.Deserialize<PortableObject>()
- : (PortableObject) context.AffinityKey;
+ var key = binaryObj != null
+ ? binaryObj.Deserialize<BinarizableObject>()
+ : (BinarizableObject) context.AffinityKey;
Assert.AreEqual(AffKey, key.Val);
}
@@ -751,9 +751,9 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Test portable service.
+ /// Test binary service.
/// </summary>
- private class TestIgniteServicePortable : TestIgniteServiceSerializable, IBinarizable
+ private class TestIgniteServiceBinarizable : TestIgniteServiceSerializable, IBinarizable
{
/** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
@@ -769,9 +769,9 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Test portable service with exceptions in marshalling.
+ /// Test binary service with exceptions in marshalling.
/// </summary>
- private class TestIgniteServicePortableErr : TestIgniteServiceSerializable, IBinarizable
+ private class TestIgniteServiceBinarizableErr : TestIgniteServiceSerializable, IBinarizable
{
/** */
public bool ThrowOnWrite { get; set; }
@@ -813,9 +813,9 @@ namespace Apache.Ignite.Core.Tests.Services
}
/// <summary>
- /// Portable object.
+ /// Binary object.
/// </summary>
- private class PortableObject
+ private class BinarizableObject
{
public int Val { get; set; }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
index c75f003..a95ecd7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TypeResolverTest.cs
@@ -38,16 +38,16 @@ namespace Apache.Ignite.Core.Tests
{
var testTypes = new[]
{
- typeof (TestGenericPortable<int>),
- typeof (TestGenericPortable<string>),
- typeof (TestGenericPortable<TestGenericPortable<int>>),
- typeof (TestGenericPortable<List<Tuple<int, string>>>),
- typeof (TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>),
- typeof (List<TestGenericPortable<List<TestGenericPortable<List<Tuple<int, string>>>>>>),
- typeof (TestGenericPortable<int, string>),
- typeof (TestGenericPortable<int, TestGenericPortable<string>>),
- typeof (TestGenericPortable<int, string, Type>),
- typeof (TestGenericPortable<int, string, TestGenericPortable<int, string, Type>>)
+ typeof (TestGenericBinarizable<int>),
+ typeof (TestGenericBinarizable<string>),
+ typeof (TestGenericBinarizable<TestGenericBinarizable<int>>),
+ typeof (TestGenericBinarizable<List<Tuple<int, string>>>),
+ typeof (TestGenericBinarizable<List<TestGenericBinarizable<List<Tuple<int, string>>>>>),
+ typeof (List<TestGenericBinarizable<List<TestGenericBinarizable<List<Tuple<int, string>>>>>>),
+ typeof (TestGenericBinarizable<int, string>),
+ typeof (TestGenericBinarizable<int, TestGenericBinarizable<string>>),
+ typeof (TestGenericBinarizable<int, string, Type>),
+ typeof (TestGenericBinarizable<int, string, TestGenericBinarizable<int, string, Type>>)
};
foreach (var type in testTypes)
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 12abefb..98ea106 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -604,7 +604,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
private void DataStreamerStreamReceiverInvoke(void* target, long rcvPtr, void* cache, long memPtr,
- byte keepPortable)
+ byte keepBinary)
{
SafeCall(() =>
{
@@ -612,14 +612,14 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream, BinaryMode.ForceBinary);
- var portableReceiver = reader.ReadObject<BinaryObject>();
+ var binaryReceiver = reader.ReadObject<BinaryObject>();
var receiver = _handleRegistry.Get<StreamReceiverHolder>(rcvPtr) ??
- portableReceiver.Deserialize<StreamReceiverHolder>();
+ binaryReceiver.Deserialize<StreamReceiverHolder>();
if (receiver != null)
receiver.Receive(_ignite, new UnmanagedNonReleaseableTarget(_ctx, cache), stream,
- keepPortable != 0);
+ keepBinary != 0);
}
});
}
@@ -893,12 +893,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream);
- bool srvKeepPortable = reader.ReadBoolean();
+ bool srvKeepBinary = reader.ReadBoolean();
var svc = reader.ReadObject<IService>();
ResourceProcessor.Inject(svc, _ignite);
- svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+ svc.Init(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary)));
return _handleRegistry.Allocate(svc);
}
@@ -915,10 +915,10 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream);
- bool srvKeepPortable = reader.ReadBoolean();
+ bool srvKeepBinary = reader.ReadBoolean();
svc.Execute(new ServiceContext(
- _ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+ _ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary)));
}
});
}
@@ -935,9 +935,9 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream);
- bool srvKeepPortable = reader.ReadBoolean();
+ bool srvKeepBinary = reader.ReadBoolean();
- svc.Cancel(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepPortable)));
+ svc.Cancel(new ServiceContext(_ignite.Marshaller.StartUnmarshal(stream, srvKeepBinary)));
}
}
finally
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/examples/Config/example-cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Config/example-cache-query.xml b/modules/platforms/dotnet/examples/Config/example-cache-query.xml
index 7755645..a3b854b 100644
--- a/modules/platforms/dotnet/examples/Config/example-cache-query.xml
+++ b/modules/platforms/dotnet/examples/Config/example-cache-query.xml
@@ -33,12 +33,12 @@
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
<property name="types">
<list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Account</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Address</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Employee</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.EmployeeKey</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Organization</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.OrganizationType</value>
</list>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/examples/Config/example-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Config/example-cache.xml b/modules/platforms/dotnet/examples/Config/example-cache.xml
index d31938a..21a6a76 100644
--- a/modules/platforms/dotnet/examples/Config/example-cache.xml
+++ b/modules/platforms/dotnet/examples/Config/example-cache.xml
@@ -32,12 +32,12 @@
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
<property name="types">
<list>
- <value>Apache.Ignite.Examples.Dll.Portable.Account</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Address</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Employee</value>
- <value>Apache.Ignite.Examples.Dll.Portable.EmployeeKey</value>
- <value>Apache.Ignite.Examples.Dll.Portable.Organization</value>
- <value>Apache.Ignite.Examples.Dll.Portable.OrganizationType</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Account</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Address</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Employee</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.EmployeeKey</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.Organization</value>
+ <value>Apache.Ignite.ExamplesDll.Binary.OrganizationType</value>
</list>
</property>
</bean>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 07c1847..d52ae4c 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -763,6 +763,7 @@
<exclude>**/*.fxcop</exclude>
<exclude>**/*.metaproj</exclude>
<exclude>**/*.metaproj.tmp</exclude>
+ <exclude>**/*.nunit</exclude>
<exclude>**/teamcity_boost.cpp</exclude>
<exclude>**/teamcity_messages.h</exclude>
<exclude>**/teamcity_messages.cpp</exclude>
[25/55] [abbrv] ignite git commit: IGNITE-1917: Binary protocol
performance optimizations.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 8543ce6..3edf980 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -69,7 +69,7 @@ public class PortableClassDescriptor {
private final BinaryIdMapper idMapper;
/** */
- private final Mode mode;
+ private final BinaryWriteMode mode;
/** */
private final boolean userType;
@@ -87,7 +87,7 @@ public class PortableClassDescriptor {
private final Constructor<?> ctor;
/** */
- private final Collection<FieldInfo> fields;
+ private final BinaryFieldAccessor[] fields;
/** */
private final Method writeReplaceMtd;
@@ -99,7 +99,7 @@ public class PortableClassDescriptor {
private final Map<String, Integer> stableFieldsMeta;
/** Object schemas. Initialized only for serializable classes and contains only 1 entry. */
- private final Collection<PortableSchema> stableSchemas;
+ private final PortableSchema stableSchema;
/** Schema registry. */
private final PortableSchemaRegistry schemaReg;
@@ -167,9 +167,9 @@ public class PortableClassDescriptor {
useOptMarshaller = !predefined && initUseOptimizedMarshallerFlag();
if (excluded)
- mode = Mode.EXCLUSION;
+ mode = BinaryWriteMode.EXCLUSION;
else
- mode = serializer != null ? Mode.PORTABLE : mode(cls);
+ mode = serializer != null ? BinaryWriteMode.PORTABLE : PortableUtils.mode(cls);
switch (mode) {
case BYTE:
@@ -210,7 +210,7 @@ public class PortableClassDescriptor {
ctor = null;
fields = null;
stableFieldsMeta = null;
- stableSchemas = null;
+ stableSchema = null;
break;
@@ -219,13 +219,13 @@ public class PortableClassDescriptor {
ctor = constructor(cls);
fields = null;
stableFieldsMeta = null;
- stableSchemas = null;
+ stableSchema = null;
break;
case OBJECT:
ctor = constructor(cls);
- fields = new ArrayList<>();
+ ArrayList<BinaryFieldAccessor> fields0 = new ArrayList<>();
stableFieldsMeta = metaDataEnabled ? new HashMap<String, Integer>() : null;
PortableSchema.Builder schemaBuilder = PortableSchema.Builder.newBuilder();
@@ -250,20 +250,22 @@ public class PortableClassDescriptor {
if (!ids.add(fieldId))
throw new BinaryObjectException("Duplicate field ID: " + name);
- FieldInfo fieldInfo = new FieldInfo(f, fieldId);
+ BinaryFieldAccessor fieldInfo = BinaryFieldAccessor.create(f, fieldId);
- fields.add(fieldInfo);
+ fields0.add(fieldInfo);
schemaBuilder.addField(fieldId);
if (metaDataEnabled)
- stableFieldsMeta.put(name, fieldInfo.fieldMode().typeId());
+ stableFieldsMeta.put(name, fieldInfo.mode().typeId());
}
}
}
-
- stableSchemas = Collections.singleton(schemaBuilder.build());
-
+
+ fields = fields0.toArray(new BinaryFieldAccessor[fields0.size()]);
+
+ stableSchema = schemaBuilder.build();
+
break;
default:
@@ -271,7 +273,8 @@ public class PortableClassDescriptor {
throw new BinaryObjectException("Invalid mode: " + mode);
}
- if (mode == Mode.PORTABLE || mode == Mode.EXTERNALIZABLE || mode == Mode.OBJECT) {
+ if (mode == BinaryWriteMode.PORTABLE || mode == BinaryWriteMode.EXTERNALIZABLE ||
+ mode == BinaryWriteMode.OBJECT) {
readResolveMtd = U.findNonPublicMethod(cls, "readResolve");
writeReplaceMtd = U.findNonPublicMethod(cls, "writeReplace");
}
@@ -310,10 +313,10 @@ public class PortableClassDescriptor {
}
/**
- * @return Schemas.
+ * @return Schema.
*/
- Collection<PortableSchema> schemas() {
- return stableSchemas;
+ PortableSchema schema() {
+ return stableSchema;
}
/**
@@ -380,52 +383,46 @@ public class PortableClassDescriptor {
assert obj != null;
assert writer != null;
+ writer.typeId(typeId);
+
switch (mode) {
case BYTE:
- writer.doWriteByte(GridPortableMarshaller.BYTE);
- writer.doWriteByte((byte)obj);
+ writer.writeByteFieldPrimitive((byte) obj);
break;
case SHORT:
- writer.doWriteByte(GridPortableMarshaller.SHORT);
- writer.doWriteShort((short)obj);
+ writer.writeShortFieldPrimitive((short)obj);
break;
case INT:
- writer.doWriteByte(GridPortableMarshaller.INT);
- writer.doWriteInt((int)obj);
+ writer.writeIntFieldPrimitive((int) obj);
break;
case LONG:
- writer.doWriteByte(GridPortableMarshaller.LONG);
- writer.doWriteLong((long)obj);
+ writer.writeLongFieldPrimitive((long) obj);
break;
case FLOAT:
- writer.doWriteByte(GridPortableMarshaller.FLOAT);
- writer.doWriteFloat((float)obj);
+ writer.writeFloatFieldPrimitive((float) obj);
break;
case DOUBLE:
- writer.doWriteByte(GridPortableMarshaller.DOUBLE);
- writer.doWriteDouble((double)obj);
+ writer.writeDoubleFieldPrimitive((double) obj);
break;
case CHAR:
- writer.doWriteByte(GridPortableMarshaller.CHAR);
- writer.doWriteChar((char)obj);
+ writer.writeCharFieldPrimitive((char) obj);
break;
case BOOLEAN:
- writer.doWriteByte(GridPortableMarshaller.BOOLEAN);
- writer.doWriteBoolean((boolean)obj);
+ writer.writeBooleanFieldPrimitive((boolean) obj);
break;
@@ -623,9 +620,11 @@ public class PortableClassDescriptor {
case OBJECT:
if (writeHeader(obj, writer)) {
try {
- for (FieldInfo info : fields)
+ for (BinaryFieldAccessor info : fields)
info.write(obj, writer);
+ writer.schemaId(stableSchema.schemaId());
+
writer.postWrite(userType);
}
finally {
@@ -683,7 +682,7 @@ public class PortableClassDescriptor {
reader.setHandler(res);
- for (FieldInfo info : fields)
+ for (BinaryFieldAccessor info : fields)
info.read(res, reader);
break;
@@ -723,12 +722,22 @@ public class PortableClassDescriptor {
if (writer.tryWriteAsHandle(obj))
return false;
- PortableUtils.writeHeader(
- writer,
- registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID,
- obj instanceof CacheObjectImpl ? 0 : obj.hashCode(),
- registered ? null : cls.getName()
- );
+ if (registered) {
+ PortableUtils.writeHeader(
+ writer,
+ typeId,
+ obj instanceof CacheObjectImpl ? 0 : obj.hashCode(),
+ null
+ );
+ }
+ else {
+ PortableUtils.writeHeader(
+ writer,
+ GridPortableMarshaller.UNREGISTERED_TYPE_ID,
+ obj instanceof CacheObjectImpl ? 0 : obj.hashCode(),
+ cls.getName()
+ );
+ }
return true;
}
@@ -794,658 +803,4 @@ public class PortableClassDescriptor {
return use;
}
-
- /**
- * @param cls Class.
- * @return Mode.
- */
- @SuppressWarnings("IfMayBeConditional")
- private static Mode mode(Class<?> cls) {
- assert cls != null;
-
- if (cls == byte.class || cls == Byte.class)
- return Mode.BYTE;
- else if (cls == short.class || cls == Short.class)
- return Mode.SHORT;
- else if (cls == int.class || cls == Integer.class)
- return Mode.INT;
- else if (cls == long.class || cls == Long.class)
- return Mode.LONG;
- else if (cls == float.class || cls == Float.class)
- return Mode.FLOAT;
- else if (cls == double.class || cls == Double.class)
- return Mode.DOUBLE;
- else if (cls == char.class || cls == Character.class)
- return Mode.CHAR;
- else if (cls == boolean.class || cls == Boolean.class)
- return Mode.BOOLEAN;
- else if (cls == BigDecimal.class)
- return Mode.DECIMAL;
- else if (cls == String.class)
- return Mode.STRING;
- else if (cls == UUID.class)
- return Mode.UUID;
- else if (cls == Date.class)
- return Mode.DATE;
- else if (cls == Timestamp.class)
- return Mode.TIMESTAMP;
- else if (cls == byte[].class)
- return Mode.BYTE_ARR;
- else if (cls == short[].class)
- return Mode.SHORT_ARR;
- else if (cls == int[].class)
- return Mode.INT_ARR;
- else if (cls == long[].class)
- return Mode.LONG_ARR;
- else if (cls == float[].class)
- return Mode.FLOAT_ARR;
- else if (cls == double[].class)
- return Mode.DOUBLE_ARR;
- else if (cls == char[].class)
- return Mode.CHAR_ARR;
- else if (cls == boolean[].class)
- return Mode.BOOLEAN_ARR;
- else if (cls == BigDecimal[].class)
- return Mode.DECIMAL_ARR;
- else if (cls == String[].class)
- return Mode.STRING_ARR;
- else if (cls == UUID[].class)
- return Mode.UUID_ARR;
- else if (cls == Date[].class)
- return Mode.DATE_ARR;
- else if (cls == Timestamp[].class)
- return Mode.TIMESTAMP_ARR;
- else if (cls.isArray())
- return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJECT_ARR;
- else if (cls == BinaryObjectImpl.class)
- return Mode.PORTABLE_OBJ;
- else if (Binarylizable.class.isAssignableFrom(cls))
- return Mode.PORTABLE;
- else if (Externalizable.class.isAssignableFrom(cls))
- return Mode.EXTERNALIZABLE;
- else if (Map.Entry.class.isAssignableFrom(cls))
- return Mode.MAP_ENTRY;
- else if (Collection.class.isAssignableFrom(cls))
- return Mode.COL;
- else if (Map.class.isAssignableFrom(cls))
- return Mode.MAP;
- else if (cls == BinaryObjectImpl.class)
- return Mode.PORTABLE_OBJ;
- else if (cls.isEnum())
- return Mode.ENUM;
- else if (cls == Class.class)
- return Mode.CLASS;
- else
- return Mode.OBJECT;
- }
-
- /** */
- private static class FieldInfo {
- /** */
- private final Field field;
-
- /** */
- private final int id;
-
- /** */
- private final Mode mode;
-
- /**
- * @param field Field.
- * @param id Field ID.
- */
- private FieldInfo(Field field, int id) {
- assert field != null;
-
- this.field = field;
- this.id = id;
-
- Class<?> type = field.getType();
-
- mode = mode(type);
- }
-
- /**
- * @return Field mode.
- */
- public Mode fieldMode() {
- return mode;
- }
-
- /**
- * @param obj Object.
- * @param writer Writer.
- * @throws BinaryObjectException In case of error.
- */
- public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
- assert obj != null;
- assert writer != null;
-
- writer.writeFieldId(id);
-
- Object val;
-
- try {
- val = field.get(obj);
- }
- catch (IllegalAccessException e) {
- throw new BinaryObjectException("Failed to get value for field: " + field, e);
- }
-
- switch (mode) {
- case BYTE:
- writer.writeByteField((Byte)val);
-
- break;
-
- case SHORT:
- writer.writeShortField((Short)val);
-
- break;
-
- case INT:
- writer.writeIntField((Integer)val);
-
- break;
-
- case LONG:
- writer.writeLongField((Long)val);
-
- break;
-
- case FLOAT:
- writer.writeFloatField((Float)val);
-
- break;
-
- case DOUBLE:
- writer.writeDoubleField((Double)val);
-
- break;
-
- case CHAR:
- writer.writeCharField((Character)val);
-
- break;
-
- case BOOLEAN:
- writer.writeBooleanField((Boolean)val);
-
- break;
-
- case DECIMAL:
- writer.writeDecimalField((BigDecimal)val);
-
- break;
-
- case STRING:
- writer.writeStringField((String)val);
-
- break;
-
- case UUID:
- writer.writeUuidField((UUID)val);
-
- break;
-
- case DATE:
- writer.writeDateField((Date)val);
-
- break;
-
- case TIMESTAMP:
- writer.writeTimestampField((Timestamp)val);
-
- break;
-
- case BYTE_ARR:
- writer.writeByteArrayField((byte[])val);
-
- break;
-
- case SHORT_ARR:
- writer.writeShortArrayField((short[]) val);
-
- break;
-
- case INT_ARR:
- writer.writeIntArrayField((int[]) val);
-
- break;
-
- case LONG_ARR:
- writer.writeLongArrayField((long[]) val);
-
- break;
-
- case FLOAT_ARR:
- writer.writeFloatArrayField((float[]) val);
-
- break;
-
- case DOUBLE_ARR:
- writer.writeDoubleArrayField((double[]) val);
-
- break;
-
- case CHAR_ARR:
- writer.writeCharArrayField((char[]) val);
-
- break;
-
- case BOOLEAN_ARR:
- writer.writeBooleanArrayField((boolean[]) val);
-
- break;
-
- case DECIMAL_ARR:
- writer.writeDecimalArrayField((BigDecimal[]) val);
-
- break;
-
- case STRING_ARR:
- writer.writeStringArrayField((String[]) val);
-
- break;
-
- case UUID_ARR:
- writer.writeUuidArrayField((UUID[]) val);
-
- break;
-
- case DATE_ARR:
- writer.writeDateArrayField((Date[]) val);
-
- break;
-
- case TIMESTAMP_ARR:
- writer.writeTimestampArrayField((Timestamp[]) val);
-
- break;
-
- case OBJECT_ARR:
- writer.writeObjectArrayField((Object[])val);
-
- break;
-
- case COL:
- writer.writeCollectionField((Collection<?>)val);
-
- break;
-
- case MAP:
- writer.writeMapField((Map<?, ?>)val);
-
- break;
-
- case MAP_ENTRY:
- writer.writeMapEntryField((Map.Entry<?, ?>)val);
-
- break;
-
- case PORTABLE_OBJ:
- writer.writePortableObjectField((BinaryObjectImpl)val);
-
- break;
-
- case ENUM:
- writer.writeEnumField((Enum<?>)val);
-
- break;
-
- case ENUM_ARR:
- writer.writeEnumArrayField((Object[])val);
-
- break;
-
- case PORTABLE:
- case EXTERNALIZABLE:
- case OBJECT:
- writer.writeObjectField(val);
-
- break;
-
- case CLASS:
- writer.writeClassField((Class)val);
-
- break;
-
- default:
- assert false : "Invalid mode: " + mode;
- }
- }
-
- /**
- * @param obj Object.
- * @param reader Reader.
- * @throws BinaryObjectException In case of error.
- */
- public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
- Object val = null;
-
- switch (mode) {
- case BYTE:
- val = reader.readByte(id);
-
- break;
-
- case SHORT:
- val = reader.readShort(id);
-
- break;
-
- case INT:
- val = reader.readInt(id);
-
- break;
-
- case LONG:
- val = reader.readLong(id);
-
- break;
-
- case FLOAT:
- val = reader.readFloat(id);
-
- break;
-
- case DOUBLE:
- val = reader.readDouble(id);
-
- break;
-
- case CHAR:
- val = reader.readChar(id);
-
- break;
-
- case BOOLEAN:
- val = reader.readBoolean(id);
-
- break;
-
- case DECIMAL:
- val = reader.readDecimal(id);
-
- break;
-
- case STRING:
- val = reader.readString(id);
-
- break;
-
- case UUID:
- val = reader.readUuid(id);
-
- break;
-
- case DATE:
- val = reader.readDate(id);
-
- break;
-
- case TIMESTAMP:
- val = reader.readTimestamp(id);
-
- break;
-
- case BYTE_ARR:
- val = reader.readByteArray(id);
-
- break;
-
- case SHORT_ARR:
- val = reader.readShortArray(id);
-
- break;
-
- case INT_ARR:
- val = reader.readIntArray(id);
-
- break;
-
- case LONG_ARR:
- val = reader.readLongArray(id);
-
- break;
-
- case FLOAT_ARR:
- val = reader.readFloatArray(id);
-
- break;
-
- case DOUBLE_ARR:
- val = reader.readDoubleArray(id);
-
- break;
-
- case CHAR_ARR:
- val = reader.readCharArray(id);
-
- break;
-
- case BOOLEAN_ARR:
- val = reader.readBooleanArray(id);
-
- break;
-
- case DECIMAL_ARR:
- val = reader.readDecimalArray(id);
-
- break;
-
- case STRING_ARR:
- val = reader.readStringArray(id);
-
- break;
-
- case UUID_ARR:
- val = reader.readUuidArray(id);
-
- break;
-
- case DATE_ARR:
- val = reader.readDateArray(id);
-
- break;
-
- case TIMESTAMP_ARR:
- val = reader.readTimestampArray(id);
-
- break;
-
- case OBJECT_ARR:
- val = reader.readObjectArray(id);
-
- break;
-
- case COL:
- val = reader.readCollection(id, null);
-
- break;
-
- case MAP:
- val = reader.readMap(id, null);
-
- break;
-
- case MAP_ENTRY:
- val = reader.readMapEntry(id);
-
- break;
-
- case PORTABLE_OBJ:
- val = reader.readPortableObject(id);
-
- break;
-
- case ENUM:
- val = reader.readEnum(id, field.getType());
-
- break;
-
- case ENUM_ARR:
- val = reader.readEnumArray(id, field.getType().getComponentType());
-
- break;
-
- case PORTABLE:
- case EXTERNALIZABLE:
- case OBJECT:
- val = reader.readObject(id);
-
- break;
-
- case CLASS:
- val = reader.readClass(id);
-
- break;
-
- default:
- assert false : "Invalid mode: " + mode;
- }
-
- try {
- if (val != null || !field.getType().isPrimitive())
- field.set(obj, val);
- }
- catch (IllegalAccessException e) {
- throw new BinaryObjectException("Failed to set value for field: " + field, e);
- }
- }
- }
-
- /** */
- enum Mode {
- /** */
- BYTE(GridPortableMarshaller.BYTE),
-
- /** */
- SHORT(GridPortableMarshaller.SHORT),
-
- /** */
- INT(GridPortableMarshaller.INT),
-
- /** */
- LONG(GridPortableMarshaller.LONG),
-
- /** */
- FLOAT(GridPortableMarshaller.FLOAT),
-
- /** */
- DOUBLE(GridPortableMarshaller.DOUBLE),
-
- /** */
- CHAR(GridPortableMarshaller.CHAR),
-
- /** */
- BOOLEAN(GridPortableMarshaller.BOOLEAN),
-
- /** */
- DECIMAL(GridPortableMarshaller.DECIMAL),
-
- /** */
- STRING(GridPortableMarshaller.STRING),
-
- /** */
- UUID(GridPortableMarshaller.UUID),
-
- /** */
- DATE(GridPortableMarshaller.DATE),
-
- /** */
- TIMESTAMP(GridPortableMarshaller.TIMESTAMP),
-
- /** */
- BYTE_ARR(GridPortableMarshaller.BYTE_ARR),
-
- /** */
- SHORT_ARR(GridPortableMarshaller.SHORT_ARR),
-
- /** */
- INT_ARR(GridPortableMarshaller.INT_ARR),
-
- /** */
- LONG_ARR(GridPortableMarshaller.LONG_ARR),
-
- /** */
- FLOAT_ARR(GridPortableMarshaller.FLOAT_ARR),
-
- /** */
- DOUBLE_ARR(GridPortableMarshaller.DOUBLE_ARR),
-
- /** */
- CHAR_ARR(GridPortableMarshaller.CHAR_ARR),
-
- /** */
- BOOLEAN_ARR(GridPortableMarshaller.BOOLEAN_ARR),
-
- /** */
- DECIMAL_ARR(GridPortableMarshaller.DECIMAL_ARR),
-
- /** */
- STRING_ARR(GridPortableMarshaller.STRING_ARR),
-
- /** */
- UUID_ARR(GridPortableMarshaller.UUID_ARR),
-
- /** */
- DATE_ARR(GridPortableMarshaller.DATE_ARR),
-
- /** */
- TIMESTAMP_ARR(GridPortableMarshaller.TIMESTAMP_ARR),
-
- /** */
- OBJECT_ARR(GridPortableMarshaller.OBJ_ARR),
-
- /** */
- COL(GridPortableMarshaller.COL),
-
- /** */
- MAP(GridPortableMarshaller.MAP),
-
- /** */
- MAP_ENTRY(GridPortableMarshaller.MAP_ENTRY),
-
- /** */
- PORTABLE_OBJ(GridPortableMarshaller.OBJ),
-
- /** */
- ENUM(GridPortableMarshaller.ENUM),
-
- /** */
- ENUM_ARR(GridPortableMarshaller.ENUM_ARR),
-
- /** */
- CLASS(GridPortableMarshaller.CLASS),
-
- /** */
- PORTABLE(GridPortableMarshaller.PORTABLE_OBJ),
-
- /** */
- EXTERNALIZABLE(GridPortableMarshaller.OBJ),
-
- /** */
- OBJECT(GridPortableMarshaller.OBJ),
-
- /** */
- EXCLUSION(GridPortableMarshaller.OBJ);
-
- /** */
- private final int typeId;
-
- /**
- * @param typeId Type ID.
- */
- Mode(int typeId) {
- this.typeId = typeId;
- }
-
- /**
- * @return Type ID.
- */
- int typeId() {
- return typeId;
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index afc23e1..e3caba4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -31,6 +31,7 @@ import java.net.URLClassLoader;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
@@ -573,8 +574,9 @@ public class PortableContext implements Externalizable {
mappers.putIfAbsent(typeId, idMapper);
- metaHnd.addMeta(typeId,
- new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null, desc.schemas()).wrap(this));
+ Collection<PortableSchema> schemas = desc.schema() != null ? Collections.singleton(desc.schema()) : null;
+
+ metaHnd.addMeta(typeId, new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null, schemas).wrap(this));
return desc;
}
@@ -782,7 +784,7 @@ public class PortableContext implements Externalizable {
);
fieldsMeta = desc.fieldsMeta();
- schemas = desc.schemas();
+ schemas = desc.schema() != null ? Collections.singleton(desc.schema()) : null;
if (IgniteUtils.detectClassLoader(cls).equals(dfltLdr))
userTypes.put(id, desc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java
deleted file mode 100644
index 869f81d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderContext.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.jetbrains.annotations.Nullable;
-
-/**
-* Reader context.
-*/
-class PortableReaderContext {
- /** */
- private Object oHandles;
-
- /** */
- private Map<Integer, BinaryObject> poHandles;
-
- /**
- * @param handle Handle.
- * @param obj Object.
- */
- @SuppressWarnings("unchecked")
- void setObjectHandler(int handle, Object obj) {
- assert obj != null;
-
- if (oHandles == null)
- oHandles = new IgniteBiTuple(handle, obj);
- else if (oHandles instanceof IgniteBiTuple) {
- Map map = new HashMap(3, 1.0f);
-
- IgniteBiTuple t = (IgniteBiTuple)oHandles;
-
- map.put(t.getKey(), t.getValue());
- map.put(handle, obj);
-
- oHandles = map;
- }
- else
- ((Map)oHandles).put(handle, obj);
- }
-
- /**
- * @param handle Handle.
- * @param po Portable object.
- */
- void setPortableHandler(int handle, BinaryObject po) {
- assert po != null;
-
- if (poHandles == null)
- poHandles = new HashMap<>(3, 1.0f);
-
- poHandles.put(handle, po);
- }
-
- /**
- * @param handle Handle.
- * @return Object.
- */
- @Nullable Object getObjectByHandle(int handle) {
- if (oHandles != null) {
- if (oHandles instanceof IgniteBiTuple) {
- IgniteBiTuple t = (IgniteBiTuple)oHandles;
-
- if ((int)t.get1() == handle)
- return t.get2();
- }
- else
- return ((Map)oHandles).get(handle);
- }
-
- return null;
- }
-
- /**
- * @param handle Handle.
- * @return Object.
- */
- @Nullable BinaryObject getPortableByHandle(int handle) {
- return poHandles != null ? poHandles.get(handle) : null;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PortableReaderContext.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
index 86ca5f8..72a96b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
@@ -17,14 +17,11 @@
package org.apache.ignite.internal.portable;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -41,14 +38,26 @@ public class PortableSchema implements Externalizable {
/** Order returned if field is not found. */
public static final int ORDER_NOT_FOUND = -1;
- /** Inline flag. */
- private boolean inline;
+ /** Minimum sensible size. */
+ private static final int MAP_MIN_SIZE = 32;
- /** Map with ID to order. */
- private HashMap<Integer, Integer> idToOrder;
+ /** Empty cell. */
+ private static final int MAP_EMPTY = 0;
+
+ /** Schema ID. */
+ private int schemaId;
/** IDs depending on order. */
- private ArrayList<Integer> ids;
+ private int[] ids;
+
+ /** Interned names of associated fields. */
+ private String[] names;
+
+ /** ID-to-order data. */
+ private int[] idToOrderData;
+
+ /** ID-to-order mask. */
+ private int idToOrderMask;
/** ID 1. */
private int id0;
@@ -62,21 +71,6 @@ public class PortableSchema implements Externalizable {
/** ID 4. */
private int id3;
- /** ID 1. */
- private int id4;
-
- /** ID 2. */
- private int id5;
-
- /** ID 3. */
- private int id6;
-
- /** ID 4. */
- private int id7;
-
- /** Schema ID. */
- private int schemaId;
-
/**
* {@link Externalizable} support.
*/
@@ -91,39 +85,11 @@ public class PortableSchema implements Externalizable {
* @param fieldIds Field IDs.
*/
private PortableSchema(int schemaId, List<Integer> fieldIds) {
- this.schemaId = schemaId;
+ assert fieldIds != null;
- if (fieldIds.size() <= 8) {
- inline = true;
-
- Iterator<Integer> iter = fieldIds.iterator();
-
- id0 = iter.hasNext() ? iter.next() : 0;
- id1 = iter.hasNext() ? iter.next() : 0;
- id2 = iter.hasNext() ? iter.next() : 0;
- id3 = iter.hasNext() ? iter.next() : 0;
- id4 = iter.hasNext() ? iter.next() : 0;
- id5 = iter.hasNext() ? iter.next() : 0;
- id6 = iter.hasNext() ? iter.next() : 0;
- id7 = iter.hasNext() ? iter.next() : 0;
-
- idToOrder = null;
- }
- else {
- inline = false;
-
- id0 = id1 = id2 = id3 = id4 = id5 = id6 = id7 = 0;
-
- ids = new ArrayList<>();
- idToOrder = new HashMap<>();
-
- for (int i = 0; i < fieldIds.size(); i++) {
- int fieldId = fieldIds.get(i);
+ this.schemaId = schemaId;
- ids.add(fieldId);
- idToOrder.put(fieldId, i);
- }
- }
+ initialize(fieldIds);
}
/**
@@ -134,46 +100,51 @@ public class PortableSchema implements Externalizable {
}
/**
- * Get field ID by order in footer.
+ * Try speculatively confirming order for the given field name.
*
- * @param order Order.
+ * @param expOrder Expected order.
+ * @param expName Expected name.
* @return Field ID.
*/
- public int fieldId(int order) {
- if (inline) {
- switch (order) {
- case 0:
- return id0;
+ @SuppressWarnings("StringEquality")
+ public Confirmation confirmOrder(int expOrder, String expName) {
+ assert expName != null;
- case 1:
- return id1;
+ if (expOrder < names.length) {
+ String name = names[expOrder];
- case 2:
- return id2;
+ // Note that we use only reference equality assuming that field names are interned literals.
+ if (name == expName)
+ return Confirmation.CONFIRMED;
- case 3:
- return id3;
-
- case 4:
- return id4;
-
- case 5:
- return id5;
+ if (name == null)
+ return Confirmation.CLARIFY;
+ }
- case 6:
- return id6;
+ return Confirmation.REJECTED;
+ }
- case 7:
- return id7;
+ /**
+ * Add field name.
+ *
+ * @param order Order.
+ * @param name Name.
+ */
+ public void clarifyFieldName(int order, String name) {
+ assert name != null;
+ assert order < names.length;
- default:
- assert false : "Should not reach here.";
+ names[order] = name.intern();
+ }
- return 0;
- }
- }
- else
- return ids.get(order);
+ /**
+ * Get field ID by order in footer.
+ *
+ * @param order Order.
+ * @return Field ID.
+ */
+ public int fieldId(int order) {
+ return order < ids.length ? ids[order] : 0;
}
/**
@@ -183,7 +154,7 @@ public class PortableSchema implements Externalizable {
* @return Offset or {@code 0} if there is no such field.
*/
public int order(int id) {
- if (inline) {
+ if (idToOrderData == null) {
if (id == id0)
return 0;
@@ -196,24 +167,34 @@ public class PortableSchema implements Externalizable {
if (id == id3)
return 3;
- if (id == id4)
- return 4;
+ return ORDER_NOT_FOUND;
+ }
+ else {
+ int idx = (id & idToOrderMask) << 1;
+
+ int curId = idToOrderData[idx];
- if (id == id5)
- return 5;
+ if (id == curId) // Hit!
+ return idToOrderData[idx + 1];
+ else if (curId == MAP_EMPTY) // No such ID!
+ return ORDER_NOT_FOUND;
+ else {
+ // Unlikely collision scenario.
+ for (int i = 2; i < idToOrderData.length; i += 2) {
+ int newIdx = (idx + i) % idToOrderData.length;
- if (id == id6)
- return 6;
+ assert newIdx < idToOrderData.length - 1;
- if (id == id7)
- return 7;
+ curId = idToOrderData[newIdx];
- return ORDER_NOT_FOUND;
- }
- else {
- Integer order = idToOrder.get(id);
+ if (id == curId)
+ return idToOrderData[newIdx + 1];
+ else if (curId == MAP_EMPTY)
+ return ORDER_NOT_FOUND;
+ }
- return order != null ? order : ORDER_NOT_FOUND;
+ return ORDER_NOT_FOUND;
+ }
}
}
@@ -231,59 +212,173 @@ public class PortableSchema implements Externalizable {
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(schemaId);
- if (inline) {
- out.writeBoolean(true);
-
- out.writeInt(id0);
- out.writeInt(id1);
- out.writeInt(id2);
- out.writeInt(id3);
- out.writeInt(id4);
- out.writeInt(id5);
- out.writeInt(id6);
- out.writeInt(id7);
- }
- else {
- out.writeBoolean(false);
-
- out.writeInt(ids.size());
+ out.writeInt(ids.length);
- for (Integer id : ids)
- out.writeInt(id);
- }
+ for (Integer id : ids)
+ out.writeInt(id);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
schemaId = in.readInt();
- if (in.readBoolean()) {
- inline = true;
-
- id0 = in.readInt();
- id1 = in.readInt();
- id2 = in.readInt();
- id3 = in.readInt();
- id4 = in.readInt();
- id5 = in.readInt();
- id6 = in.readInt();
- id7 = in.readInt();
+ int idsCnt = in.readInt();
+
+ List<Integer> fieldIds = new ArrayList<>(idsCnt);
+
+ for (int i = 0; i < idsCnt; i++)
+ fieldIds.add(in.readInt());
+
+ initialize(fieldIds);
+ }
+
+ /**
+ * Parse values.
+ *
+ * @param vals Values.
+ * @param size Proposed result size.
+ * @return Parse result.
+ */
+ private static ParseResult parse(int[] vals, int size) {
+ int mask = maskForPowerOfTwo(size);
+
+ int totalSize = size * 2;
+
+ int[] data = new int[totalSize];
+ int collisions = 0;
+
+ for (int order = 0; order < vals.length; order++) {
+ int id = vals[order];
+
+ assert id != 0;
+
+ int idIdx = (id & mask) << 1;
+
+ if (data[idIdx] == 0) {
+ // Found empty slot.
+ data[idIdx] = id;
+ data[idIdx + 1] = order;
+ }
+ else {
+ // Collision!
+ collisions++;
+
+ boolean placeFound = false;
+
+ for (int i = 2; i < totalSize; i += 2) {
+ int newIdIdx = (idIdx + i) % totalSize;
+
+ if (data[newIdIdx] == 0) {
+ data[newIdIdx] = id;
+ data[newIdIdx + 1] = order;
+
+ placeFound = true;
+
+ break;
+ }
+ }
+
+ assert placeFound : "Should always have a place for entry!";
+ }
+ }
+
+ return new ParseResult(data, collisions);
+ }
+
+ /**
+ * Get next power of two which greater or equal to the given number.
+ * This implementation is not meant to be very efficient, so it is expected to be used relatively rare.
+ *
+ * @param val Number
+ * @return Nearest pow2.
+ */
+ private static int nextPowerOfTwo(int val) {
+ int res = 1;
+
+ while (res < val)
+ res = res << 1;
+
+ if (res < 0)
+ throw new IllegalArgumentException("Value is too big to find positive pow2: " + val);
+
+ return res;
+ }
+
+ /**
+ * Calculate mask for the given value which is a power of two.
+ *
+ * @param val Value.
+ * @return Mask.
+ */
+ private static int maskForPowerOfTwo(int val) {
+ int mask = 0;
+ int comparand = 1;
+
+ while (comparand < val) {
+ mask |= comparand;
+
+ comparand <<= 1;
+ }
+
+ return mask;
+ }
+
+ /**
+ * Initialization routine.
+ *
+ * @param fieldIds Field IDs.
+ */
+ private void initialize(List<Integer> fieldIds) {
+ ids = new int[fieldIds.size()];
+
+ for (int i = 0; i < fieldIds.size(); i++)
+ ids[i] = fieldIds.get(i);
+
+ names = new String[fieldIds.size()];
+
+ if (fieldIds.size() <= 4) {
+ Iterator<Integer> iter = fieldIds.iterator();
+
+ id0 = iter.hasNext() ? iter.next() : 0;
+ id1 = iter.hasNext() ? iter.next() : 0;
+ id2 = iter.hasNext() ? iter.next() : 0;
+ id3 = iter.hasNext() ? iter.next() : 0;
}
else {
- inline = false;
+ id0 = id1 = id2 = id3 = 0;
- int size = in.readInt();
+ initializeMap(ids);
+ }
+ }
- ids = new ArrayList<>(size);
- idToOrder = U.newHashMap(size);
+ /**
+ * Initialize the map.
+ *
+ * @param vals Values.
+ */
+ private void initializeMap(int[] vals) {
+ int size = Math.max(nextPowerOfTwo(vals.length) << 2, MAP_MIN_SIZE);
- for (int i = 0; i < size; i++) {
- int fieldId = in.readInt();
+ assert size > 0;
- ids.add(fieldId);
- idToOrder.put(fieldId, i);
- }
+ ParseResult finalRes;
+
+ ParseResult res1 = parse(vals, size);
+
+ if (res1.collisions == 0)
+ finalRes = res1;
+ else {
+ ParseResult res2 = parse(vals, size * 2);
+
+ // Failed to decrease aom
+ if (res2.collisions == 0)
+ finalRes = res2;
+ else
+ finalRes = parse(vals, size * 4);
}
+
+ idToOrderData = finalRes.data;
+ idToOrderMask = maskForPowerOfTwo(idToOrderData.length / 2);
}
/**
@@ -332,4 +427,40 @@ public class PortableSchema implements Externalizable {
return new PortableSchema(schemaId, fields);
}
}
+
+ /**
+ * Order confirmation result.
+ */
+ public enum Confirmation {
+ /** Confirmed. */
+ CONFIRMED,
+
+ /** Denied. */
+ REJECTED,
+
+ /** Field name clarification is needed. */
+ CLARIFY
+ }
+
+ /**
+ * Result of map parsing.
+ */
+ private static class ParseResult {
+ /** Data. */
+ private int[] data;
+
+ /** Collisions. */
+ private int collisions;
+
+ /**
+ * Constructor.
+ *
+ * @param data Data.
+ * @param collisions Collisions.
+ */
+ private ParseResult(int[] data, int collisions) {
+ this.data = data;
+ this.collisions = collisions;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableThreadLocalMemoryAllocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableThreadLocalMemoryAllocator.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableThreadLocalMemoryAllocator.java
deleted file mode 100644
index 8f5bfb2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableThreadLocalMemoryAllocator.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.portable.streams.PortableMemoryAllocator;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
-
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
-
-/**
- * Thread-local memory allocator.
- */
-public class PortableThreadLocalMemoryAllocator implements PortableMemoryAllocator {
- /** Memory allocator instance. */
- public static final PortableThreadLocalMemoryAllocator THREAD_LOCAL_ALLOC =
- new PortableThreadLocalMemoryAllocator();
-
- /** Holders. */
- private static final ThreadLocal<ByteArrayHolder> holders = new ThreadLocal<>();
-
- /** Unsafe instance. */
- protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Array offset: byte. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /**
- * Ensures singleton.
- */
- private PortableThreadLocalMemoryAllocator() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public byte[] allocate(int size) {
- ByteArrayHolder holder = holders.get();
-
- if (holder == null)
- holders.set(holder = new ByteArrayHolder());
-
- if (holder.acquired)
- return new byte[size];
-
- holder.acquired = true;
-
- if (holder.data == null || size > holder.data.length)
- holder.data = new byte[size];
-
- return holder.data;
- }
-
- /** {@inheritDoc} */
- @Override public byte[] reallocate(byte[] data, int size) {
- ByteArrayHolder holder = holders.get();
-
- assert holder != null;
-
- byte[] newData = new byte[size];
-
- if (holder.data == data)
- holder.data = newData;
-
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, newData, BYTE_ARR_OFF, data.length);
-
- return newData;
- }
-
- /** {@inheritDoc} */
- @Override public void release(byte[] data, int maxMsgSize) {
- ByteArrayHolder holder = holders.get();
-
- assert holder != null;
-
- if (holder.data != data)
- return;
-
- holder.maxMsgSize = maxMsgSize;
- holder.acquired = false;
-
- holder.shrink();
- }
-
- /** {@inheritDoc} */
- @Override public long allocateDirect(int size) {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public long reallocateDirect(long addr, int size) {
- return 0;
- }
-
- /** {@inheritDoc} */
- @Override public void releaseDirect(long addr) {
- // No-op
- }
-
- /**
- * Checks whether a thread-local array is acquired or not.
- * The function is used by Unit tests.
- *
- * @return {@code true} if acquired {@code false} otherwise.
- */
- public boolean isThreadLocalArrayAcquired() {
- ByteArrayHolder holder = holders.get();
-
- return holder != null && holder.acquired;
- }
-
- /**
- * Thread-local byte array holder.
- */
- private static class ByteArrayHolder {
- /** */
- private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
-
- /** Data array */
- private byte[] data;
-
- /** Max message size detected between checks. */
- private int maxMsgSize;
-
- /** Last time array size is checked. */
- private long lastCheck = U.currentTimeMillis();
-
- /** Whether the holder is acquired or not. */
- private boolean acquired;
-
- /**
- * Shrinks array size if needed.
- */
- private void shrink() {
- long now = U.currentTimeMillis();
-
- if (now - lastCheck >= CHECK_FREQ) {
- int halfSize = data.length >> 1;
-
- if (maxMsgSize < halfSize)
- data = new byte[halfSize];
-
- lastCheck = now;
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index 95ef9591..53d414c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -17,7 +17,9 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.portable.builder.PortableLazyValue;
+import org.apache.ignite.internal.portable.streams.PortableOutputStream;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -26,6 +28,7 @@ import org.apache.ignite.binary.BinaryObject;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import java.io.Externalizable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Collection;
@@ -669,13 +672,14 @@ public class PortableUtils {
* @return Position where length should be written.
*/
public static int writeHeader(BinaryWriterExImpl writer, int typeId, int hashCode, @Nullable String clsName) {
- writer.doWriteByte(GridPortableMarshaller.OBJ);
- writer.doWriteByte(GridPortableMarshaller.PROTO_VER);
+ PortableOutputStream out = writer.out();
- writer.doWriteShort((short) 0);
-
- writer.doWriteInt(typeId);
- writer.doWriteInt(hashCode);
+ out.unsafeEnsure(12);
+ out.unsafeWriteByte(GridPortableMarshaller.OBJ);
+ out.unsafeWriteByte(GridPortableMarshaller.PROTO_VER);
+ out.unsafeWriteShort((short) 0);
+ out.unsafeWriteInt(typeId);
+ out.unsafeWriteInt(hashCode);
int reserved = writer.reserve(12);
@@ -903,4 +907,108 @@ public class PortableUtils {
oldMeta.affinityKeyFieldName(), mergedSchemas) : oldMeta;
}
}
+
+ /**
+ * @param cls Class.
+ * @return Mode.
+ */
+ @SuppressWarnings("IfMayBeConditional")
+ public static BinaryWriteMode mode(Class<?> cls) {
+ assert cls != null;
+
+ /** Primitives. */
+ if (cls == byte.class)
+ return BinaryWriteMode.P_BYTE;
+ else if (cls == boolean.class)
+ return BinaryWriteMode.P_BOOLEAN;
+ else if (cls == short.class)
+ return BinaryWriteMode.P_SHORT;
+ else if (cls == char.class)
+ return BinaryWriteMode.P_CHAR;
+ else if (cls == int.class)
+ return BinaryWriteMode.P_INT;
+ else if (cls == long.class)
+ return BinaryWriteMode.P_LONG;
+ else if (cls == float.class)
+ return BinaryWriteMode.P_FLOAT;
+ else if (cls == double.class)
+ return BinaryWriteMode.P_DOUBLE;
+
+ /** Boxed primitives. */
+ else if (cls == Byte.class)
+ return BinaryWriteMode.BYTE;
+ else if (cls == Boolean.class)
+ return BinaryWriteMode.BOOLEAN;
+ else if (cls == Short.class)
+ return BinaryWriteMode.SHORT;
+ else if (cls == Character.class)
+ return BinaryWriteMode.CHAR;
+ else if (cls == Integer.class)
+ return BinaryWriteMode.INT;
+ else if (cls == Long.class)
+ return BinaryWriteMode.LONG;
+ else if (cls == Float.class)
+ return BinaryWriteMode.FLOAT;
+ else if (cls == Double.class)
+ return BinaryWriteMode.DOUBLE;
+
+ /** The rest types. */
+ else if (cls == BigDecimal.class)
+ return BinaryWriteMode.DECIMAL;
+ else if (cls == String.class)
+ return BinaryWriteMode.STRING;
+ else if (cls == UUID.class)
+ return BinaryWriteMode.UUID;
+ else if (cls == Date.class)
+ return BinaryWriteMode.DATE;
+ else if (cls == Timestamp.class)
+ return BinaryWriteMode.TIMESTAMP;
+ else if (cls == byte[].class)
+ return BinaryWriteMode.BYTE_ARR;
+ else if (cls == short[].class)
+ return BinaryWriteMode.SHORT_ARR;
+ else if (cls == int[].class)
+ return BinaryWriteMode.INT_ARR;
+ else if (cls == long[].class)
+ return BinaryWriteMode.LONG_ARR;
+ else if (cls == float[].class)
+ return BinaryWriteMode.FLOAT_ARR;
+ else if (cls == double[].class)
+ return BinaryWriteMode.DOUBLE_ARR;
+ else if (cls == char[].class)
+ return BinaryWriteMode.CHAR_ARR;
+ else if (cls == boolean[].class)
+ return BinaryWriteMode.BOOLEAN_ARR;
+ else if (cls == BigDecimal[].class)
+ return BinaryWriteMode.DECIMAL_ARR;
+ else if (cls == String[].class)
+ return BinaryWriteMode.STRING_ARR;
+ else if (cls == UUID[].class)
+ return BinaryWriteMode.UUID_ARR;
+ else if (cls == Date[].class)
+ return BinaryWriteMode.DATE_ARR;
+ else if (cls == Timestamp[].class)
+ return BinaryWriteMode.TIMESTAMP_ARR;
+ else if (cls.isArray())
+ return cls.getComponentType().isEnum() ?
+ BinaryWriteMode.ENUM_ARR : BinaryWriteMode.OBJECT_ARR;
+ else if (cls == BinaryObjectImpl.class)
+ return BinaryWriteMode.PORTABLE_OBJ;
+ else if (Binarylizable.class.isAssignableFrom(cls))
+ return BinaryWriteMode.PORTABLE;
+ else if (Externalizable.class.isAssignableFrom(cls))
+ return BinaryWriteMode.EXTERNALIZABLE;
+ else if (Map.Entry.class.isAssignableFrom(cls))
+ return BinaryWriteMode.MAP_ENTRY;
+ else if (Collection.class.isAssignableFrom(cls))
+ return BinaryWriteMode.COL;
+ else if (Map.class.isAssignableFrom(cls))
+ return BinaryWriteMode.MAP;
+ else if (cls.isEnum())
+ return BinaryWriteMode.ENUM;
+ else if (cls == Class.class)
+ return BinaryWriteMode.CLASS;
+ else
+ return BinaryWriteMode.OBJECT;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
index dfc2330..2ce2416 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
@@ -178,7 +178,9 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
/** {@inheritDoc} */
@Override public BinaryObject build() {
- try (BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, typeId, false)) {
+ try (BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx)) {
+ writer.typeId(typeId);
+
PortableBuilderSerializer serializationCtx = new PortableBuilderSerializer();
serializationCtx.registerObjectWriting(this, 0);
@@ -206,7 +208,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
Set<Integer> remainsFlds = null;
if (reader != null) {
- PortableSchema schema = reader.schema(start);
+ PortableSchema schema = reader.schema();
Map<Integer, Object> assignedFldsById;
@@ -440,7 +442,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
int fieldIdLen = PortableUtils.fieldIdLength(flags);
int fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
- PortableSchema schema = reader.schema(start);
+ PortableSchema schema = reader.schema();
Map<Integer, Object> readCache = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
index b6a6b54..538c26c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -21,6 +21,8 @@ import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+
+import org.apache.ignite.internal.portable.BinaryReaderHandles;
import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
import org.apache.ignite.internal.portable.PortablePositionReadable;
@@ -31,6 +33,7 @@ import org.apache.ignite.internal.portable.PortableSchema;
import org.apache.ignite.internal.portable.PortableUtils;
import org.apache.ignite.internal.portable.BinaryWriterExImpl;
import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
@@ -41,21 +44,23 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
*/
public class PortableBuilderReader implements PortablePositionReadable {
/** */
- private final Map<Integer, BinaryObjectBuilderImpl> objMap = new HashMap<>();
+ private final PortableContext ctx;
/** */
- private final PortableContext ctx;
+ private final byte[] arr;
/** */
private final BinaryReaderExImpl reader;
/** */
- private byte[] arr;
+ private final Map<Integer, BinaryObjectBuilderImpl> objMap;
/** */
private int pos;
- /**
+ /*
+ * Constructor.
+ *
* @param objImpl Portable object
*/
PortableBuilderReader(BinaryObjectImpl objImpl) {
@@ -64,7 +69,25 @@ public class PortableBuilderReader implements PortablePositionReadable {
pos = objImpl.start();
// TODO: IGNITE-1272 - Is class loader needed here?
- reader = new BinaryReaderExImpl(ctx, arr, pos, null);
+ reader = new BinaryReaderExImpl(ctx, PortableHeapInputStream.create(arr, pos), null, new BinaryReaderHandles());
+
+ objMap = new HashMap<>();
+ }
+
+ /**
+ * Copying constructor.
+ *
+ * @param other Other reader.
+ * @param start Start position.
+ */
+ PortableBuilderReader(PortableBuilderReader other, int start) {
+ this.ctx = other.ctx;
+ this.arr = other.arr;
+ this.pos = start;
+
+ reader = new BinaryReaderExImpl(ctx, PortableHeapInputStream.create(arr, start), null, other.reader.handles());
+
+ this.objMap = other.objMap;
}
/**
@@ -84,19 +107,10 @@ public class PortableBuilderReader implements PortablePositionReadable {
/**
* Get schema of the object, starting at the given position.
*
- * @param start Start position.
* @return Object's schema.
*/
- public PortableSchema schema(int start) {
- // We can use current reader in case start is equal to initially recorded position.
- BinaryReaderExImpl targetReader;
-
- if (start == pos)
- targetReader = reader;
- else
- targetReader = new BinaryReaderExImpl(ctx, arr, start, null);
-
- return targetReader.getOrCreateSchema();
+ public PortableSchema schema() {
+ return reader.getOrCreateSchema();
}
/**
@@ -367,7 +381,7 @@ public class PortableBuilderReader implements PortablePositionReadable {
BinaryObjectBuilderImpl res = objMap.get(objStart);
if (res == null) {
- res = new BinaryObjectBuilderImpl(this, objStart);
+ res = new BinaryObjectBuilderImpl(new PortableBuilderReader(this, objStart), objStart);
objMap.put(objStart, res);
}
@@ -379,7 +393,7 @@ public class PortableBuilderReader implements PortablePositionReadable {
BinaryObjectBuilderImpl res = objMap.get(pos);
if (res == null) {
- res = new BinaryObjectBuilderImpl(this, pos);
+ res = new BinaryObjectBuilderImpl(new PortableBuilderReader(this, pos), pos);
objMap.put(pos, res);
}
@@ -492,7 +506,7 @@ public class PortableBuilderReader implements PortablePositionReadable {
BinaryObjectBuilderImpl res = objMap.get(objStart);
if (res == null) {
- res = new BinaryObjectBuilderImpl(this, objStart);
+ res = new BinaryObjectBuilderImpl(new PortableBuilderReader(this, objStart), objStart);
objMap.put(objStart, res);
}
@@ -506,7 +520,7 @@ public class PortableBuilderReader implements PortablePositionReadable {
BinaryObjectBuilderImpl res = objMap.get(pos);
if (res == null) {
- res = new BinaryObjectBuilderImpl(this, pos);
+ res = new BinaryObjectBuilderImpl(new PortableBuilderReader(this, pos), pos);
objMap.put(pos, res);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
index c943682..b68e9d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
@@ -123,14 +123,14 @@ public abstract class PortableAbstractOutputStream extends PortableAbstractStrea
@Override public void writeShort(int pos, short val) {
ensureCapacity(pos + 2);
- writeShortPositioned(pos, val);
+ unsafeWriteShort(pos, val);
}
/** {@inheritDoc} */
@Override public void writeInt(int pos, int val) {
ensureCapacity(pos + 4);
- writeIntPositioned(pos, val);
+ unsafeWriteInt(pos, val);
}
/** {@inheritDoc} */
@@ -247,6 +247,26 @@ public abstract class PortableAbstractOutputStream extends PortableAbstractStrea
return 0;
}
+ /** {@inheritDoc} */
+ @Override public void unsafeEnsure(int cap) {
+ ensureCapacity(pos + cap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteBoolean(boolean val) {
+ unsafeWriteByte(val ? BYTE_ONE : BYTE_ZERO);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteFloat(float val) {
+ unsafeWriteInt(Float.floatToIntBits(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteDouble(double val) {
+ unsafeWriteLong(Double.doubleToLongBits(val));
+ }
+
/**
* Calculate new capacity.
*
@@ -314,22 +334,6 @@ public abstract class PortableAbstractOutputStream extends PortableAbstractStrea
protected abstract void writeLongFast(long val);
/**
- * Write short value to the given position.
- *
- * @param pos Position.
- * @param val Value.
- */
- protected abstract void writeShortPositioned(int pos, short val);
-
- /**
- * Write int value to the given position.
- *
- * @param pos Position.
- * @param val Value.
- */
- protected abstract void writeIntPositioned(int pos, int val);
-
- /**
* Ensure capacity.
*
* @param cnt Required byte count.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapInputStream.java
index e027d70..1b39950 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapInputStream.java
@@ -23,6 +23,23 @@ import java.util.Arrays;
* Portable off-heap input stream.
*/
public final class PortableHeapInputStream extends PortableAbstractInputStream {
+ /**
+ * Create stream with pointer set at the given position.
+ *
+ * @param data Data.
+ * @param pos Position.
+ * @return Stream.
+ */
+ public static PortableHeapInputStream create(byte[] data, int pos) {
+ assert pos < data.length;
+
+ PortableHeapInputStream stream = new PortableHeapInputStream(data);
+
+ stream.pos = pos;
+
+ return stream;
+ }
+
/** Data. */
private byte[] data;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapOutputStream.java
index 208ad33..062a359 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableHeapOutputStream.java
@@ -17,73 +17,40 @@
package org.apache.ignite.internal.portable.streams;
-import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.DFLT_ALLOC;
-import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
-
/**
* Portable heap output stream.
*/
public final class PortableHeapOutputStream extends PortableAbstractOutputStream {
- /** Default capacity. */
- private static final int DFLT_CAP = 1024;
-
/** Allocator. */
- private final PortableMemoryAllocator alloc;
+ private final PortableMemoryAllocatorChunk chunk;
/** Data. */
private byte[] data;
/**
* Constructor.
- */
- public PortableHeapOutputStream() {
- this(DFLT_CAP, DFLT_ALLOC);
- }
-
- /**
- * Constructor.
*
* @param cap Initial capacity.
*/
public PortableHeapOutputStream(int cap) {
- this(cap, THREAD_LOCAL_ALLOC);
+ this(cap, PortableMemoryAllocator.INSTANCE.chunk());
}
/**
* Constructor.
*
- * @param cap Initial capacity.
- * @param alloc Allocator.
+ * @param cap Capacity.
+ * @param chunk Chunk.
*/
- public PortableHeapOutputStream(int cap, PortableMemoryAllocator alloc) {
- data = alloc.allocate(cap);
-
- this.alloc = alloc;
- }
+ public PortableHeapOutputStream(int cap, PortableMemoryAllocatorChunk chunk) {
+ this.chunk = chunk;
- /**
- * Constructor.
- *
- * @param data Data.
- */
- public PortableHeapOutputStream(byte[] data) {
- this(data, DFLT_ALLOC);
- }
-
- /**
- * Constructor.
- *
- * @param data Data.
- * @param alloc Allocator.
- */
- public PortableHeapOutputStream(byte[] data, PortableMemoryAllocator alloc) {
- this.data = data;
- this.alloc = alloc;
+ data = chunk.allocate(cap);
}
/** {@inheritDoc} */
@Override public void close() {
- alloc.release(data, pos);
+ chunk.release(data, pos);
}
/** {@inheritDoc} */
@@ -91,7 +58,7 @@ public final class PortableHeapOutputStream extends PortableAbstractOutputStream
if (cnt > data.length) {
int newCap = capacity(data.length, cnt);
- data = alloc.reallocate(data, newCap);
+ data = chunk.reallocate(data, newCap);
}
}
@@ -147,18 +114,63 @@ public final class PortableHeapOutputStream extends PortableAbstractOutputStream
}
/** {@inheritDoc} */
- @Override protected void writeShortPositioned(int pos, short val) {
+ @Override public void unsafeWriteByte(byte val) {
+ UNSAFE.putByte(data, BYTE_ARR_OFF + pos++, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteShort(short val) {
if (!LITTLE_ENDIAN)
val = Short.reverseBytes(val);
UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+
+ shift(2);
}
/** {@inheritDoc} */
- @Override protected void writeIntPositioned(int pos, int val) {
+ @Override public void unsafeWriteShort(int pos, short val) {
+ if (!LITTLE_ENDIAN)
+ val = Short.reverseBytes(val);
+
+ UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteChar(char val) {
+ if (!LITTLE_ENDIAN)
+ val = Character.reverseBytes(val);
+
+ UNSAFE.putChar(data, BYTE_ARR_OFF + pos, val);
+
+ shift(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteInt(int val) {
+ if (!LITTLE_ENDIAN)
+ val = Integer.reverseBytes(val);
+
+ UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
+
+ shift(4);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteInt(int pos, int val) {
if (!LITTLE_ENDIAN)
val = Integer.reverseBytes(val);
UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
}
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteLong(long val) {
+ if (!LITTLE_ENDIAN)
+ val = Long.reverseBytes(val);
+
+ UNSAFE.putLong(data, BYTE_ARR_OFF + pos, val);
+
+ shift(8);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocator.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocator.java
index 7ddb457..e16747b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocator.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocator.java
@@ -18,59 +18,40 @@
package org.apache.ignite.internal.portable.streams;
/**
- * Portable memory allocator.
+ * Thread-local memory allocator.
*/
-public interface PortableMemoryAllocator {
- /** Default memory allocator. */
- public static final PortableMemoryAllocator DFLT_ALLOC = new PortableSimpleMemoryAllocator();
+public final class PortableMemoryAllocator {
+ /** Memory allocator instance. */
+ public static final PortableMemoryAllocator INSTANCE = new PortableMemoryAllocator();
- /**
- * Allocate memory.
- *
- * @param size Size.
- * @return Data.
- */
- public byte[] allocate(int size);
+ /** Holders. */
+ private static final ThreadLocal<PortableMemoryAllocatorChunk> holders = new ThreadLocal<>();
/**
- * Reallocates memory.
- *
- * @param data Current data chunk.
- * @param size New size required.
- *
- * @return Data.
+ * Ensures singleton.
*/
- public byte[] reallocate(byte[] data, int size);
+ private PortableMemoryAllocator() {
+ // No-op.
+ }
- /**
- * Release memory.
- *
- * @param data Data.
- * @param maxMsgSize Max message size sent during the time the allocator is used.
- */
- public void release(byte[] data, int maxMsgSize);
+ public PortableMemoryAllocatorChunk chunk() {
+ PortableMemoryAllocatorChunk holder = holders.get();
- /**
- * Allocate memory.
- *
- * @param size Size.
- * @return Address.
- */
- public long allocateDirect(int size);
+ if (holder == null)
+ holders.set(holder = new PortableMemoryAllocatorChunk());
- /**
- * Reallocate memory.
- *
- * @param addr Address.
- * @param size Size.
- * @return Address.
- */
- public long reallocateDirect(long addr, int size);
+ return holder;
+ }
/**
- * Release memory.
+ * Checks whether a thread-local array is acquired or not.
+ * The function is used by Unit tests.
*
- * @param addr Address.
+ * @return {@code true} if acquired {@code false} otherwise.
*/
- public void releaseDirect(long addr);
+ public boolean isAcquired() {
+ PortableMemoryAllocatorChunk holder = holders.get();
+
+ return holder != null && holder.isAcquired();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocatorChunk.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocatorChunk.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocatorChunk.java
new file mode 100644
index 0000000..35d58f7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableMemoryAllocatorChunk.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.streams;
+
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import sun.misc.Unsafe;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
+
+/**
+ * Memory allocator chunk.
+ */
+public class PortableMemoryAllocatorChunk {
+ /** Unsafe instance. */
+ protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
+
+ /** Array offset: byte. */
+ protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+ /** Buffer size re-check frequency. */
+ private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
+
+ /** Data array */
+ private byte[] data;
+
+ /** Max message size detected between checks. */
+ private int maxMsgSize;
+
+ /** Last time array size is checked. */
+ private long lastCheck = U.currentTimeMillis();
+
+ /** Whether the holder is acquired or not. */
+ private boolean acquired;
+
+ /**
+ * Allocate.
+ *
+ * @param size Desired size.
+ * @return Data.
+ */
+ public byte[] allocate(int size) {
+ if (acquired)
+ return new byte[size];
+
+ acquired = true;
+
+ if (data == null || size > data.length)
+ data = new byte[size];
+
+ return data;
+ }
+
+ /**
+ * Reallocate.
+ *
+ * @param data Old data.
+ * @param size Size.
+ * @return New data.
+ */
+ public byte[] reallocate(byte[] data, int size) {
+ byte[] newData = new byte[size];
+
+ if (this.data == data)
+ this.data = newData;
+
+ UNSAFE.copyMemory(data, BYTE_ARR_OFF, newData, BYTE_ARR_OFF, data.length);
+
+ return newData;
+ }
+
+ /**
+ * Shrinks array size if needed.
+ */
+ public void release(byte[] data, int maxMsgSize) {
+ if (this.data != data)
+ return;
+
+ if (maxMsgSize > this.maxMsgSize)
+ this.maxMsgSize = maxMsgSize;
+
+ this.acquired = false;
+
+ long now = U.currentTimeMillis();
+
+ if (now - this.lastCheck >= CHECK_FREQ) {
+ int halfSize = data.length >> 1;
+
+ if (this.maxMsgSize < halfSize)
+ this.data = new byte[halfSize];
+
+ this.lastCheck = now;
+ }
+ }
+
+ /**
+ * @return {@code True} if acquired.
+ */
+ public boolean isAcquired() {
+ return acquired;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOffheapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOffheapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOffheapOutputStream.java
index 430a176..cadd244 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOffheapOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOffheapOutputStream.java
@@ -125,24 +125,69 @@ public class PortableOffheapOutputStream extends PortableAbstractOutputStream {
}
/** {@inheritDoc} */
- @Override protected void writeShortPositioned(int pos, short val) {
+ @Override public boolean hasArray() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteByte(byte val) {
+ UNSAFE.putByte(ptr + pos++, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteShort(short val) {
if (!LITTLE_ENDIAN)
val = Short.reverseBytes(val);
UNSAFE.putShort(ptr + pos, val);
+
+ shift(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteShort(int pos, short val) {
+ if (!LITTLE_ENDIAN)
+ val = Short.reverseBytes(val);
+
+ UNSAFE.putShort(ptr + pos, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteChar(char val) {
+ if (!LITTLE_ENDIAN)
+ val = Character.reverseBytes(val);
+
+ UNSAFE.putChar(ptr + pos, val);
+
+ shift(2);
}
/** {@inheritDoc} */
- @Override protected void writeIntPositioned(int pos, int val) {
+ @Override public void unsafeWriteInt(int val) {
if (!LITTLE_ENDIAN)
val = Integer.reverseBytes(val);
UNSAFE.putInt(ptr + pos, val);
+
+ shift(4);
}
/** {@inheritDoc} */
- @Override public boolean hasArray() {
- return false;
+ @Override public void unsafeWriteInt(int pos, int val) {
+ if (!LITTLE_ENDIAN)
+ val = Integer.reverseBytes(val);
+
+ UNSAFE.putInt(ptr + pos, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteLong(long val) {
+ if (!LITTLE_ENDIAN)
+ val = Long.reverseBytes(val);
+
+ UNSAFE.putLong(ptr + pos, val);
+
+ shift(8);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
index 0e25b12..3a2e9e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
@@ -170,4 +170,83 @@ public interface PortableOutputStream extends PortableStream, AutoCloseable {
* Close the stream releasing resources.
*/
@Override public void close();
+
+ /**
+ * Ensure capacity for unsafe writes.
+ *
+ * @param cap Capacity.
+ */
+ public void unsafeEnsure(int cap);
+
+ /**
+ * Write byte in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteByte(byte val);
+
+ /**
+ * Write boolean in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteBoolean(boolean val);
+
+ /**
+ * Write short in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteShort(short val);
+
+ /**
+ * Write short in unsafe mode.
+ *
+ * @param pos Position.
+ * @param val Value.
+ */
+ public void unsafeWriteShort(int pos, short val);
+
+ /**
+ * Write char in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteChar(char val);
+
+ /**
+ * Write int in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteInt(int val);
+
+ /**
+ * Write int in unsafe mode.
+ *
+ * @param pos Position.
+ * @param val Value.
+ */
+ public void unsafeWriteInt(int pos, int val);
+
+ /**
+ * Write long in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteLong(long val);
+
+ /**
+ * Write float in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteFloat(float val);
+
+ /**
+ * Write double in unsafe mode.
+ *
+ * @param val Value.
+ */
+ public void unsafeWriteDouble(double val);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableSimpleMemoryAllocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableSimpleMemoryAllocator.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableSimpleMemoryAllocator.java
deleted file mode 100644
index 54d7b38..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableSimpleMemoryAllocator.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable.streams;
-
-import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
-
-/**
- * Naive implementation of portable memory allocator.
- */
-public class PortableSimpleMemoryAllocator implements PortableMemoryAllocator {
- /** Unsafe. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Array offset: byte. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** {@inheritDoc} */
- @Override public byte[] allocate(int size) {
- return new byte[size];
- }
-
- /** {@inheritDoc} */
- @Override public byte[] reallocate(byte[] data, int size) {
- byte[] newData = new byte[size];
-
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, newData, BYTE_ARR_OFF, data.length);
-
- return newData;
- }
-
- /** {@inheritDoc} */
- @Override public void release(byte[] data, int maxMsgSize) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public long allocateDirect(int size) {
- return UNSAFE.allocateMemory(size);
- }
-
- /** {@inheritDoc} */
- @Override public long reallocateDirect(long addr, int size) {
- return UNSAFE.reallocateMemory(addr, size);
- }
-
- /** {@inheritDoc} */
- @Override public void releaseDirect(long addr) {
- UNSAFE.freeMemory(addr);
- }
-}
\ No newline at end of file
[09/55] [abbrv] ignite git commit: IGNITE-1934 .Net: Store tests
broken after keepPortableInStore renaming.
Posted by ag...@apache.org.
IGNITE-1934 .Net: Store tests broken after keepPortableInStore renaming.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f3b0be79
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f3b0be79
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f3b0be79
Branch: refs/heads/ignite-1.5
Commit: f3b0be79e3dc12a1cab54525e905574cc7f2b7c7
Parents: d69362f
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Wed Nov 18 10:03:05 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 18 10:03:05 2015 +0300
----------------------------------------------------------------------
.../Config/native-client-test-cache-parallel-store.xml | 2 +-
.../Config/native-client-test-cache-store.xml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f3b0be79/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
index 74abbf8..af03e69 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
@@ -39,7 +39,7 @@
<property name="name" value="object_store_parallel"/>
<property name="cacheMode" value="LOCAL"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="keepPortableInStore" value="false"/>
+ <property name="keepBinaryInStore" value="false"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
http://git-wip-us.apache.org/repos/asf/ignite/blob/f3b0be79/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
index c2bf78c..b414a91 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
@@ -55,7 +55,7 @@
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeThrough" value="true"/>
<property name="readThrough" value="true"/>
- <property name="keepPortableInStore" value="false"/>
+ <property name="keepBinaryInStore" value="false"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
@@ -70,7 +70,7 @@
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeThrough" value="true"/>
<property name="readThrough" value="true"/>
- <property name="keepPortableInStore" value="false"/>
+ <property name="keepBinaryInStore" value="false"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
[55/55] [abbrv] ignite git commit: Merge branch ignite-1282 into
ignite-1.5
Posted by ag...@apache.org.
Merge branch ignite-1282 into ignite-1.5
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/13e11b32
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/13e11b32
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/13e11b32
Branch: refs/heads/ignite-1.5
Commit: 13e11b32b0d4abc9a5ea9fffe6b2c56561a4f56c
Parents: 5d224f1 df859c0
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Sun Nov 22 01:44:35 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Sun Nov 22 01:44:35 2015 +0300
----------------------------------------------------------------------
.gitignore | 6 +
assembly/release-fabric-base.xml | 94 +
.../config/binary/example-ignite-binary.xml | 44 +
examples/config/example-default.xml | 76 +
examples/config/example-ignite.xml | 56 +-
.../apache/ignite/examples/binary/Address.java | 72 +
.../apache/ignite/examples/binary/Employee.java | 93 +
.../ignite/examples/binary/EmployeeKey.java | 90 +
.../binary/ExampleBinaryNodeStartup.java | 36 +
.../ignite/examples/binary/Organization.java | 93 +
.../examples/binary/OrganizationType.java | 32 +
...ComputeClientBinaryTaskExecutionExample.java | 153 +
.../binary/computegrid/ComputeClientTask.java | 116 +
.../binary/computegrid/package-info.java | 21 +
.../CacheClientBinaryPutGetExample.java | 230 ++
.../datagrid/CacheClientBinaryQueryExample.java | 330 ++
.../examples/binary/datagrid/package-info.java | 21 +
.../ignite/examples/binary/package-info.java | 21 +
.../CacheClientPortableExampleTest.java | 46 +
.../ComputeClientPortableExampleTest.java | 37 +
.../testsuites/IgniteExamplesSelfTestSuite.java | 6 +
.../ignite/codegen/MessageCodeGenerator.java | 11 +-
modules/core/pom.xml | 21 +
...processors.platform.PlatformBootstrapFactory | 2 +
.../src/main/java/org/apache/ignite/Ignite.java | 7 +
.../java/org/apache/ignite/IgniteBinary.java | 357 ++
.../java/org/apache/ignite/IgniteCache.java | 41 +
.../org/apache/ignite/IgniteDataStreamer.java | 16 +
.../org/apache/ignite/binary/BinaryField.java | 46 +
.../apache/ignite/binary/BinaryIdMapper.java | 54 +
.../binary/BinaryInvalidTypeException.java | 58 +
.../org/apache/ignite/binary/BinaryObject.java | 149 +
.../ignite/binary/BinaryObjectBuilder.java | 135 +
.../ignite/binary/BinaryObjectException.java | 57 +
.../apache/ignite/binary/BinaryRawReader.java | 240 ++
.../apache/ignite/binary/BinaryRawWriter.java | 225 ++
.../org/apache/ignite/binary/BinaryReader.java | 290 ++
.../apache/ignite/binary/BinarySerializer.java | 47 +
.../org/apache/ignite/binary/BinaryType.java | 68 +
.../ignite/binary/BinaryTypeConfiguration.java | 112 +
.../org/apache/ignite/binary/BinaryWriter.java | 273 ++
.../org/apache/ignite/binary/Binarylizable.java | 48 +
.../org/apache/ignite/binary/package-info.java | 22 +
.../ignite/cache/CacheKeyConfiguration.java | 92 +
.../apache/ignite/cache/CacheTypeMetadata.java | 67 +-
.../org/apache/ignite/cache/QueryEntity.java | 217 ++
.../org/apache/ignite/cache/QueryIndex.java | 192 +
.../org/apache/ignite/cache/QueryIndexType.java | 38 +
.../configuration/BinaryConfiguration.java | 139 +
.../configuration/CacheConfiguration.java | 692 +++-
.../configuration/IgniteConfiguration.java | 75 +-
.../configuration/PlatformConfiguration.java | 25 +
.../ignite/internal/GridKernalContextImpl.java | 4 +-
.../org/apache/ignite/internal/IgniteEx.java | 9 -
.../apache/ignite/internal/IgniteKernal.java | 39 +-
.../ignite/internal/IgniteNodeAttributes.java | 6 +
.../internal/client/GridClientCompute.java | 2 +-
.../impl/connection/GridClientConnection.java | 2 +-
.../GridClientConnectionManagerAdapter.java | 2 +-
.../connection/GridClientNioTcpConnection.java | 6 +-
.../communication/GridIoMessageFactory.java | 4 +-
.../swapspace/GridSwapSpaceManager.java | 34 -
.../portable/BinaryCachingMetadataHandler.java | 70 +
.../internal/portable/BinaryEnumCache.java | 69 +
.../internal/portable/BinaryFieldAccessor.java | 805 ++++
.../internal/portable/BinaryFieldImpl.java | 116 +
.../portable/BinaryInternalIdMapper.java | 161 +
.../internal/portable/BinaryMetadata.java | 166 +
.../portable/BinaryMetadataCollector.java | 277 ++
.../portable/BinaryMetadataHandler.java | 44 +
.../portable/BinaryNoopMetadataHandler.java | 53 +
.../internal/portable/BinaryObjectEx.java | 245 ++
.../internal/portable/BinaryObjectImpl.java | 581 +++
.../portable/BinaryObjectOffheapImpl.java | 436 +++
.../internal/portable/BinaryRawReaderEx.java | 33 +
.../internal/portable/BinaryRawWriterEx.java | 60 +
.../internal/portable/BinaryReaderExImpl.java | 2748 +++++++++++++
.../internal/portable/BinaryReaderHandles.java | 108 +
.../portable/BinaryThreadLocalContext.java | 69 +
.../internal/portable/BinaryTypeImpl.java | 81 +
.../internal/portable/BinaryWriteMode.java | 178 +
.../internal/portable/BinaryWriterExImpl.java | 1817 +++++++++
.../internal/portable/BinaryWriterHandles.java | 101 +
.../portable/BinaryWriterSchemaHolder.java | 148 +
.../portable/GridPortableMarshaller.java | 67 +-
.../portable/PortableClassDescriptor.java | 1003 ++---
.../internal/portable/PortableContext.java | 542 +--
.../portable/PortableMetaDataCollector.java | 258 --
.../portable/PortableMetaDataHandler.java | 44 -
.../internal/portable/PortableMetaDataImpl.java | 150 -
.../internal/portable/PortableObjectEx.java | 214 -
.../internal/portable/PortableObjectImpl.java | 391 --
.../portable/PortableObjectOffheapImpl.java | 243 --
.../portable/PortablePositionReadable.java | 47 +
.../internal/portable/PortablePrimitives.java | 779 +---
.../internal/portable/PortableRawReaderEx.java | 33 -
.../internal/portable/PortableRawWriterEx.java | 60 -
.../portable/PortableReaderContext.java | 82 -
.../internal/portable/PortableReaderExImpl.java | 3157 ---------------
.../internal/portable/PortableSchema.java | 466 +++
.../portable/PortableSchemaRegistry.java | 172 +
.../PortableThreadLocalMemoryAllocator.java | 162 -
.../ignite/internal/portable/PortableUtils.java | 651 +++-
.../internal/portable/PortableWriterExImpl.java | 1854 ---------
.../internal/portable/api/IgnitePortables.java | 362 --
.../internal/portable/api/PortableBuilder.java | 136 -
.../portable/api/PortableException.java | 57 -
.../internal/portable/api/PortableIdMapper.java | 54 -
.../api/PortableInvalidClassException.java | 58 -
.../portable/api/PortableMarshalAware.java | 48 -
.../portable/api/PortableMarshaller.java | 357 --
.../internal/portable/api/PortableMetadata.java | 60 -
.../internal/portable/api/PortableObject.java | 152 -
.../portable/api/PortableProtocolVersion.java | 41 -
.../portable/api/PortableRawReader.java | 234 --
.../portable/api/PortableRawWriter.java | 219 --
.../internal/portable/api/PortableReader.java | 284 --
.../portable/api/PortableSerializer.java | 47 -
.../portable/api/PortableTypeConfiguration.java | 195 -
.../internal/portable/api/PortableWriter.java | 266 --
.../builder/BinaryObjectBuilderImpl.java | 577 +++
.../portable/builder/PortableBuilderEnum.java | 8 +-
.../portable/builder/PortableBuilderImpl.java | 533 ---
.../portable/builder/PortableBuilderReader.java | 214 +-
.../PortableBuilderSerializationAware.java | 2 +-
.../builder/PortableBuilderSerializer.java | 36 +-
.../builder/PortableEnumArrayLazyValue.java | 12 +-
.../portable/builder/PortableLazyArrayList.java | 8 +-
.../builder/PortableLazyLinkedList.java | 8 +-
.../portable/builder/PortableLazyMap.java | 8 +-
.../portable/builder/PortableLazyMapEntry.java | 2 +-
.../portable/builder/PortableLazySet.java | 8 +-
.../builder/PortableModifiableLazyValue.java | 2 +-
.../builder/PortableObjectArrayLazyValue.java | 8 +-
.../builder/PortablePlainLazyValue.java | 2 +-
.../builder/PortablePlainPortableObject.java | 22 +-
.../portable/builder/PortableValueWithType.java | 13 +-
.../streams/PortableAbstractInputStream.java | 48 +-
.../streams/PortableAbstractOutputStream.java | 44 +-
.../streams/PortableHeapInputStream.java | 34 +-
.../streams/PortableHeapOutputStream.java | 106 +-
.../portable/streams/PortableInputStream.java | 12 +-
.../streams/PortableMemoryAllocator.java | 67 +-
.../streams/PortableMemoryAllocatorChunk.java | 117 +
.../streams/PortableOffheapInputStream.java | 17 +-
.../streams/PortableOffheapOutputStream.java | 59 +-
.../portable/streams/PortableOutputStream.java | 94 +
.../streams/PortableSimpleMemoryAllocator.java | 66 -
.../affinity/GridAffinityAssignmentCache.java | 3 +-
.../affinity/GridAffinityProcessor.java | 5 +-
.../processors/cache/CacheInvokeEntry.java | 11 +-
.../processors/cache/CacheLazyEntry.java | 23 +-
.../internal/processors/cache/CacheObject.java | 11 +-
.../processors/cache/CacheObjectAdapter.java | 2 +-
.../cache/CacheObjectByteArrayImpl.java | 7 +-
.../processors/cache/CacheObjectContext.java | 128 +-
.../processors/cache/CacheObjectImpl.java | 5 +
.../processors/cache/CacheOperationContext.java | 22 +-
.../processors/cache/GridCacheAdapter.java | 98 +-
.../cache/GridCacheConcurrentMap.java | 10 +-
.../processors/cache/GridCacheContext.java | 14 +-
.../processors/cache/GridCacheEntryEx.java | 15 +-
.../processors/cache/GridCacheEventManager.java | 31 +-
.../cache/GridCacheEvictionManager.java | 5 +-
.../processors/cache/GridCacheMapEntry.java | 157 +-
.../processors/cache/GridCacheMvccManager.java | 29 +-
.../processors/cache/GridCacheProcessor.java | 7 +
.../processors/cache/GridCacheProxyImpl.java | 4 +-
.../processors/cache/GridCacheReturn.java | 27 +-
.../processors/cache/GridCacheSwapManager.java | 37 +-
.../processors/cache/GridCacheUtils.java | 3 +
.../processors/cache/IgniteCacheProxy.java | 11 +-
.../processors/cache/IgniteInternalCache.java | 6 +-
.../processors/cache/KeyCacheObjectImpl.java | 5 +
.../CacheDataStructuresManager.java | 4 +-
.../GridDistributedCacheAdapter.java | 40 +-
.../distributed/GridDistributedCacheEntry.java | 9 +-
.../distributed/GridDistributedLockRequest.java | 17 +
.../GridDistributedTxPrepareRequest.java | 3 +-
.../GridDistributedTxRemoteAdapter.java | 3 +
.../distributed/dht/GridDhtCacheEntry.java | 5 +-
.../distributed/dht/GridDhtLocalPartition.java | 3 +-
.../distributed/dht/GridDhtLockFuture.java | 10 +-
.../distributed/dht/GridDhtLockRequest.java | 3 +
.../dht/GridDhtTransactionalCacheAdapter.java | 21 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 17 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 15 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 12 +-
.../dht/GridPartitionedGetFuture.java | 6 +-
.../dht/GridPartitionedSingleGetFuture.java | 14 +-
.../dht/atomic/GridDhtAtomicCache.java | 74 +-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 6 +-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 42 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 15 +-
.../dht/atomic/GridNearAtomicUpdateRequest.java | 68 +-
.../atomic/GridNearAtomicUpdateResponse.java | 5 +-
.../dht/colocated/GridDhtColocatedCache.java | 31 +-
.../colocated/GridDhtColocatedLockFuture.java | 14 +-
.../dht/preloader/GridDhtForceKeysFuture.java | 2 +-
.../dht/preloader/GridDhtPartitionDemander.java | 2 +-
.../distributed/near/GridNearAtomicCache.java | 4 +
.../distributed/near/GridNearCacheEntry.java | 17 +-
.../distributed/near/GridNearGetFuture.java | 55 +-
.../distributed/near/GridNearLockFuture.java | 14 +-
.../distributed/near/GridNearLockRequest.java | 2 +
.../near/GridNearTransactionalCache.java | 8 +-
.../cache/distributed/near/GridNearTxLocal.java | 9 +-
.../distributed/near/GridNearTxRemote.java | 12 +-
.../cache/local/GridLocalCacheEntry.java | 16 +-
.../cache/local/GridLocalLockFuture.java | 3 +-
.../local/atomic/GridLocalAtomicCache.java | 108 +-
.../CacheDefaultPortableAffinityKeyMapper.java | 8 +-
.../portable/CacheObjectBinaryProcessor.java | 97 +
.../CacheObjectBinaryProcessorImpl.java | 848 ++++
.../portable/CacheObjectPortableContext.java | 133 -
.../portable/CacheObjectPortableProcessor.java | 103 -
.../CacheObjectPortableProcessorImpl.java | 1035 -----
.../cache/portable/IgniteBinaryImpl.java | 165 +
.../cache/portable/IgnitePortablesImpl.java | 177 -
.../cache/portable/PortableMetaDataKey.java | 82 -
.../cache/portable/PortableMetadataKey.java | 82 +
.../cache/query/GridCacheQueryManager.java | 298 +-
.../cache/query/GridCacheQueryRequest.java | 4 +-
.../continuous/CacheContinuousQueryEvent.java | 10 +-
.../cache/store/CacheOsStoreManager.java | 4 +-
.../store/GridCacheStoreManagerAdapter.java | 47 +-
.../transactions/IgniteTransactionsImpl.java | 10 +-
.../cache/transactions/IgniteTxAdapter.java | 5 +-
.../cache/transactions/IgniteTxEntry.java | 57 +-
.../transactions/IgniteTxLocalAdapter.java | 145 +-
.../cache/transactions/IgniteTxLocalEx.java | 1 +
.../cache/transactions/IgniteTxManager.java | 2 +-
.../cacheobject/IgniteCacheObjectProcessor.java | 6 +
.../IgniteCacheObjectProcessorImpl.java | 9 +
.../processors/cacheobject/NoOpBinary.java | 75 +
.../datastreamer/DataStreamProcessor.java | 1 +
.../datastreamer/DataStreamerEntry.java | 6 +-
.../datastreamer/DataStreamerImpl.java | 16 +-
.../datastreamer/DataStreamerRequest.java | 58 +-
.../datastreamer/DataStreamerUpdateJob.java | 10 +-
.../datastructures/GridCacheAtomicLongImpl.java | 26 +-
.../processors/hadoop/HadoopJobProperty.java | 2 +-
.../platform/PlatformAbstractBootstrap.java | 48 +
.../PlatformAbstractConfigurationClosure.java | 61 +
.../platform/PlatformAbstractPredicate.java | 67 +
.../platform/PlatformAbstractTarget.java | 320 ++
.../processors/platform/PlatformBootstrap.java | 35 +
.../platform/PlatformBootstrapFactory.java | 37 +
.../platform/PlatformConfiguration.java | 25 -
.../platform/PlatformConfigurationEx.java | 48 +
.../processors/platform/PlatformContext.java | 26 +-
.../platform/PlatformContextImpl.java | 616 +++
.../platform/PlatformExtendedException.java | 4 +-
.../processors/platform/PlatformIgnition.java | 189 +
.../platform/PlatformNoopProcessor.java | 6 +
.../processors/platform/PlatformProcessor.java | 11 +
.../platform/PlatformProcessorImpl.java | 374 ++
.../platform/cache/PlatformCache.java | 1090 ++++++
.../cache/PlatformCacheEntryFilterImpl.java | 106 +
.../cache/PlatformCacheEntryProcessorImpl.java | 220 ++
.../platform/cache/PlatformCacheIterator.java | 72 +
.../PlatformCachePartialUpdateException.java | 59 +
.../cache/affinity/PlatformAffinity.java | 297 ++
.../query/PlatformAbstractQueryCursor.java | 192 +
.../query/PlatformContinuousQueryImpl.java | 235 ++
.../PlatformContinuousQueryRemoteFilter.java | 188 +
.../cache/query/PlatformFieldsQueryCursor.java | 49 +
.../cache/query/PlatformQueryCursor.java | 45 +
.../cache/store/PlatformCacheStoreCallback.java | 61 +
.../platform/cluster/PlatformClusterGroup.java | 335 ++
.../cluster/PlatformClusterNodeFilterImpl.java | 78 +
.../platform/compute/PlatformAbstractJob.java | 156 +
.../platform/compute/PlatformAbstractTask.java | 206 +
.../PlatformBalancingMultiClosureTask.java | 83 +
...tformBalancingSingleClosureAffinityTask.java | 88 +
.../PlatformBalancingSingleClosureTask.java | 81 +
.../PlatformBroadcastingMultiClosureTask.java | 87 +
.../PlatformBroadcastingSingleClosureTask.java | 84 +
.../platform/compute/PlatformClosureJob.java | 104 +
.../platform/compute/PlatformCompute.java | 332 ++
.../platform/compute/PlatformFullJob.java | 220 ++
.../platform/compute/PlatformFullTask.java | 192 +
.../platform/cpp/PlatformCppBootstrap.java | 31 +
.../cpp/PlatformCppBootstrapFactory.java | 39 +
.../cpp/PlatformCppConfigurationClosure.java | 114 +
.../cpp/PlatformCppConfigurationEx.java | 82 +
.../datastreamer/PlatformDataStreamer.java | 227 ++
.../PlatformStreamReceiverImpl.java | 119 +
.../datastructures/PlatformAtomicLong.java | 149 +
.../dotnet/PlatformDotNetBootstrap.java | 31 +
.../dotnet/PlatformDotNetBootstrapFactory.java | 39 +
.../dotnet/PlatformDotNetCacheStore.java | 484 +++
.../dotnet/PlatformDotNetConfiguration.java | 119 -
.../PlatformDotNetConfigurationClosure.java | 258 ++
.../dotnet/PlatformDotNetConfigurationEx.java | 91 +
.../PlatformDotNetPortableConfiguration.java | 228 --
...PlatformDotNetPortableTypeConfiguration.java | 248 --
.../platform/dotnet/PlatformDotNetService.java | 27 +
.../dotnet/PlatformDotNetServiceImpl.java | 47 +
.../events/PlatformEventFilterListenerImpl.java | 186 +
.../platform/events/PlatformEvents.java | 396 ++
.../lifecycle/PlatformLifecycleBean.java | 75 +
.../platform/memory/PlatformAbstractMemory.java | 121 +
.../PlatformBigEndianInputStreamImpl.java | 136 +
.../PlatformBigEndianOutputStreamImpl.java | 196 +
.../platform/memory/PlatformExternalMemory.java | 55 +
.../memory/PlatformInputStreamImpl.java | 351 ++
.../memory/PlatformMemoryManagerImpl.java | 85 +
.../platform/memory/PlatformMemoryPool.java | 140 +
.../platform/memory/PlatformMemoryUtils.java | 467 +++
.../memory/PlatformOutputStreamImpl.java | 342 ++
.../platform/memory/PlatformPooledMemory.java | 64 +
.../platform/memory/PlatformUnpooledMemory.java | 51 +
.../messaging/PlatformMessageFilterImpl.java | 110 +
.../messaging/PlatformMessageLocalFilter.java | 102 +
.../platform/messaging/PlatformMessaging.java | 166 +
.../services/PlatformAbstractService.java | 230 ++
.../platform/services/PlatformServices.java | 275 ++
.../transactions/PlatformTransactions.java | 259 ++
.../platform/utils/PlatformFutureUtils.java | 397 ++
.../platform/utils/PlatformReaderBiClosure.java | 34 +
.../platform/utils/PlatformReaderClosure.java | 34 +
.../platform/utils/PlatformUtils.java | 809 ++++
.../platform/utils/PlatformWriterBiClosure.java | 34 +
.../platform/utils/PlatformWriterClosure.java | 33 +
.../processors/query/GridQueryIndexing.java | 18 +-
.../processors/query/GridQueryProcessor.java | 674 ++--
.../client/message/GridClientTaskRequest.java | 6 +-
.../ignite/internal/util/GridEnumCache.java | 56 -
.../ignite/internal/util/IgniteUtils.java | 34 +-
.../marshaller/portable/BinaryMarshaller.java | 146 +
.../marshaller/portable/package-info.java | 22 +
.../platform/cpp/PlatformCppConfiguration.java | 47 +
.../ignite/platform/cpp/package-info.java | 22 +
.../PlatformDotNetBinaryConfiguration.java | 170 +
.../PlatformDotNetBinaryTypeConfiguration.java | 171 +
.../dotnet/PlatformDotNetCacheStoreFactory.java | 117 +
.../dotnet/PlatformDotNetConfiguration.java | 97 +
.../dotnet/PlatformDotNetLifecycleBean.java | 86 +
.../ignite/platform/dotnet/package-info.java | 22 +
.../apache/ignite/platform/package-info.java | 22 +
.../ignite/spi/discovery/tcp/ServerImpl.java | 51 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 2 +
.../apache/ignite/spi/swapspace/SwapKey.java | 9 +-
.../resources/META-INF/classnames.properties | 268 +-
.../portable/BinaryFieldsAbstractSelfTest.java | 719 ++++
.../portable/BinaryFieldsHeapSelfTest.java | 32 +
.../portable/BinaryFieldsOffheapSelfTest.java | 61 +
.../BinaryFooterOffsetsAbstractSelfTest.java | 206 +
.../BinaryFooterOffsetsHeapSelfTest.java | 32 +
.../BinaryFooterOffsetsOffheapSelfTest.java | 61 +
.../portable/BinaryMarshallerSelfTest.java | 3671 ++++++++++++++++++
.../BinaryObjectBuilderAdditionalSelfTest.java | 1292 ++++++
.../portable/BinaryObjectBuilderSelfTest.java | 1069 +++++
.../GridPortableAffinityKeySelfTest.java | 225 ++
...idPortableMarshallerCtxDisabledSelfTest.java | 248 ++
.../portable/GridPortableMetaDataSelfTest.java | 372 ++
.../portable/GridPortableWildcardsSelfTest.java | 465 +++
.../portable/TestCachingMetadataHandler.java | 45 +
.../GridBinaryMarshalerAwareTestClass.java | 67 +
.../mutabletest/GridPortableTestClasses.java | 443 +++
.../portable/mutabletest/package-info.java | 22 +
.../BinaryFieldsHeapNonCompactSelfTest.java | 30 +
.../BinaryFieldsOffheapNonCompactSelfTest.java | 30 +
...naryFooterOffsetsHeapNonCompactSelfTest.java | 30 +
...yFooterOffsetsOffheapNonCompactSelfTest.java | 30 +
.../BinaryMarshallerNonCompactSelfTest.java | 30 +
...jectBuilderAdditionalNonCompactSelfTest.java | 30 +
.../BinaryObjectBuilderNonCompactSelfTest.java | 30 +
.../ignite/internal/portable/package-info.java | 22 +
.../portable/test/GridPortableTestClass1.java | 28 +
.../portable/test/GridPortableTestClass2.java | 24 +
.../internal/portable/test/package-info.java | 22 +
.../test/subpackage/GridPortableTestClass3.java | 24 +
.../portable/test/subpackage/package-info.java | 22 +
.../cache/CacheNearReaderUpdateTest.java | 62 +-
.../cache/GridCacheAbstractSelfTest.java | 9 +-
...heOffHeapTieredEvictionAbstractSelfTest.java | 2 +-
.../processors/cache/GridCacheTestEntryEx.java | 13 +-
.../cache/IgniteCachePeekModesAbstractTest.java | 30 +-
...IgniteCacheAbstractExecutionContextTest.java | 5 +
...tractDistributedByteArrayValuesSelfTest.java | 4 +
...naryObjectsAbstractDataStreamerSelfTest.java | 192 +
...aryObjectsAbstractMultiThreadedSelfTest.java | 233 ++
.../GridCacheBinaryObjectsAbstractSelfTest.java | 981 +++++
...ntNodeBinaryObjectMetadataMultinodeTest.java | 295 ++
...CacheClientNodeBinaryObjectMetadataTest.java | 221 ++
.../GridCachePortableStoreAbstractSelfTest.java | 300 ++
.../GridCachePortableStoreObjectsSelfTest.java | 55 +
...GridCachePortableStorePortablesSelfTest.java | 66 +
...ridPortableCacheEntryMemorySizeSelfTest.java | 48 +
...leDuplicateIndexObjectsAbstractSelfTest.java | 161 +
.../DataStreamProcessorPortableSelfTest.java | 71 +
.../GridDataStreamerImplSelfTest.java | 345 ++
...ridCacheAffinityRoutingPortableSelfTest.java | 54 +
...lyPortableDataStreamerMultiNodeSelfTest.java | 29 +
...rtableDataStreamerMultithreadedSelfTest.java | 47 +
...artitionedOnlyPortableMultiNodeSelfTest.java | 28 +
...tionedOnlyPortableMultithreadedSelfTest.java | 47 +
...AtomicNearDisabledOffheapTieredSelfTest.java | 29 +
...BinaryObjectsAtomicNearDisabledSelfTest.java | 51 +
...inaryObjectsAtomicOffheapTieredSelfTest.java | 29 +
.../GridCacheBinaryObjectsAtomicSelfTest.java | 51 +
...tionedNearDisabledOffheapTieredSelfTest.java | 30 +
...yObjectsPartitionedNearDisabledSelfTest.java | 51 +
...ObjectsPartitionedOffheapTieredSelfTest.java | 30 +
...idCacheBinaryObjectsPartitionedSelfTest.java | 51 +
.../GridCacheMemoryModePortableSelfTest.java | 36 +
...acheOffHeapTieredAtomicPortableSelfTest.java | 48 +
...eapTieredEvictionAtomicPortableSelfTest.java | 96 +
...heOffHeapTieredEvictionPortableSelfTest.java | 96 +
.../GridCacheOffHeapTieredPortableSelfTest.java | 48 +
...ateIndexObjectPartitionedAtomicSelfTest.java | 38 +
...xObjectPartitionedTransactionalSelfTest.java | 41 +
...sNearPartitionedByteArrayValuesSelfTest.java | 41 +
...sPartitionedOnlyByteArrayValuesSelfTest.java | 42 +
...ridCacheBinaryObjectsReplicatedSelfTest.java | 51 +
...idCacheBinaryObjectsAtomicLocalSelfTest.java | 32 +
...BinaryObjectsLocalOffheapTieredSelfTest.java | 29 +
.../GridCacheBinaryObjectsLocalSelfTest.java | 51 +
.../CacheVersionedEntryAbstractTest.java | 2 +-
.../continuous/GridEventConsumeSelfTest.java | 111 +-
.../DataStreamProcessorSelfTest.java | 8 +
.../loadtests/hashmap/GridHashMapLoadTest.java | 3 +-
.../platform/PlatformComputeBinarizable.java | 42 +
.../PlatformComputeBinarizableArgTask.java | 119 +
.../platform/PlatformComputeBroadcastTask.java | 73 +
.../platform/PlatformComputeDecimalTask.java | 106 +
.../platform/PlatformComputeEchoTask.java | 188 +
.../ignite/platform/PlatformComputeEnum.java | 28 +
.../PlatformComputeJavaBinarizable.java | 39 +
.../platform/PlatformEventsWriteEventTask.java | 144 +
.../ignite/platform/PlatformMaxMemoryTask.java | 57 +
.../ignite/platform/PlatformMinMemoryTask.java | 57 +
.../lifecycle/PlatformJavaLifecycleBean.java | 47 +
.../lifecycle/PlatformJavaLifecycleTask.java | 65 +
.../file/GridFileSwapSpaceSpiSelfTest.java | 11 +-
.../testframework/junits/GridAbstractTest.java | 4 +-
.../ignite/testframework/junits/IgniteMock.java | 6 +
.../multijvm/IgniteCacheProcessProxy.java | 7 +-
.../junits/multijvm/IgniteProcessProxy.java | 4 +-
.../IgnitePortableCacheFullApiTestSuite.java | 37 +
.../IgnitePortableCacheTestSuite.java | 103 +
.../IgnitePortableObjectsTestSuite.java | 110 +
.../ignite/portable/test1/1.1/test1-1.1.jar | Bin 0 -> 2548 bytes
.../ignite/portable/test1/1.1/test1-1.1.pom | 9 +
.../portable/test1/maven-metadata-local.xml | 12 +
.../ignite/portable/test2/1.1/test2-1.1.jar | Bin 0 -> 1361 bytes
.../ignite/portable/test2/1.1/test2-1.1.pom | 9 +
.../portable/test2/maven-metadata-local.xml | 12 +
.../HadoopDefaultMapReducePlannerSelfTest.java | 6 -
.../processors/query/h2/IgniteH2Indexing.java | 25 +-
.../query/h2/opt/GridH2ValueCacheObject.java | 8 +-
.../query/h2/opt/GridLuceneIndex.java | 4 +-
.../IgniteCacheAbstractFieldsQuerySelfTest.java | 3 +-
...CacheOffheapTieredMultithreadedSelfTest.java | 25 +-
...niteCacheP2pUnmarshallingQueryErrorTest.java | 22 +-
...hePartitionedQueryMultiThreadedSelfTest.java | 22 +-
.../query/IgniteSqlSplitterSelfTest.java | 54 +
.../h2/GridIndexingSpiAbstractSelfTest.java | 7 +-
.../IgnitePortableCacheQueryTestSuite.java | 117 +
modules/platform/licenses/apache-2.0.txt | 202 -
modules/platform/pom.xml | 80 -
modules/platform/src/main/cpp/README.txt | 103 -
.../platform/src/main/cpp/common/Makefile.am | 45 -
.../platform/src/main/cpp/common/configure.ac | 62 -
.../src/main/cpp/common/ignite-common.pc.in | 9 -
.../src/main/cpp/common/include/Makefile.am | 22 -
.../common/include/ignite/common/concurrent.h | 210 -
.../cpp/common/include/ignite/common/exports.h | 145 -
.../cpp/common/include/ignite/common/java.h | 652 ----
.../cpp/common/os/linux/include/Makefile.am | 21 -
.../os/linux/include/ignite/common/common.h | 81 -
.../linux/include/ignite/common/concurrent_os.h | 394 --
.../src/main/cpp/common/os/linux/src/common.cpp | 59 -
.../cpp/common/os/linux/src/concurrent_os.cpp | 175 -
.../os/win/include/ignite/common/common.h | 56 -
.../win/include/ignite/common/concurrent_os.h | 406 --
.../src/main/cpp/common/os/win/src/common.cpp | 65 -
.../cpp/common/os/win/src/concurrent_os.cpp | 151 -
.../src/main/cpp/common/project/README.TXT | 1 -
.../src/main/cpp/common/project/vs/README.TXT | 1 -
.../main/cpp/common/project/vs/common.vcxproj | 202 -
.../common/project/vs/common.vcxproj.filters | 54 -
.../src/main/cpp/common/project/vs/module.def | 99 -
.../src/main/cpp/common/project/vs/targetver.h | 25 -
.../src/main/cpp/common/src/concurrent.cpp | 94 -
.../src/main/cpp/common/src/exports.cpp | 413 --
.../platform/src/main/cpp/common/src/java.cpp | 2205 -----------
.../platform/src/main/cpp/core-test/Makefile.am | 49 -
.../main/cpp/core-test/config/cache-query.xml | 91 -
.../main/cpp/core-test/config/cache-test.xml | 129 -
.../src/main/cpp/core-test/configure.ac | 62 -
.../src/main/cpp/core-test/include/Makefile.am | 22 -
.../include/ignite/portable_test_defs.h | 320 --
.../include/ignite/portable_test_utils.h | 516 ---
.../cpp/core-test/include/teamcity_messages.h | 55 -
.../src/main/cpp/core-test/project/README.TXT | 1 -
.../main/cpp/core-test/project/vs/README.TXT | 1 -
.../cpp/core-test/project/vs/core-test.vcxproj | 174 -
.../project/vs/core-test.vcxproj.filters | 68 -
.../main/cpp/core-test/src/cache_query_test.cpp | 656 ----
.../src/main/cpp/core-test/src/cache_test.cpp | 486 ---
.../main/cpp/core-test/src/concurrent_test.cpp | 186 -
.../cpp/core-test/src/handle_registry_test.cpp | 176 -
.../main/cpp/core-test/src/ignition_test.cpp | 102 -
.../src/portable_reader_writer_raw_test.cpp | 1532 --------
.../src/portable_reader_writer_test.cpp | 1951 ----------
.../cpp/core-test/src/portable_session_test.cpp | 257 --
.../cpp/core-test/src/portable_test_defs.cpp | 65 -
.../main/cpp/core-test/src/teamcity_boost.cpp | 159 -
.../cpp/core-test/src/teamcity_messages.cpp | 150 -
modules/platform/src/main/cpp/core/Makefile.am | 66 -
modules/platform/src/main/cpp/core/configure.ac | 62 -
modules/platform/src/main/cpp/core/ignite.pc.in | 9 -
.../src/main/cpp/core/include/Makefile.am | 61 -
.../main/cpp/core/include/ignite/cache/cache.h | 1153 ------
.../cpp/core/include/ignite/cache/cache_entry.h | 118 -
.../core/include/ignite/cache/cache_peek_mode.h | 71 -
.../cpp/core/include/ignite/cache/query/query.h | 27 -
.../include/ignite/cache/query/query_argument.h | 125 -
.../include/ignite/cache/query/query_cursor.h | 191 -
.../include/ignite/cache/query/query_scan.h | 151 -
.../core/include/ignite/cache/query/query_sql.h | 253 --
.../include/ignite/cache/query/query_text.h | 159 -
.../src/main/cpp/core/include/ignite/guid.h | 112 -
.../src/main/cpp/core/include/ignite/ignite.h | 154 -
.../core/include/ignite/ignite_configuration.h | 92 -
.../main/cpp/core/include/ignite/ignite_error.h | 260 --
.../src/main/cpp/core/include/ignite/ignition.h | 195 -
.../core/include/ignite/impl/cache/cache_impl.h | 418 --
.../ignite/impl/cache/query/query_impl.h | 115 -
.../core/include/ignite/impl/handle_registry.h | 202 -
.../include/ignite/impl/ignite_environment.h | 130 -
.../cpp/core/include/ignite/impl/ignite_impl.h | 146 -
.../core/include/ignite/impl/interop/interop.h | 25 -
.../ignite/impl/interop/interop_input_stream.h | 234 --
.../ignite/impl/interop/interop_memory.h | 280 --
.../ignite/impl/interop/interop_output_stream.h | 234 --
.../cpp/core/include/ignite/impl/operations.h | 452 ---
.../ignite/impl/portable/portable_common.h | 146 -
.../ignite/impl/portable/portable_id_resolver.h | 106 -
.../impl/portable/portable_metadata_handler.h | 102 -
.../impl/portable/portable_metadata_manager.h | 120 -
.../impl/portable/portable_metadata_snapshot.h | 122 -
.../impl/portable/portable_metadata_updater.h | 53 -
.../portable/portable_metadata_updater_impl.h | 65 -
.../ignite/impl/portable/portable_reader_impl.h | 1130 ------
.../ignite/impl/portable/portable_utils.h | 344 --
.../ignite/impl/portable/portable_writer_impl.h | 859 ----
.../cpp/core/include/ignite/portable/portable.h | 29 -
.../include/ignite/portable/portable_consts.h | 106 -
.../ignite/portable/portable_containers.h | 525 ---
.../ignite/portable/portable_raw_reader.h | 324 --
.../ignite/portable/portable_raw_writer.h | 300 --
.../include/ignite/portable/portable_reader.h | 355 --
.../include/ignite/portable/portable_type.h | 293 --
.../include/ignite/portable/portable_writer.h | 335 --
.../main/cpp/core/os/linux/include/Makefile.am | 20 -
.../core/os/linux/include/ignite/impl/utils.h | 155 -
.../main/cpp/core/os/linux/src/impl/utils.cpp | 439 ---
.../cpp/core/os/win/include/ignite/impl/utils.h | 155 -
.../src/main/cpp/core/os/win/src/impl/utils.cpp | 453 ---
.../src/main/cpp/core/project/README.TXT | 1 -
.../src/main/cpp/core/project/vs/README.TXT | 1 -
.../src/main/cpp/core/project/vs/core.vcxproj | 272 --
.../cpp/core/project/vs/core.vcxproj.filters | 246 --
modules/platform/src/main/cpp/core/src/guid.cpp | 65 -
.../platform/src/main/cpp/core/src/ignite.cpp | 43 -
.../src/main/cpp/core/src/ignite_error.cpp | 222 --
.../platform/src/main/cpp/core/src/ignition.cpp | 468 ---
.../main/cpp/core/src/impl/cache/cache_impl.cpp | 388 --
.../core/src/impl/cache/query/query_impl.cpp | 193 -
.../main/cpp/core/src/impl/handle_registry.cpp | 234 --
.../cpp/core/src/impl/ignite_environment.cpp | 167 -
.../src/main/cpp/core/src/impl/ignite_impl.cpp | 42 -
.../src/impl/interop/interop_input_stream.cpp | 215 -
.../core/src/impl/interop/interop_memory.cpp | 182 -
.../src/impl/interop/interop_output_stream.cpp | 215 -
.../impl/portable/portable_metadata_handler.cpp | 78 -
.../impl/portable/portable_metadata_manager.cpp | 201 -
.../portable/portable_metadata_snapshot.cpp | 70 -
.../impl/portable/portable_metadata_updater.cpp | 32 -
.../portable/portable_metadata_updater_impl.cpp | 94 -
.../src/impl/portable/portable_reader_impl.cpp | 683 ----
.../core/src/impl/portable/portable_utils.cpp | 214 -
.../src/impl/portable/portable_writer_impl.cpp | 600 ---
.../core/src/portable/portable_containers.cpp | 76 -
.../core/src/portable/portable_raw_reader.cpp | 135 -
.../core/src/portable/portable_raw_writer.cpp | 147 -
.../cpp/core/src/portable/portable_reader.cpp | 142 -
.../cpp/core/src/portable/portable_type.cpp | 51 -
.../cpp/core/src/portable/portable_writer.cpp | 154 -
.../platform/src/main/cpp/project/vs/ignite.sln | 48 -
.../Apache.Ignite.Core.csproj | 376 --
.../Cache/CacheAtomicUpdateTimeoutException.cs | 67 -
.../Cache/CacheEntryProcessorException.cs | 79 -
.../Apache.Ignite.Core/Cache/CacheException.cs | 68 -
.../Cache/CachePartialUpdateException.cs | 119 -
.../Apache.Ignite.Core/Cache/CachePeekMode.cs | 68 -
.../Cache/Event/CacheEntryEventType.cs | 41 -
.../Cache/Event/ICacheEntryEvent.cs | 40 -
.../Cache/Event/ICacheEntryEventFilter.cs | 31 -
.../Cache/Event/ICacheEntryEventListener.cs | 33 -
.../Cache/Expiry/ExpiryPolicy.cs | 89 -
.../Cache/Expiry/IExpiryPolicy.cs | 59 -
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 542 ---
.../Apache.Ignite.Core/Cache/ICacheAffinity.cs | 161 -
.../Apache.Ignite.Core/Cache/ICacheEntry.cs | 37 -
.../Cache/ICacheEntryFilter.cs | 34 -
.../Cache/ICacheEntryProcessor.cs | 45 -
.../Cache/ICacheEntryProcessorResult.cs | 40 -
.../Apache.Ignite.Core/Cache/ICacheLock.cs | 58 -
.../Apache.Ignite.Core/Cache/ICacheMetrics.cs | 486 ---
.../Cache/IMutableCacheEntry.cs | 47 -
.../Cache/Query/Continuous/ContinuousQuery.cs | 170 -
.../Query/Continuous/IContinuousQueryHandle.cs | 51 -
.../Cache/Query/IQueryCursor.cs | 40 -
.../Apache.Ignite.Core/Cache/Query/QueryBase.cs | 82 -
.../Apache.Ignite.Core/Cache/Query/ScanQuery.cs | 77 -
.../Cache/Query/SqlFieldsQuery.cs | 81 -
.../Apache.Ignite.Core/Cache/Query/SqlQuery.cs | 119 -
.../Apache.Ignite.Core/Cache/Query/TextQuery.cs | 104 -
.../Store/CacheParallelLoadStoreAdapter.cs | 205 -
.../Cache/Store/CacheStoreAdapter.cs | 146 -
.../Cache/Store/CacheStoreException.cs | 66 -
.../Cache/Store/ICacheStore.cs | 184 -
.../Cache/Store/ICacheStoreSession.cs | 42 -
.../Cluster/ClusterGroupEmptyException.cs | 70 -
.../Cluster/ClusterTopologyException.cs | 69 -
.../Apache.Ignite.Core/Cluster/ICluster.cs | 80 -
.../Apache.Ignite.Core/Cluster/IClusterGroup.cs | 229 --
.../Cluster/IClusterMetrics.cs | 515 ---
.../Apache.Ignite.Core/Cluster/IClusterNode.cs | 138 -
.../Cluster/IClusterNodeFilter.cs | 32 -
.../Common/AsyncSupportedAttribute.cs | 33 -
.../Apache.Ignite.Core/Common/IAsyncSupport.cs | 52 -
.../dotnet/Apache.Ignite.Core/Common/IFuture.cs | 115 -
.../Common/IgniteException.cs | 66 -
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 138 -
.../ComputeExecutionRejectedException.cs | 69 -
.../Compute/ComputeJobAdapter.cs | 122 -
.../Compute/ComputeJobFailoverException.cs | 72 -
.../Compute/ComputeJobResultPolicy.cs | 45 -
.../Compute/ComputeTaskAdapter.cs | 93 -
.../Compute/ComputeTaskCancelledException.cs | 69 -
.../ComputeTaskNoResultCacheAttribute.cs | 35 -
.../Compute/ComputeTaskSplitAdapter.cs | 95 -
.../Compute/ComputeTaskTimeoutException.cs | 67 -
.../Compute/ComputeUserUndeclaredException.cs | 70 -
.../Apache.Ignite.Core/Compute/ICompute.cs | 274 --
.../Apache.Ignite.Core/Compute/IComputeFunc.cs | 55 -
.../Apache.Ignite.Core/Compute/IComputeJob.cs | 58 -
.../Compute/IComputeJobResult.cs | 73 -
.../Compute/IComputeReducer.cs | 39 -
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 132 -
.../Datastream/IDataStreamer.cs | 206 -
.../Datastream/IStreamReceiver.cs | 38 -
.../Datastream/StreamTransformer.cs | 73 -
.../Datastream/StreamVisitor.cs | 55 -
.../Apache.Ignite.Core/Events/CacheEvent.cs | 176 -
.../Events/CacheQueryExecutedEvent.cs | 97 -
.../Events/CacheQueryReadEvent.cs | 134 -
.../Events/CacheRebalancingEvent.cs | 98 -
.../Events/CheckpointEvent.cs | 50 -
.../Apache.Ignite.Core/Events/DiscoveryEvent.cs | 80 -
.../Apache.Ignite.Core/Events/EventBase.cs | 160 -
.../Apache.Ignite.Core/Events/EventReader.cs | 72 -
.../Apache.Ignite.Core/Events/EventType.cs | 514 ---
.../dotnet/Apache.Ignite.Core/Events/IEvent.cs | 74 -
.../Apache.Ignite.Core/Events/IEventFilter.cs | 36 -
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 182 -
.../Apache.Ignite.Core/Events/JobEvent.cs | 100 -
.../Apache.Ignite.Core/Events/SwapSpaceEvent.cs | 50 -
.../Apache.Ignite.Core/Events/TaskEvent.cs | 91 -
.../main/dotnet/Apache.Ignite.Core/IIgnite.cs | 168 -
.../Apache.Ignite.Core/IgniteConfiguration.cs | 140 -
.../main/dotnet/Apache.Ignite.Core/Ignition.cs | 657 ----
.../Impl/Cache/CacheAffinityImpl.cs | 275 --
.../Apache.Ignite.Core/Impl/Cache/CacheEntry.cs | 126 -
.../Impl/Cache/CacheEntryFilterHolder.cs | 147 -
.../Impl/Cache/CacheEntryProcessorHolder.cs | 145 -
.../Impl/Cache/CacheEntryProcessorResult.cs | 65 -
.../Cache/CacheEntryProcessorResultHolder.cs | 127 -
.../Impl/Cache/CacheEnumerable.cs | 82 -
.../Impl/Cache/CacheEnumerator.cs | 117 -
.../Impl/Cache/CacheEnumeratorProxy.cs | 156 -
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 940 -----
.../Apache.Ignite.Core/Impl/Cache/CacheLock.cs | 171 -
.../Impl/Cache/CacheMetricsImpl.cs | 248 --
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 63 -
.../Impl/Cache/CacheProxyImpl.cs | 499 ---
.../Impl/Cache/Event/CacheEntryCreateEvent.cs | 74 -
.../Impl/Cache/Event/CacheEntryRemoveEvent.cs | 74 -
.../Impl/Cache/Event/CacheEntryUpdateEvent.cs | 79 -
.../Impl/Cache/MutableCacheEntry.cs | 163 -
.../Impl/Cache/Query/AbstractQueryCursor.cs | 264 --
.../Query/Continuous/ContinuousQueryFilter.cs | 125 -
.../Continuous/ContinuousQueryFilterHolder.cs | 118 -
.../Continuous/ContinuousQueryHandleImpl.cs | 216 --
.../Query/Continuous/ContinuousQueryUtils.cs | 115 -
.../Impl/Cache/Query/FieldsQueryCursor.cs | 54 -
.../Impl/Cache/Query/QueryCursor.cs | 50 -
.../Impl/Cache/Store/CacheStore.cs | 263 --
.../Impl/Cache/Store/CacheStoreSession.cs | 53 -
.../Impl/Cache/Store/CacheStoreSessionProxy.cs | 63 -
.../Impl/Cluster/ClusterGroupImpl.cs | 577 ---
.../Impl/Cluster/ClusterMetricsImpl.cs | 292 --
.../Impl/Cluster/ClusterNodeImpl.cs | 221 --
.../Impl/Cluster/IClusterGroupEx.cs | 35 -
.../Impl/Collections/CollectionExtensions.cs | 45 -
.../Impl/Collections/MultiValueDictionary.cs | 143 -
.../Impl/Collections/ReadOnlyCollection.cs | 102 -
.../Impl/Collections/ReadOnlyDictionary.cs | 149 -
.../Impl/Common/AsyncResult.cs | 71 -
.../Impl/Common/CompletedAsyncResult.cs | 70 -
.../Common/CopyOnWriteConcurrentDictionary.cs | 70 -
.../Impl/Common/DelegateConverter.cs | 253 --
.../Impl/Common/DelegateTypeDescriptor.cs | 314 --
.../Apache.Ignite.Core/Impl/Common/Future.cs | 286 --
.../Impl/Common/FutureConverter.cs | 62 -
.../Impl/Common/FutureType.cs | 52 -
.../Impl/Common/IFutureConverter.cs | 34 -
.../Impl/Common/IFutureInternal.cs | 46 -
.../Impl/Common/IgniteArgumentCheck.cs | 76 -
.../Impl/Common/LoadedAssembliesResolver.cs | 96 -
.../Impl/Common/PortableResultWrapper.cs | 68 -
.../Impl/Common/TypeCaster.cs | 72 -
.../Closure/ComputeAbstractClosureTask.cs | 101 -
.../Impl/Compute/Closure/ComputeActionJob.cs | 83 -
.../Impl/Compute/Closure/ComputeFuncJob.cs | 89 -
.../Compute/Closure/ComputeMultiClosureTask.cs | 56 -
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 76 -
.../Closure/ComputeReducingClosureTask.cs | 61 -
.../Compute/Closure/ComputeSingleClosureTask.cs | 48 -
.../Compute/Closure/IComputeResourceInjector.cs | 31 -
.../Apache.Ignite.Core/Impl/Compute/Compute.cs | 213 -
.../Impl/Compute/ComputeAsync.cs | 261 --
.../Impl/Compute/ComputeFunc.cs | 119 -
.../Impl/Compute/ComputeImpl.cs | 645 ---
.../Impl/Compute/ComputeJob.cs | 163 -
.../Impl/Compute/ComputeJobHolder.cs | 246 --
.../Compute/ComputeJobResultGenericWrapper.cs | 70 -
.../Impl/Compute/ComputeJobResultImpl.cs | 96 -
.../Impl/Compute/ComputeOutFunc.cs | 123 -
.../Impl/Compute/ComputeTaskHolder.cs | 484 ---
.../Impl/Datastream/DataStreamerBatch.cs | 269 --
.../Impl/Datastream/DataStreamerEntry.cs | 64 -
.../Impl/Datastream/DataStreamerImpl.cs | 832 ----
.../Impl/Datastream/DataStreamerRemoveEntry.cs | 48 -
.../Impl/Datastream/StreamReceiverHolder.cs | 144 -
.../Apache.Ignite.Core/Impl/Events/Events.cs | 498 ---
.../Impl/Events/EventsAsync.cs | 158 -
.../Impl/Events/RemoteListenEventFilter.cs | 85 -
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 204 -
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 69 -
.../Impl/Handle/HandleRegistry.cs | 340 --
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 35 -
.../Apache.Ignite.Core/Impl/IInteropCallback.cs | 34 -
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 549 ---
.../Impl/IgniteConfigurationEx.cs | 57 -
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 490 ---
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 351 --
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 438 ---
.../Impl/Interop/InteropDotNetConfiguration.cs | 62 -
.../InteropDotNetPortableConfiguration.cs | 127 -
.../InteropDotNetPortableTypeConfiguration.cs | 151 -
.../Impl/InteropExceptionHolder.cs | 85 -
.../Impl/LifecycleBeanHolder.cs | 66 -
.../Impl/Memory/IPlatformMemory.cs | 65 -
.../Impl/Memory/InteropExternalMemory.cs | 46 -
.../Impl/Memory/InteropMemoryUtils.cs | 38 -
.../Memory/PlatformBigEndianMemoryStream.cs | 483 ---
.../Impl/Memory/PlatformMemory.cs | 78 -
.../Impl/Memory/PlatformMemoryManager.cs | 107 -
.../Impl/Memory/PlatformMemoryPool.cs | 106 -
.../Impl/Memory/PlatformMemoryStream.cs | 677 ----
.../Impl/Memory/PlatformMemoryUtils.cs | 463 ---
.../Impl/Memory/PlatformPooledMemory.cs | 70 -
.../Impl/Memory/PlatformRawMemory.cs | 89 -
.../Impl/Memory/PlatformUnpooledMemory.cs | 52 -
.../Impl/Messaging/MessageFilterHolder.cs | 179 -
.../Impl/Messaging/Messaging.cs | 262 --
.../Impl/Messaging/MessagingAsync.cs | 68 -
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 47 -
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 715 ----
.../Portable/IPortableSystemTypeSerializer.cs | 34 -
.../Impl/Portable/IPortableTypeDescriptor.cs | 124 -
.../Impl/Portable/IPortableWriteAware.cs | 34 -
.../Impl/Portable/Io/IPortableStream.cs | 320 --
.../Impl/Portable/Io/PortableAbstractStream.cs | 1298 -------
.../Impl/Portable/Io/PortableHeapStream.cs | 447 ---
.../Impl/Portable/Io/PortableStreamAdapter.cs | 114 -
.../Metadata/IPortableMetadataHandler.cs | 41 -
.../Metadata/PortableHashsetMetadataHandler.cs | 69 -
.../Portable/Metadata/PortableMetadataHolder.cs | 149 -
.../Portable/Metadata/PortableMetadataImpl.cs | 200 -
.../Impl/Portable/PortableBuilderField.cs | 73 -
.../Impl/Portable/PortableBuilderImpl.cs | 923 -----
.../Impl/Portable/PortableCollectionInfo.cs | 251 --
.../Impl/Portable/PortableFullTypeDescriptor.cs | 203 -
.../Impl/Portable/PortableHandleDictionary.cs | 187 -
.../Portable/PortableMarshalAwareSerializer.cs | 45 -
.../Impl/Portable/PortableMarshaller.cs | 603 ---
.../Impl/Portable/PortableMode.cs | 40 -
.../Impl/Portable/PortableObjectHandle.cs | 59 -
.../PortableOrSerializableObjectHolder.cs | 66 -
.../Portable/PortableReaderHandleDictionary.cs | 42 -
.../Impl/Portable/PortableReaderImpl.cs | 1013 -----
.../Impl/Portable/PortableReflectiveRoutines.cs | 483 ---
.../Portable/PortableReflectiveSerializer.cs | 218 --
.../Portable/PortableSurrogateTypeDescriptor.cs | 133 -
.../Impl/Portable/PortableSystemHandlers.cs | 1336 -------
.../Portable/PortableSystemTypeSerializer.cs | 62 -
.../Impl/Portable/PortableUserObject.cs | 385 --
.../Impl/Portable/PortableUtils.cs | 2039 ----------
.../Impl/Portable/PortableWriterImpl.cs | 1305 -------
.../Impl/Portable/PortablesImpl.cs | 205 -
.../Impl/Portable/SerializableObjectHolder.cs | 66 -
.../Impl/Portable/TypeResolver.cs | 227 --
.../Impl/Resource/IResourceInjector.cs | 27 -
.../Impl/Resource/ResourceFieldInjector.cs | 47 -
.../Impl/Resource/ResourceMethodInjector.cs | 48 -
.../Impl/Resource/ResourceProcessor.cs | 105 -
.../Impl/Resource/ResourcePropertyInjector.cs | 47 -
.../Impl/Resource/ResourceTypeDescriptor.cs | 291 --
.../Impl/Services/ServiceContext.cs | 60 -
.../Impl/Services/ServiceDescriptor.cs | 106 -
.../Impl/Services/ServiceProxy.cs | 71 -
.../Impl/Services/ServiceProxyInvoker.cs | 136 -
.../Impl/Services/ServiceProxySerializer.cs | 140 -
.../Impl/Services/Services.cs | 316 --
.../Impl/Services/ServicesAsync.cs | 89 -
.../Impl/Transactions/AsyncTransaction.cs | 78 -
.../Impl/Transactions/Transaction.cs | 155 -
.../Impl/Transactions/TransactionImpl.cs | 489 ---
.../Impl/Transactions/TransactionMetricsImpl.cs | 62 -
.../Impl/Transactions/TransactionsImpl.cs | 201 -
.../Impl/Unmanaged/IUnmanagedTarget.cs | 42 -
.../Impl/Unmanaged/UnmanagedCallbackHandlers.cs | 99 -
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 1154 ------
.../Impl/Unmanaged/UnmanagedContext.cs | 53 -
.../Unmanaged/UnmanagedNonReleaseableTarget.cs | 68 -
.../Impl/Unmanaged/UnmanagedTarget.cs | 77 -
.../Impl/Unmanaged/UnmanagedUtils.cs | 1263 ------
.../Lifecycle/ILifecycleBean.cs | 64 -
.../Lifecycle/LifecycleEventType.cs | 49 -
.../Messaging/IMessageFilter.cs | 35 -
.../Apache.Ignite.Core/Messaging/IMessaging.cs | 105 -
.../Portable/IPortableBuilder.cs | 78 -
.../Portable/IPortableIdMapper.cs | 40 -
.../Portable/IPortableMarshalAware.cs | 39 -
.../Portable/IPortableMetadata.cs | 61 -
.../Portable/IPortableNameMapper.cs | 39 -
.../Portable/IPortableObject.cs | 44 -
.../Portable/IPortableRawReader.cs | 264 --
.../Portable/IPortableRawWriter.cs | 221 --
.../Portable/IPortableReader.cs | 340 --
.../Portable/IPortableSerializer.cs | 39 -
.../Portable/IPortableWriter.cs | 259 --
.../Apache.Ignite.Core/Portable/IPortables.cs | 120 -
.../Portable/PortableConfiguration.cs | 122 -
.../Portable/PortableException.cs | 64 -
.../Portable/PortableTypeConfiguration.cs | 162 -
.../Portable/PortableTypeNames.cs | 115 -
.../Properties/AssemblyInfo.cs | 46 -
.../Resource/InstanceResourceAttribute.cs | 35 -
.../Resource/StoreSessionResourceAttribute.cs | 32 -
.../Apache.Ignite.Core/Services/IService.cs | 51 -
.../Services/IServiceContext.cs | 69 -
.../Services/IServiceDescriptor.cs | 96 -
.../Apache.Ignite.Core/Services/IServices.cs | 181 -
.../Services/ServiceConfiguration.cs | 62 -
.../Services/ServiceInvocationException.cs | 101 -
.../Transactions/ITransaction.cs | 230 --
.../Transactions/ITransactionMetrics.cs | 47 -
.../Transactions/ITransactions.cs | 73 -
.../Transactions/TransactionConcurrency.cs | 36 -
.../TransactionHeuristicException.cs | 72 -
.../Transactions/TransactionIsolation.cs | 41 -
.../TransactionOptimisticException.cs | 69 -
.../TransactionRollbackException.cs | 68 -
.../Transactions/TransactionState.cs | 70 -
.../Transactions/TransactionTimeoutException.cs | 69 -
.../platform/src/main/dotnet/Apache.Ignite.sln | 68 -
.../main/dotnet/Apache.Ignite.sln.DotSettings | 4 -
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 76 -
.../src/main/dotnet/Apache.Ignite/App.config | 56 -
.../Config/AppSettingsConfigurator.cs | 113 -
.../Apache.Ignite/Config/ArgsConfigurator.cs | 164 -
.../Apache.Ignite/Config/ConfigValueParser.cs | 42 -
.../Apache.Ignite/Config/IConfigurator.cs | 34 -
.../main/dotnet/Apache.Ignite/IgniteRunner.cs | 171 -
.../Apache.Ignite/Properties/AssemblyInfo.cs | 35 -
.../Apache.Ignite/Service/IgniteService.cs | 219 --
.../Apache.Ignite/Service/NativeMethods.cs | 57 -
.../Apache.Ignite/Service/ServiceDescription.cs | 32 -
...processors.platform.PlatformBootstrapFactory | 2 -
.../platform/PlatformAbstractBootstrap.java | 48 -
.../PlatformAbstractConfigurationClosure.java | 61 -
.../platform/PlatformAbstractPredicate.java | 67 -
.../platform/PlatformAbstractTarget.java | 320 --
.../processors/platform/PlatformBootstrap.java | 35 -
.../platform/PlatformBootstrapFactory.java | 37 -
.../platform/PlatformConfigurationEx.java | 48 -
.../platform/PlatformContextImpl.java | 621 ---
.../processors/platform/PlatformIgnition.java | 189 -
.../platform/PlatformProcessorImpl.java | 359 --
.../platform/cache/PlatformCache.java | 1090 ------
.../cache/PlatformCacheEntryFilterImpl.java | 106 -
.../cache/PlatformCacheEntryProcessorImpl.java | 220 --
.../platform/cache/PlatformCacheIterator.java | 72 -
.../PlatformCachePartialUpdateException.java | 59 -
.../cache/affinity/PlatformAffinity.java | 296 --
.../query/PlatformAbstractQueryCursor.java | 192 -
.../query/PlatformContinuousQueryImpl.java | 235 --
.../PlatformContinuousQueryRemoteFilter.java | 188 -
.../cache/query/PlatformFieldsQueryCursor.java | 49 -
.../cache/query/PlatformQueryCursor.java | 45 -
.../cache/store/PlatformCacheStoreCallback.java | 61 -
.../platform/cluster/PlatformClusterGroup.java | 335 --
.../cluster/PlatformClusterNodeFilterImpl.java | 78 -
.../platform/compute/PlatformAbstractJob.java | 156 -
.../platform/compute/PlatformAbstractTask.java | 206 -
.../PlatformBalancingMultiClosureTask.java | 83 -
...tformBalancingSingleClosureAffinityTask.java | 88 -
.../PlatformBalancingSingleClosureTask.java | 81 -
.../PlatformBroadcastingMultiClosureTask.java | 87 -
.../PlatformBroadcastingSingleClosureTask.java | 84 -
.../platform/compute/PlatformClosureJob.java | 104 -
.../platform/compute/PlatformCompute.java | 332 --
.../platform/compute/PlatformFullJob.java | 220 --
.../platform/compute/PlatformFullTask.java | 192 -
.../platform/cpp/PlatformCppBootstrap.java | 31 -
.../cpp/PlatformCppBootstrapFactory.java | 39 -
.../cpp/PlatformCppConfigurationClosure.java | 99 -
.../cpp/PlatformCppConfigurationEx.java | 82 -
.../datastreamer/PlatformDataStreamer.java | 226 --
.../PlatformStreamReceiverImpl.java | 119 -
.../dotnet/PlatformDotNetBootstrap.java | 31 -
.../dotnet/PlatformDotNetBootstrapFactory.java | 39 -
.../dotnet/PlatformDotNetCacheStore.java | 497 ---
.../PlatformDotNetConfigurationClosure.java | 254 --
.../dotnet/PlatformDotNetConfigurationEx.java | 90 -
.../platform/dotnet/PlatformDotNetService.java | 27 -
.../dotnet/PlatformDotNetServiceImpl.java | 47 -
.../events/PlatformEventFilterListenerImpl.java | 163 -
.../platform/events/PlatformEvents.java | 396 --
.../lifecycle/PlatformLifecycleBean.java | 75 -
.../platform/memory/PlatformAbstractMemory.java | 121 -
.../PlatformBigEndianInputStreamImpl.java | 126 -
.../PlatformBigEndianOutputStreamImpl.java | 161 -
.../platform/memory/PlatformExternalMemory.java | 55 -
.../memory/PlatformInputStreamImpl.java | 331 --
.../memory/PlatformMemoryManagerImpl.java | 85 -
.../platform/memory/PlatformMemoryPool.java | 140 -
.../platform/memory/PlatformMemoryUtils.java | 467 ---
.../memory/PlatformOutputStreamImpl.java | 267 --
.../platform/memory/PlatformPooledMemory.java | 64 -
.../platform/memory/PlatformUnpooledMemory.java | 51 -
.../messaging/PlatformMessageFilterImpl.java | 110 -
.../messaging/PlatformMessageLocalFilter.java | 102 -
.../platform/messaging/PlatformMessaging.java | 166 -
.../services/PlatformAbstractService.java | 230 --
.../platform/services/PlatformServices.java | 275 --
.../transactions/PlatformTransactions.java | 259 --
.../platform/utils/PlatformFutureUtils.java | 397 --
.../platform/utils/PlatformReaderBiClosure.java | 34 -
.../platform/utils/PlatformReaderClosure.java | 34 -
.../platform/utils/PlatformUtils.java | 768 ----
.../platform/utils/PlatformWriterBiClosure.java | 34 -
.../platform/utils/PlatformWriterClosure.java | 33 -
.../platform/cpp/PlatformCppConfiguration.java | 47 -
.../ignite/platform/cpp/package-info.java | 22 -
.../dotnet/PlatformDotNetCacheStoreFactory.java | 139 -
.../dotnet/PlatformDotNetLifecycleBean.java | 109 -
.../ignite/platform/dotnet/package-info.java | 22 -
.../apache/ignite/platform/package-info.java | 22 -
.../Apache.Ignite.Core.Tests.TestDll.csproj | 52 -
.../Properties/AssemblyInfo.cs | 49 -
.../TestClass.cs | 35 -
.../Apache.Ignite.Core.Tests.csproj | 225 --
.../Cache/CacheAbstractTest.cs | 3252 ----------------
.../Cache/CacheAffinityTest.cs | 139 -
.../Cache/CacheDynamicStartTest.cs | 281 --
.../Cache/CacheEntryTest.cs | 69 -
.../Cache/CacheForkedTest.cs | 81 -
.../Cache/CacheLocalAtomicTest.cs | 57 -
.../Cache/CacheLocalTest.cs | 56 -
.../CachePartitionedAtomicNearEnabledTest.cs | 50 -
.../Cache/CachePartitionedAtomicTest.cs | 50 -
.../Cache/CachePartitionedNearEnabledTest.cs | 50 -
.../Cache/CachePartitionedTest.cs | 50 -
.../Cache/CacheReplicatedAtomicTest.cs | 60 -
.../Cache/CacheReplicatedTest.cs | 60 -
.../Cache/CacheTestAsyncWrapper.cs | 436 ---
.../Cache/Query/CacheQueriesTest.cs | 928 -----
.../Continuous/ContinuousQueryAbstractTest.cs | 1181 ------
.../ContinuousQueryAtomicBackupTest.cs | 33 -
.../ContinuousQueryAtomicNoBackupTest.cs | 34 -
.../ContinuousQueryNoBackupAbstractTest.cs | 72 -
.../ContinuousQueryTransactionalBackupTest.cs | 34 -
.../ContinuousQueryTransactionalNoBackupTest.cs | 33 -
.../Cache/Store/CacheParallelLoadStoreTest.cs | 110 -
.../Cache/Store/CacheStoreSessionTest.cs | 285 --
.../Cache/Store/CacheStoreTest.cs | 510 ---
.../Cache/Store/CacheTestParallelLoadStore.cs | 91 -
.../Cache/Store/CacheTestStore.cs | 155 -
.../Compute/AbstractTaskTest.cs | 217 --
.../Compute/ClosureTaskTest.cs | 390 --
.../Compute/ComputeApiTest.cs | 1281 ------
.../Compute/ComputeMultithreadedTest.cs | 269 --
.../Compute/FailoverTaskSelfTest.cs | 246 --
.../Forked/ForkedPortableClosureTaskTest.cs | 30 -
.../Compute/Forked/ForkedResourceTaskTest.cs | 33 -
.../Forked/ForkedSerializableClosureTaskTest.cs | 33 -
.../Compute/Forked/ForkedTaskAdapterTest.cs | 30 -
.../Compute/IgniteExceptionTaskSelfTest.cs | 753 ----
.../Compute/PortableClosureTaskTest.cs | 217 --
.../Compute/PortableTaskTest.cs | 253 --
.../Compute/ResourceTaskTest.cs | 568 ---
.../Compute/SerializableClosureTaskTest.cs | 217 --
.../Compute/TaskAdapterTest.cs | 274 --
.../Compute/TaskResultTest.cs | 437 ---
.../Config/Apache.Ignite.exe.config.test | 41 -
.../Config/Cache/Store/cache-store-session.xml | 80 -
.../Config/Compute/compute-grid1.xml | 90 -
.../Config/Compute/compute-grid2.xml | 63 -
.../Config/Compute/compute-grid3.xml | 52 -
.../Config/Compute/compute-standalone.xml | 87 -
.../Config/Dynamic/dynamic-client.xml | 51 -
.../Config/Dynamic/dynamic-data-no-cfg.xml | 47 -
.../Config/Dynamic/dynamic-data.xml | 65 -
.../Config/Lifecycle/lifecycle-beans.xml | 66 -
.../Config/Lifecycle/lifecycle-no-beans.xml | 44 -
.../Config/cache-portables.xml | 78 -
.../Config/cache-query-continuous.xml | 171 -
.../Config/cache-query.xml | 100 -
.../Config/marshaller-default.xml | 43 -
.../Config/marshaller-invalid.xml | 46 -
.../Config/marshaller-portable.xml | 43 -
.../native-client-test-cache-affinity.xml | 70 -
.../native-client-test-cache-parallel-store.xml | 69 -
.../Config/native-client-test-cache-store.xml | 125 -
.../Config/native-client-test-cache.xml | 194 -
.../Config/portable.xml | 56 -
.../Config/start-test-grid1.xml | 54 -
.../Config/start-test-grid2.xml | 45 -
.../Config/start-test-grid3.xml | 43 -
.../Dataload/DataStreamerTest.cs | 592 ---
.../Apache.Ignite.Core.Tests/EventsTest.cs | 961 -----
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 352 --
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 443 ---
.../Apache.Ignite.Core.Tests/FutureTest.cs | 278 --
.../IgniteManagerTest.cs | 51 -
.../IgniteStartStopTest.cs | 422 --
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 288 --
.../Apache.Ignite.Core.Tests/LoadDllTest.cs | 243 --
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 71 -
.../Memory/InteropMemoryTest.cs | 213 -
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 646 ---
.../Portable/PortableApiSelfTest.cs | 1787 ---------
.../Portable/PortableSelfTest.cs | 2078 ----------
.../PortableConfigurationTest.cs | 173 -
.../Process/IIgniteProcessOutputReader.cs | 35 -
.../Process/IgniteProcess.cs | 283 --
.../Process/IgniteProcessConsoleOutputReader.cs | 40 -
.../Properties/AssemblyInfo.cs | 35 -
.../Query/ImplicitPortablePerson.cs | 46 -
.../Query/NoDefPortablePerson.cs | 35 -
.../Query/PortablePerson.cs | 69 -
.../SerializationTest.cs | 240 --
.../Services/ServiceProxyTest.cs | 741 ----
.../Services/ServicesAsyncWrapper.cs | 174 -
.../Services/ServicesTest.cs | 823 ----
.../Services/ServicesTestAsync.cs | 33 -
.../Apache.Ignite.Core.Tests/TestRunner.cs | 71 -
.../Apache.Ignite.Core.Tests/TestUtils.cs | 292 --
.../TypeResolverTest.cs | 107 -
.../platform/PlatformComputeBroadcastTask.java | 73 -
.../platform/PlatformComputeDecimalTask.java | 106 -
.../platform/PlatformComputeEchoTask.java | 188 -
.../ignite/platform/PlatformComputeEnum.java | 28 -
.../platform/PlatformComputeJavaPortable.java | 39 -
.../platform/PlatformComputePortable.java | 42 -
.../PlatformComputePortableArgTask.java | 121 -
.../platform/PlatformEventsWriteEventTask.java | 146 -
.../ignite/platform/PlatformMaxMemoryTask.java | 57 -
.../ignite/platform/PlatformMinMemoryTask.java | 57 -
.../lifecycle/PlatformJavaLifecycleBean.java | 47 -
.../lifecycle/PlatformJavaLifecycleTask.java | 65 -
modules/platforms/cpp/README.txt | 101 +
modules/platforms/cpp/common/Makefile.am | 45 +
modules/platforms/cpp/common/configure.ac | 62 +
.../platforms/cpp/common/ignite-common.pc.in | 9 +
.../platforms/cpp/common/include/Makefile.am | 26 +
.../common/include/ignite/common/concurrent.h | 237 ++
.../cpp/common/include/ignite/common/exports.h | 158 +
.../cpp/common/include/ignite/common/java.h | 679 ++++
.../cpp/common/include/ignite/common/utils.h | 81 +
.../cpp/common/os/linux/include/Makefile.am | 24 +
.../os/linux/include/ignite/common/common.h | 81 +
.../linux/include/ignite/common/concurrent_os.h | 394 ++
.../cpp/common/os/linux/src/common.cpp | 59 +
.../cpp/common/os/linux/src/concurrent_os.cpp | 175 +
.../os/win/include/ignite/common/common.h | 56 +
.../win/include/ignite/common/concurrent_os.h | 406 ++
.../platforms/cpp/common/os/win/src/common.cpp | 65 +
.../cpp/common/os/win/src/concurrent_os.cpp | 151 +
modules/platforms/cpp/common/project/README.TXT | 1 +
.../platforms/cpp/common/project/vs/README.TXT | 1 +
.../cpp/common/project/vs/common.vcxproj | 203 +
.../common/project/vs/common.vcxproj.filters | 57 +
.../platforms/cpp/common/project/vs/module.def | 111 +
.../platforms/cpp/common/project/vs/targetver.h | 25 +
modules/platforms/cpp/common/src/concurrent.cpp | 94 +
modules/platforms/cpp/common/src/exports.cpp | 461 +++
modules/platforms/cpp/common/src/java.cpp | 2416 ++++++++++++
modules/platforms/cpp/core-test/Makefile.am | 49 +
.../cpp/core-test/config/cache-query.xml | 91 +
.../cpp/core-test/config/cache-test.xml | 129 +
modules/platforms/cpp/core-test/configure.ac | 62 +
.../platforms/cpp/core-test/include/Makefile.am | 22 +
.../core-test/include/ignite/binary_test_defs.h | 320 ++
.../include/ignite/binary_test_utils.h | 516 +++
.../cpp/core-test/include/teamcity_messages.h | 55 +
.../platforms/cpp/core-test/project/README.TXT | 1 +
.../cpp/core-test/project/vs/README.TXT | 1 +
.../cpp/core-test/project/vs/core-test.vcxproj | 174 +
.../project/vs/core-test.vcxproj.filters | 68 +
.../src/binary_reader_writer_raw_test.cpp | 1593 ++++++++
.../core-test/src/binary_reader_writer_test.cpp | 2373 +++++++++++
.../cpp/core-test/src/binary_session_test.cpp | 257 ++
.../cpp/core-test/src/binary_test_defs.cpp | 65 +
.../cpp/core-test/src/cache_query_test.cpp | 841 ++++
.../platforms/cpp/core-test/src/cache_test.cpp | 479 +++
.../cpp/core-test/src/concurrent_test.cpp | 186 +
.../cpp/core-test/src/handle_registry_test.cpp | 176 +
.../cpp/core-test/src/ignition_test.cpp | 95 +
.../cpp/core-test/src/teamcity_boost.cpp | 159 +
.../cpp/core-test/src/teamcity_messages.cpp | 150 +
modules/platforms/cpp/core/Makefile.am | 67 +
modules/platforms/cpp/core/configure.ac | 62 +
modules/platforms/cpp/core/ignite.pc.in | 9 +
modules/platforms/cpp/core/include/Makefile.am | 69 +
.../cpp/core/include/ignite/binary/binary.h | 29 +
.../core/include/ignite/binary/binary_consts.h | 106 +
.../include/ignite/binary/binary_containers.h | 525 +++
.../include/ignite/binary/binary_raw_reader.h | 350 ++
.../include/ignite/binary/binary_raw_writer.h | 326 ++
.../core/include/ignite/binary/binary_reader.h | 384 ++
.../core/include/ignite/binary/binary_type.h | 293 ++
.../core/include/ignite/binary/binary_writer.h | 362 ++
.../cpp/core/include/ignite/cache/cache.h | 1196 ++++++
.../cpp/core/include/ignite/cache/cache_entry.h | 118 +
.../core/include/ignite/cache/cache_peek_mode.h | 71 +
.../cpp/core/include/ignite/cache/query/query.h | 28 +
.../include/ignite/cache/query/query_argument.h | 125 +
.../include/ignite/cache/query/query_cursor.h | 200 +
.../ignite/cache/query/query_fields_cursor.h | 153 +
.../ignite/cache/query/query_fields_row.h | 154 +
.../include/ignite/cache/query/query_scan.h | 151 +
.../core/include/ignite/cache/query/query_sql.h | 243 ++
.../ignite/cache/query/query_sql_fields.h | 210 +
.../include/ignite/cache/query/query_text.h | 160 +
.../platforms/cpp/core/include/ignite/guid.h | 112 +
.../platforms/cpp/core/include/ignite/ignite.h | 166 +
.../core/include/ignite/ignite_configuration.h | 66 +
.../cpp/core/include/ignite/ignite_error.h | 260 ++
.../cpp/core/include/ignite/ignition.h | 195 +
.../include/ignite/impl/binary/binary_common.h | 188 +
.../ignite/impl/binary/binary_id_resolver.h | 106 +
.../ignite/impl/binary/binary_reader_impl.h | 1309 +++++++
.../include/ignite/impl/binary/binary_schema.h | 136 +
.../ignite/impl/binary/binary_type_handler.h | 102 +
.../ignite/impl/binary/binary_type_manager.h | 120 +
.../ignite/impl/binary/binary_type_snapshot.h | 122 +
.../ignite/impl/binary/binary_type_updater.h | 53 +
.../impl/binary/binary_type_updater_impl.h | 65 +
.../include/ignite/impl/binary/binary_utils.h | 344 ++
.../ignite/impl/binary/binary_writer_impl.h | 913 +++++
.../core/include/ignite/impl/cache/cache_impl.h | 428 ++
.../impl/cache/query/query_fields_row_impl.h | 174 +
.../ignite/impl/cache/query/query_impl.h | 125 +
.../core/include/ignite/impl/handle_registry.h | 202 +
.../include/ignite/impl/ignite_environment.h | 130 +
.../cpp/core/include/ignite/impl/ignite_impl.h | 165 +
.../core/include/ignite/impl/interop/interop.h | 25 +
.../ignite/impl/interop/interop_input_stream.h | 250 ++
.../ignite/impl/interop/interop_memory.h | 280 ++
.../ignite/impl/interop/interop_output_stream.h | 250 ++
.../interop/interop_stream_position_guard.h | 79 +
.../cpp/core/include/ignite/impl/operations.h | 452 +++
.../cpp/core/os/linux/include/Makefile.am | 23 +
.../core/os/linux/include/ignite/impl/utils.h | 155 +
.../cpp/core/os/linux/src/impl/utils.cpp | 439 +++
.../cpp/core/os/win/include/ignite/impl/utils.h | 155 +
.../cpp/core/os/win/src/impl/utils.cpp | 453 +++
modules/platforms/cpp/core/project/README.TXT | 1 +
.../platforms/cpp/core/project/vs/README.TXT | 1 +
.../platforms/cpp/core/project/vs/core.vcxproj | 279 ++
.../cpp/core/project/vs/core.vcxproj.filters | 267 ++
.../cpp/core/src/binary/binary_containers.cpp | 76 +
.../cpp/core/src/binary/binary_raw_reader.cpp | 145 +
.../cpp/core/src/binary/binary_raw_writer.cpp | 147 +
.../cpp/core/src/binary/binary_reader.cpp | 152 +
.../cpp/core/src/binary/binary_type.cpp | 51 +
.../cpp/core/src/binary/binary_writer.cpp | 154 +
modules/platforms/cpp/core/src/guid.cpp | 65 +
modules/platforms/cpp/core/src/ignite.cpp | 43 +
modules/platforms/cpp/core/src/ignite_error.cpp | 222 ++
modules/platforms/cpp/core/src/ignition.cpp | 470 +++
.../core/src/impl/binary/binary_reader_impl.cpp | 760 ++++
.../cpp/core/src/impl/binary/binary_schema.cpp | 135 +
.../src/impl/binary/binary_type_handler.cpp | 78 +
.../src/impl/binary/binary_type_manager.cpp | 201 +
.../src/impl/binary/binary_type_snapshot.cpp | 70 +
.../src/impl/binary/binary_type_updater.cpp | 32 +
.../impl/binary/binary_type_updater_impl.cpp | 94 +
.../cpp/core/src/impl/binary/binary_utils.cpp | 211 +
.../core/src/impl/binary/binary_writer_impl.cpp | 623 +++
.../cpp/core/src/impl/cache/cache_impl.cpp | 393 ++
.../core/src/impl/cache/query/query_impl.cpp | 228 ++
.../cpp/core/src/impl/handle_registry.cpp | 234 ++
.../cpp/core/src/impl/ignite_environment.cpp | 167 +
.../platforms/cpp/core/src/impl/ignite_impl.cpp | 47 +
.../src/impl/interop/interop_input_stream.cpp | 235 ++
.../core/src/impl/interop/interop_memory.cpp | 182 +
.../src/impl/interop/interop_output_stream.cpp | 233 ++
modules/platforms/cpp/examples/Makefile.am | 39 +
modules/platforms/cpp/examples/README.txt | 42 +
.../cpp/examples/config/example-cache.xml | 77 +
modules/platforms/cpp/examples/configure.ac | 38 +
.../platforms/cpp/examples/include/Makefile.am | 21 +
.../examples/include/ignite/examples/address.h | 109 +
.../include/ignite/examples/organization.h | 111 +
.../cpp/examples/project/vs/ignite-examples.sln | 19 +
.../examples/project/vs/ignite-examples.vcxproj | 107 +
.../project/vs/ignite-examples.vcxproj.filters | 30 +
.../cpp/examples/src/putgetexample.cpp | 126 +
modules/platforms/cpp/ignite/Makefile.am | 39 +
modules/platforms/cpp/ignite/configure.ac | 62 +
modules/platforms/cpp/ignite/project/README.TXT | 1 +
.../platforms/cpp/ignite/project/vs/README.TXT | 1 +
.../cpp/ignite/project/vs/ignite.vcxproj | 167 +
.../ignite/project/vs/ignite.vcxproj.filters | 25 +
modules/platforms/cpp/ignite/src/ignite.cpp | 225 ++
modules/platforms/cpp/project/vs/ignite.sln | 58 +
modules/platforms/cpp/project/vs/ignite.slnrel | 33 +
.../platforms/cpp/project/vs/ignite_x86.slnrel | 33 +
.../Apache.Ignite.Benchmarks.csproj | 92 +
.../Apache.Ignite.Benchmarks.snk | Bin 0 -> 596 bytes
.../dotnet/Apache.Ignite.Benchmarks/App.config | 24 +
.../Apache.Ignite.Benchmarks/BenchmarkBase.cs | 931 +++++
.../BenchmarkOperationDescriptor.cs | 68 +
.../Apache.Ignite.Benchmarks/BenchmarkRunner.cs | 94 +
.../Apache.Ignite.Benchmarks/BenchmarkState.cs | 106 +
.../Apache.Ignite.Benchmarks/BenchmarkUtils.cs | 236 ++
.../Binary/BinarizableReadBenchmark.cs | 125 +
.../Binary/BinarizableWriteBenchmark.cs | 135 +
.../Config/benchmark.xml | 57 +
.../Interop/ClosureBenchmark.cs | 66 +
.../Interop/GetAsyncBenchmark.cs | 62 +
.../Interop/GetBenchmark.cs | 62 +
.../Interop/PlatformBenchmarkBase.cs | 121 +
.../Interop/PutAsyncBenchmark.cs | 58 +
.../Interop/PutBenchmark.cs | 58 +
.../Interop/TaskBenchmark.cs | 100 +
.../Interop/TxBenchmark.cs | 65 +
.../Apache.Ignite.Benchmarks/Model/Address.cs | 80 +
.../Apache.Ignite.Benchmarks/Model/Company.cs | 89 +
.../Model/Department.cs | 40 +
.../Apache.Ignite.Benchmarks/Model/Employee.cs | 136 +
.../Apache.Ignite.Benchmarks/Model/Sex.cs | 31 +
.../Apache.Ignite.Benchmarks/Model/TestModel.cs | 111 +
.../Properties/AssemblyInfo.cs | 35 +
.../Result/BenchmarkConsoleResultWriter.cs | 68 +
.../Result/BenchmarkFileResultWriter.cs | 323 ++
.../Result/IBenchmarkResultWriter.cs | 55 +
.../Apache.Ignite.Core.Tests.TestDll.csproj | 61 +
.../Apache.Ignite.Core.Tests.TestDll.snk | Bin 0 -> 596 bytes
.../Properties/AssemblyInfo.cs | 49 +
.../TestClass.cs | 35 +
.../Apache.Ignite.Core.Tests.csproj | 259 ++
.../Apache.Ignite.Core.Tests.nunit | 7 +
.../Apache.Ignite.Core.Tests.snk | Bin 0 -> 596 bytes
.../Binary/BinaryBuilderSelfTest.cs | 1721 ++++++++
.../Binary/BinarySelfTest.cs | 2157 ++++++++++
.../Binary/BinaryStructureTest.cs | 250 ++
.../BinaryConfigurationTest.cs | 173 +
.../Cache/CacheAbstractTest.cs | 3265 ++++++++++++++++
.../Cache/CacheAffinityTest.cs | 139 +
.../Cache/CacheDynamicStartTest.cs | 282 ++
.../Cache/CacheEntryTest.cs | 69 +
.../Cache/CacheForkedTest.cs | 81 +
.../Cache/CacheLocalAtomicTest.cs | 57 +
.../Cache/CacheLocalTest.cs | 56 +
.../CachePartitionedAtomicNearEnabledTest.cs | 50 +
.../Cache/CachePartitionedAtomicTest.cs | 50 +
.../Cache/CachePartitionedNearEnabledTest.cs | 50 +
.../Cache/CachePartitionedTest.cs | 50 +
.../Cache/CacheReplicatedAtomicTest.cs | 60 +
.../Cache/CacheReplicatedTest.cs | 60 +
.../Cache/CacheTestAsyncWrapper.cs | 575 +++
.../Cache/Query/CacheQueriesTest.cs | 935 +++++
.../Continuous/ContinuousQueryAbstractTest.cs | 1238 ++++++
.../ContinuousQueryAtomicBackupTest.cs | 33 +
.../ContinuousQueryAtomicNoBackupTest.cs | 34 +
.../ContinuousQueryNoBackupAbstractTest.cs | 72 +
.../ContinuousQueryTransactionalBackupTest.cs | 34 +
.../ContinuousQueryTransactionalNoBackupTest.cs | 33 +
.../Cache/Store/CacheParallelLoadStoreTest.cs | 110 +
.../Cache/Store/CacheStoreSessionTest.cs | 285 ++
.../Cache/Store/CacheStoreTest.cs | 536 +++
.../Cache/Store/CacheTestParallelLoadStore.cs | 91 +
.../Cache/Store/CacheTestStore.cs | 155 +
.../Compute/AbstractTaskTest.cs | 217 ++
.../Compute/BinarizableClosureTaskTest.cs | 185 +
.../Compute/BinarizableTaskTest.cs | 269 ++
.../Compute/ClosureTaskTest.cs | 390 ++
.../Compute/ComputeApiTest.cs | 1303 +++++++
.../Compute/ComputeMultithreadedTest.cs | 269 ++
.../Compute/FailoverTaskSelfTest.cs | 246 ++
.../Forked/ForkedBinarizableClosureTaskTest.cs | 30 +
.../Compute/Forked/ForkedResourceTaskTest.cs | 30 +
.../Forked/ForkedSerializableClosureTaskTest.cs | 30 +
.../Compute/Forked/ForkedTaskAdapterTest.cs | 30 +
.../Compute/IgniteExceptionTaskSelfTest.cs | 754 ++++
.../Compute/ResourceTaskTest.cs | 568 +++
.../Compute/SerializableClosureTaskTest.cs | 217 ++
.../Compute/TaskAdapterTest.cs | 274 ++
.../Compute/TaskResultTest.cs | 437 +++
.../Config/Apache.Ignite.exe.config.test | 41 +
.../Config/Cache/Store/cache-store-session.xml | 79 +
.../Config/Compute/compute-grid1.xml | 95 +
.../Config/Compute/compute-grid2.xml | 63 +
.../Config/Compute/compute-grid3.xml | 52 +
.../Config/Compute/compute-standalone.xml | 87 +
.../Config/Dynamic/dynamic-client.xml | 51 +
.../Config/Dynamic/dynamic-data-no-cfg.xml | 47 +
.../Config/Dynamic/dynamic-data.xml | 65 +
.../Config/Lifecycle/lifecycle-beans.xml | 66 +
.../Config/Lifecycle/lifecycle-no-beans.xml | 44 +
.../Apache.Ignite.Core.Tests/Config/binary.xml | 56 +
.../Config/cache-binarizables.xml | 78 +
.../Config/cache-query-continuous.xml | 171 +
.../Config/cache-query.xml | 100 +
.../Config/marshaller-default.xml | 43 +
.../Config/marshaller-explicit.xml | 53 +
.../Config/marshaller-invalid.xml | 46 +
.../native-client-test-cache-affinity.xml | 70 +
.../native-client-test-cache-parallel-store.xml | 68 +
.../Config/native-client-test-cache-store.xml | 121 +
.../Config/native-client-test-cache.xml | 143 +
.../Config/start-test-grid1.xml | 54 +
.../Config/start-test-grid2.xml | 45 +
.../Config/start-test-grid3.xml | 43 +
.../DataStructures/AtomicLongTest.cs | 138 +
.../Dataload/DataStreamerTest.cs | 592 +++
.../Apache.Ignite.Core.Tests/EventsTest.cs | 956 +++++
.../Examples/Example.cs | 126 +
.../Examples/ExamplesTest.cs | 156 +
.../Examples/PathUtil.cs | 50 +
.../Examples/ProjectFilesTest.cs | 49 +
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 365 ++
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 443 +++
.../Apache.Ignite.Core.Tests/FutureTest.cs | 188 +
.../IgniteManagerTest.cs | 51 +
.../IgniteStartStopTest.cs | 426 ++
.../Apache.Ignite.Core.Tests/IgniteTestBase.cs | 200 +
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 289 ++
.../Apache.Ignite.Core.Tests/LoadDllTest.cs | 243 ++
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 71 +
.../Memory/InteropMemoryTest.cs | 200 +
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 644 +++
.../Process/IIgniteProcessOutputReader.cs | 35 +
.../Process/IgniteProcess.cs | 283 ++
.../Process/IgniteProcessConsoleOutputReader.cs | 40 +
.../Properties/AssemblyInfo.cs | 35 +
.../Query/BinarizablePerson.cs | 69 +
.../Query/ImplicitBinarizablePerson.cs | 46 +
.../Query/NoDefBinarizablePerson.cs | 35 +
.../SerializationTest.cs | 240 ++
.../Services/ServiceProxyTest.cs | 741 ++++
.../Services/ServicesAsyncWrapper.cs | 182 +
.../Services/ServicesTest.cs | 823 ++++
.../Services/ServicesTestAsync.cs | 33 +
.../Apache.Ignite.Core.Tests/TestRunner.cs | 71 +
.../Apache.Ignite.Core.Tests/TestUtils.cs | 306 ++
.../TypeResolverTest.cs | 107 +
.../Apache.Ignite.Core.csproj | 381 ++
.../Apache.Ignite.Core/Apache.Ignite.Core.snk | Bin 0 -> 596 bytes
.../Binary/BinaryConfiguration.cs | 90 +
.../Binary/BinaryObjectException.cs | 64 +
.../Binary/BinaryTypeConfiguration.cs | 116 +
.../Binary/BinaryTypeNames.cs | 121 +
.../Apache.Ignite.Core/Binary/IBinarizable.cs | 39 +
.../Binary/IBinaryIdMapper.cs | 40 +
.../Binary/IBinaryNameMapper.cs | 39 +
.../Apache.Ignite.Core/Binary/IBinaryObject.cs | 60 +
.../Binary/IBinaryObjectBuilder.cs | 310 ++
.../Binary/IBinaryRawReader.cs | 223 ++
.../Binary/IBinaryRawWriter.cs | 220 ++
.../Apache.Ignite.Core/Binary/IBinaryReader.cs | 279 ++
.../Binary/IBinarySerializer.cs | 39 +
.../Apache.Ignite.Core/Binary/IBinaryType.cs | 52 +
.../Apache.Ignite.Core/Binary/IBinaryWriter.cs | 256 ++
.../Apache.Ignite.Core/Binary/IIgniteBinary.cs | 120 +
.../Cache/CacheAtomicUpdateTimeoutException.cs | 67 +
.../Cache/CacheEntryProcessorException.cs | 79 +
.../Apache.Ignite.Core/Cache/CacheException.cs | 68 +
.../Cache/CachePartialUpdateException.cs | 119 +
.../Apache.Ignite.Core/Cache/CachePeekMode.cs | 68 +
.../Apache.Ignite.Core/Cache/CacheResult.cs | 98 +
.../Cache/Event/CacheEntryEventType.cs | 41 +
.../Cache/Event/ICacheEntryEvent.cs | 45 +
.../Cache/Event/ICacheEntryEventFilter.cs | 31 +
.../Cache/Event/ICacheEntryEventListener.cs | 33 +
.../Cache/Expiry/ExpiryPolicy.cs | 89 +
.../Cache/Expiry/IExpiryPolicy.cs | 63 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 844 ++++
.../Apache.Ignite.Core/Cache/ICacheAffinity.cs | 158 +
.../Apache.Ignite.Core/Cache/ICacheEntry.cs | 37 +
.../Cache/ICacheEntryFilter.cs | 34 +
.../Cache/ICacheEntryProcessor.cs | 45 +
.../Cache/ICacheEntryProcessorResult.cs | 40 +
.../Apache.Ignite.Core/Cache/ICacheLock.cs | 58 +
.../Apache.Ignite.Core/Cache/ICacheMetrics.cs | 486 +++
.../Cache/IMutableCacheEntry.cs | 47 +
.../Cache/Query/Continuous/ContinuousQuery.cs | 170 +
.../Query/Continuous/IContinuousQueryHandle.cs | 47 +
.../Cache/Query/IQueryCursor.cs | 44 +
.../Apache.Ignite.Core/Cache/Query/QueryBase.cs | 82 +
.../Apache.Ignite.Core/Cache/Query/ScanQuery.cs | 76 +
.../Cache/Query/SqlFieldsQuery.cs | 81 +
.../Apache.Ignite.Core/Cache/Query/SqlQuery.cs | 120 +
.../Apache.Ignite.Core/Cache/Query/TextQuery.cs | 104 +
.../Store/CacheParallelLoadStoreAdapter.cs | 207 +
.../Cache/Store/CacheStoreAdapter.cs | 146 +
.../Cache/Store/CacheStoreException.cs | 66 +
.../Cache/Store/ICacheStore.cs | 184 +
.../Cache/Store/ICacheStoreSession.cs | 42 +
.../Cluster/ClusterGroupEmptyException.cs | 70 +
.../Cluster/ClusterTopologyException.cs | 69 +
.../Apache.Ignite.Core/Cluster/ICluster.cs | 79 +
.../Apache.Ignite.Core/Cluster/IClusterGroup.cs | 235 ++
.../Cluster/IClusterMetrics.cs | 347 ++
.../Apache.Ignite.Core/Cluster/IClusterNode.cs | 135 +
.../Cluster/IClusterNodeFilter.cs | 32 +
.../Common/IgniteException.cs | 66 +
.../Apache.Ignite.Core/Common/IgniteGuid.cs | 132 +
.../ComputeExecutionRejectedException.cs | 69 +
.../Compute/ComputeJobAdapter.cs | 122 +
.../Compute/ComputeJobFailoverException.cs | 72 +
.../Compute/ComputeJobResultPolicy.cs | 45 +
.../Compute/ComputeTaskAdapter.cs | 95 +
.../Compute/ComputeTaskCancelledException.cs | 69 +
.../ComputeTaskNoResultCacheAttribute.cs | 35 +
.../Compute/ComputeTaskSplitAdapter.cs | 95 +
.../Compute/ComputeTaskTimeoutException.cs | 67 +
.../Compute/ComputeUserUndeclaredException.cs | 70 +
.../Apache.Ignite.Core/Compute/ICompute.cs | 431 ++
.../Apache.Ignite.Core/Compute/IComputeFunc.cs | 55 +
.../Apache.Ignite.Core/Compute/IComputeJob.cs | 59 +
.../Compute/IComputeJobResult.cs | 66 +
.../Compute/IComputeReducer.cs | 41 +
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 132 +
.../DataStructures/IAtomicLong.cs | 84 +
.../Datastream/IDataStreamer.cs | 206 +
.../Datastream/IStreamReceiver.cs | 38 +
.../Datastream/StreamTransformer.cs | 73 +
.../Datastream/StreamVisitor.cs | 55 +
.../Apache.Ignite.Core/Events/CacheEvent.cs | 178 +
.../Events/CacheQueryExecutedEvent.cs | 99 +
.../Events/CacheQueryReadEvent.cs | 136 +
.../Events/CacheRebalancingEvent.cs | 100 +
.../Events/CheckpointEvent.cs | 51 +
.../Apache.Ignite.Core/Events/DiscoveryEvent.cs | 82 +
.../Apache.Ignite.Core/Events/EventBase.cs | 167 +
.../Apache.Ignite.Core/Events/EventReader.cs | 72 +
.../Apache.Ignite.Core/Events/EventType.cs | 595 +++
.../dotnet/Apache.Ignite.Core/Events/IEvent.cs | 74 +
.../Apache.Ignite.Core/Events/IEventFilter.cs | 33 +
.../Apache.Ignite.Core/Events/IEventListener.cs | 34 +
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 259 ++
.../Apache.Ignite.Core/Events/JobEvent.cs | 102 +
.../Apache.Ignite.Core/Events/SwapSpaceEvent.cs | 51 +
.../Apache.Ignite.Core/Events/TaskEvent.cs | 93 +
.../Apache.Ignite.Core/GlobalSuppressions.cs | Bin 0 -> 1908 bytes
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 168 +
.../Apache.Ignite.Core/IgniteConfiguration.cs | 143 +
.../dotnet/Apache.Ignite.Core/Ignition.cs | 627 +++
.../Impl/Binary/BinarizableSerializer.cs | 45 +
.../Impl/Binary/BinaryBuilderField.cs | 89 +
.../Impl/Binary/BinaryFullTypeDescriptor.cs | 210 +
.../Impl/Binary/BinaryHandleDictionary.cs | 188 +
.../Impl/Binary/BinaryMode.cs | 42 +
.../Impl/Binary/BinaryObject.cs | 354 ++
.../Impl/Binary/BinaryObjectBuilder.cs | 1137 ++++++
.../Impl/Binary/BinaryObjectHandle.cs | 59 +
.../Impl/Binary/BinaryObjectHeader.cs | 496 +++
.../Impl/Binary/BinaryObjectSchema.cs | 98 +
.../Impl/Binary/BinaryObjectSchemaField.cs | 48 +
.../Impl/Binary/BinaryObjectSchemaHolder.cs | 107 +
.../Impl/Binary/BinaryReader.cs | 965 +++++
.../Impl/Binary/BinaryReaderExtensions.cs | 52 +
.../Impl/Binary/BinaryReaderHandleDictionary.cs | 42 +
.../Impl/Binary/BinaryReflectiveActions.cs | 440 +++
.../Impl/Binary/BinaryReflectiveSerializer.cs | 218 ++
.../Binary/BinarySurrogateTypeDescriptor.cs | 162 +
.../Impl/Binary/BinarySystemHandlers.cs | 832 ++++
.../Impl/Binary/BinarySystemTypeSerializer.cs | 62 +
.../Impl/Binary/BinaryUtils.cs | 1823 +++++++++
.../Impl/Binary/BinaryWriter.cs | 1428 +++++++
.../Impl/Binary/DateTimeHolder.cs | 68 +
.../Impl/Binary/IBinarySystemTypeSerializer.cs | 34 +
.../Impl/Binary/IBinaryTypeDescriptor.cs | 133 +
.../Impl/Binary/IBinaryWriteAware.cs | 34 +
.../Impl/Binary/IgniteBinary.cs | 192 +
.../Impl/Binary/Io/BinaryHeapStream.cs | 452 +++
.../Impl/Binary/Io/BinaryStreamAdapter.cs | 114 +
.../Impl/Binary/Io/BinaryStreamBase.cs | 1253 ++++++
.../Impl/Binary/Io/IBinaryStream.cs | 322 ++
.../Impl/Binary/Marshaller.cs | 537 +++
.../Impl/Binary/Metadata/BinaryType.cs | 200 +
.../Binary/Metadata/BinaryTypeHashsetHandler.cs | 69 +
.../Impl/Binary/Metadata/BinaryTypeHolder.cs | 147 +
.../Impl/Binary/Metadata/IBinaryTypeHandler.cs | 41 +
.../Impl/Binary/SerializableObjectHolder.cs | 73 +
.../Impl/Binary/Structure/BinaryStructure.cs | 332 ++
.../Binary/Structure/BinaryStructureEntry.cs | 128 +
.../Structure/BinaryStructureJumpTable.cs | 118 +
.../Binary/Structure/BinaryStructureTracker.cs | 140 +
.../Binary/Structure/BinaryStructureUpdate.cs | 84 +
.../Impl/Binary/TypeResolver.cs | 231 ++
.../Impl/Cache/CacheAffinityImpl.cs | 275 ++
.../Apache.Ignite.Core/Impl/Cache/CacheEntry.cs | 127 +
.../Impl/Cache/CacheEntryFilterHolder.cs | 132 +
.../Impl/Cache/CacheEntryProcessorHolder.cs | 144 +
.../Impl/Cache/CacheEntryProcessorResult.cs | 65 +
.../Cache/CacheEntryProcessorResultHolder.cs | 128 +
.../Impl/Cache/CacheEnumerable.cs | 82 +
.../Impl/Cache/CacheEnumerator.cs | 117 +
.../Impl/Cache/CacheEnumeratorProxy.cs | 159 +
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 1255 ++++++
.../Apache.Ignite.Core/Impl/Cache/CacheLock.cs | 171 +
.../Impl/Cache/CacheMetricsImpl.cs | 248 ++
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 64 +
.../Impl/Cache/Event/CacheEntryCreateEvent.cs | 80 +
.../Impl/Cache/Event/CacheEntryRemoveEvent.cs | 80 +
.../Impl/Cache/Event/CacheEntryUpdateEvent.cs | 85 +
.../Impl/Cache/MutableCacheEntry.cs | 163 +
.../Impl/Cache/Query/AbstractQueryCursor.cs | 264 ++
.../Query/Continuous/ContinuousQueryFilter.cs | 125 +
.../Continuous/ContinuousQueryFilterHolder.cs | 86 +
.../Continuous/ContinuousQueryHandleImpl.cs | 213 +
.../Query/Continuous/ContinuousQueryUtils.cs | 96 +
.../Impl/Cache/Query/FieldsQueryCursor.cs | 54 +
.../Impl/Cache/Query/QueryCursor.cs | 50 +
.../Impl/Cache/Store/CacheStore.cs | 263 ++
.../Impl/Cache/Store/CacheStoreSession.cs | 53 +
.../Impl/Cache/Store/CacheStoreSessionProxy.cs | 63 +
.../Impl/Cluster/ClusterGroupImpl.cs | 574 +++
.../Impl/Cluster/ClusterMetricsImpl.cs | 294 ++
.../Impl/Cluster/ClusterNodeImpl.cs | 222 ++
.../Impl/Cluster/IClusterGroupEx.cs | 35 +
.../Impl/Collections/CollectionExtensions.cs | 45 +
.../Impl/Collections/MultiValueDictionary.cs | 145 +
.../Impl/Collections/ReadOnlyCollection.cs | 102 +
.../Impl/Collections/ReadOnlyDictionary.cs | 149 +
.../Apache.Ignite.Core/Impl/Common/Classpath.cs | 159 +
.../Common/CopyOnWriteConcurrentDictionary.cs | 72 +
.../Impl/Common/DelegateConverter.cs | 269 ++
.../Impl/Common/DelegateTypeDescriptor.cs | 340 ++
.../Apache.Ignite.Core/Impl/Common/Fnv1Hash.cs | 57 +
.../Apache.Ignite.Core/Impl/Common/Future.cs | 128 +
.../Impl/Common/FutureConverter.cs | 62 +
.../Impl/Common/FutureType.cs | 55 +
.../Impl/Common/IFutureConverter.cs | 35 +
.../Impl/Common/IFutureInternal.cs | 46 +
.../Impl/Common/IgniteArgumentCheck.cs | 77 +
.../Impl/Common/IgniteHome.cs | 97 +
.../Impl/Common/LoadedAssembliesResolver.cs | 96 +
.../Impl/Common/ResizeableArray.cs | 64 +
.../Impl/Common/TypeCaster.cs | 79 +
.../Closure/ComputeAbstractClosureTask.cs | 101 +
.../Impl/Compute/Closure/ComputeActionJob.cs | 82 +
.../Impl/Compute/Closure/ComputeFuncJob.cs | 86 +
.../Compute/Closure/ComputeMultiClosureTask.cs | 56 +
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 75 +
.../Closure/ComputeReducingClosureTask.cs | 61 +
.../Compute/Closure/ComputeSingleClosureTask.cs | 48 +
.../Compute/Closure/IComputeResourceInjector.cs | 31 +
.../Apache.Ignite.Core/Impl/Compute/Compute.cs | 300 ++
.../Impl/Compute/ComputeFunc.cs | 118 +
.../Impl/Compute/ComputeImpl.cs | 660 ++++
.../Impl/Compute/ComputeJob.cs | 162 +
.../Impl/Compute/ComputeJobHolder.cs | 245 ++
.../Compute/ComputeJobResultGenericWrapper.cs | 73 +
.../Impl/Compute/ComputeJobResultImpl.cs | 99 +
.../Impl/Compute/ComputeOutFunc.cs | 122 +
.../Impl/Compute/ComputeTaskHolder.cs | 505 +++
.../Impl/DataStructures/AtomicLong.cs | 102 +
.../Impl/Datastream/DataStreamerBatch.cs | 270 ++
.../Impl/Datastream/DataStreamerEntry.cs | 64 +
.../Impl/Datastream/DataStreamerImpl.cs | 840 ++++
.../Impl/Datastream/DataStreamerRemoveEntry.cs | 48 +
.../Impl/Datastream/StreamReceiverHolder.cs | 144 +
.../Apache.Ignite.Core/Impl/Events/Events.cs | 648 ++++
.../Impl/Events/RemoteListenEventFilter.cs | 84 +
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 206 +
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 69 +
.../Impl/Handle/HandleRegistry.cs | 343 ++
.../Apache.Ignite.Core/Impl/Handle/IHandle.cs | 35 +
.../Apache.Ignite.Core/Impl/IInteropCallback.cs | 34 +
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 529 +++
.../Impl/IgniteConfigurationEx.cs | 57 +
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 286 ++
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 343 ++
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 418 ++
.../Impl/InteropExceptionHolder.cs | 85 +
.../Impl/LifecycleBeanHolder.cs | 66 +
.../Impl/Memory/IPlatformMemory.cs | 65 +
.../Impl/Memory/InteropExternalMemory.cs | 46 +
.../Impl/Memory/InteropMemoryUtils.cs | 38 +
.../Memory/PlatformBigEndianMemoryStream.cs | 483 +++
.../Impl/Memory/PlatformMemory.cs | 78 +
.../Impl/Memory/PlatformMemoryManager.cs | 107 +
.../Impl/Memory/PlatformMemoryPool.cs | 106 +
.../Impl/Memory/PlatformMemoryStream.cs | 727 ++++
.../Impl/Memory/PlatformMemoryUtils.cs | 465 +++
.../Impl/Memory/PlatformPooledMemory.cs | 66 +
.../Impl/Memory/PlatformRawMemory.cs | 89 +
.../Impl/Memory/PlatformUnpooledMemory.cs | 52 +
.../Impl/Messaging/MessageListenerHolder.cs | 177 +
.../Impl/Messaging/Messaging.cs | 289 ++
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 47 +
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 737 ++++
.../Impl/Resource/IResourceInjector.cs | 27 +
.../Impl/Resource/ResourceFieldInjector.cs | 47 +
.../Impl/Resource/ResourceMethodInjector.cs | 48 +
.../Impl/Resource/ResourceProcessor.cs | 105 +
.../Impl/Resource/ResourcePropertyInjector.cs | 47 +
.../Impl/Resource/ResourceTypeDescriptor.cs | 291 ++
.../Impl/Services/ServiceContext.cs | 60 +
.../Impl/Services/ServiceDescriptor.cs | 106 +
.../Impl/Services/ServiceProxy.cs | 71 +
.../Impl/Services/ServiceProxyInvoker.cs | 141 +
.../Impl/Services/ServiceProxySerializer.cs | 140 +
.../Impl/Services/Services.cs | 372 ++
.../Impl/Transactions/Transaction.cs | 146 +
.../Impl/Transactions/TransactionImpl.cs | 482 +++
.../Impl/Transactions/TransactionMetricsImpl.cs | 68 +
.../Impl/Transactions/TransactionsImpl.cs | 201 +
.../Impl/Unmanaged/IUnmanagedTarget.cs | 42 +
.../Impl/Unmanaged/UnmanagedCallbackHandlers.cs | 99 +
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 1164 ++++++
.../Impl/Unmanaged/UnmanagedContext.cs | 53 +
.../Unmanaged/UnmanagedNonReleaseableTarget.cs | 70 +
.../Impl/Unmanaged/UnmanagedTarget.cs | 77 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 1371 +++++++
.../Lifecycle/ILifecycleBean.cs | 64 +
.../Lifecycle/LifecycleEventType.cs | 49 +
.../Messaging/IMessageListener.cs | 38 +
.../Apache.Ignite.Core/Messaging/IMessaging.cs | 128 +
.../Properties/AssemblyInfo.cs | 46 +
.../Resource/InstanceResourceAttribute.cs | 35 +
.../Resource/StoreSessionResourceAttribute.cs | 32 +
.../Apache.Ignite.Core/Services/IService.cs | 51 +
.../Services/IServiceContext.cs | 69 +
.../Services/IServiceDescriptor.cs | 96 +
.../Apache.Ignite.Core/Services/IServices.cs | 256 ++
.../Services/ServiceConfiguration.cs | 62 +
.../Services/ServiceInvocationException.cs | 101 +
.../Transactions/ITransaction.cs | 238 ++
.../Transactions/ITransactionMetrics.cs | 47 +
.../Transactions/ITransactions.cs | 76 +
.../Transactions/TransactionConcurrency.cs | 36 +
.../TransactionHeuristicException.cs | 72 +
.../Transactions/TransactionIsolation.cs | 41 +
.../TransactionOptimisticException.cs | 69 +
.../TransactionRollbackException.cs | 68 +
.../Transactions/TransactionState.cs | 70 +
.../Transactions/TransactionTimeoutException.cs | 69 +
modules/platforms/dotnet/Apache.Ignite.FxCop | 117 +
modules/platforms/dotnet/Apache.Ignite.sln | 111 +
.../dotnet/Apache.Ignite.sln.DotSettings | 4 +
modules/platforms/dotnet/Apache.Ignite.slnrel | 43 +
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 83 +
.../dotnet/Apache.Ignite/Apache.Ignite.snk | Bin 0 -> 596 bytes
.../platforms/dotnet/Apache.Ignite/App.config | 56 +
.../Config/AppSettingsConfigurator.cs | 113 +
.../Apache.Ignite/Config/ArgsConfigurator.cs | 164 +
.../Apache.Ignite/Config/ConfigValueParser.cs | 42 +
.../Apache.Ignite/Config/IConfigurator.cs | 34 +
.../dotnet/Apache.Ignite/IgniteRunner.cs | 171 +
.../Apache.Ignite/Properties/AssemblyInfo.cs | 35 +
.../Apache.Ignite/Service/IgniteService.cs | 219 ++
.../Apache.Ignite/Service/NativeMethods.cs | 57 +
.../Apache.Ignite/Service/ServiceDescription.cs | 32 +
.../platforms/dotnet/Apache.Ignite_x86.slnrel | 43 +
modules/platforms/dotnet/README.txt | 24 +
.../dotnet/examples/Apache.Ignite.Examples.sln | 38 +
.../Apache.Ignite.Examples.csproj | 88 +
.../Apache.Ignite.Examples.snk | Bin 0 -> 596 bytes
.../examples/Apache.Ignite.Examples/App.config | 24 +
.../Compute/ClosureExample.cs | 84 +
.../Compute/TaskExample.cs | 141 +
.../Datagrid/ContinuousQueryExample.cs | 103 +
.../Datagrid/CrossPlatformExample.cs | 205 +
.../Datagrid/DataStreamerExample.cs | 102 +
.../Datagrid/PutGetExample.cs | 219 ++
.../Datagrid/QueryExample.cs | 227 ++
.../Datagrid/StoreExample.cs | 115 +
.../Datagrid/TransactionExample.cs | 105 +
.../Events/EventsExample.cs | 104 +
.../Messaging/MessagingExample.cs | 112 +
.../Misc/LifecycleExample.cs | 109 +
.../Properties/AssemblyInfo.cs | 35 +
.../Services/IMapService.cs | 56 +
.../Services/ServicesExample.cs | 77 +
.../Apache.Ignite.ExamplesDll.csproj | 82 +
.../Apache.Ignite.ExamplesDll.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.ExamplesDll/Binary/Account.cs | 60 +
.../Apache.Ignite.ExamplesDll/Binary/Address.cs | 81 +
.../Binary/Employee.cs | 93 +
.../Binary/EmployeeKey.cs | 86 +
.../Binary/Organization.cs | 84 +
.../Binary/OrganizationType.cs | 43 +
.../Compute/AverageSalaryJob.cs | 66 +
.../Compute/AverageSalaryTask.cs | 85 +
.../Compute/CharacterCountClosure.cs | 43 +
.../Compute/CharacterCountReducer.cs | 51 +
.../Datagrid/ContinuousQueryFilter.cs | 50 +
.../Datagrid/EmployeeStore.cs | 122 +
.../Datagrid/EmployeeStorePredicate.cs | 41 +
.../Events/LocalListener.cs | 54 +
.../Messaging/LocalListener.cs | 59 +
.../Messaging/RemoteOrderedListener.cs | 54 +
.../Messaging/RemoteUnorderedListener.cs | 54 +
.../Messaging/Topic.cs | 28 +
.../Properties/AssemblyInfo.cs | 35 +
.../Services/MapService.cs | 119 +
.../examples/Config/example-cache-query.xml | 111 +
.../examples/Config/example-cache-store.xml | 59 +
.../dotnet/examples/Config/example-cache.xml | 80 +
.../dotnet/examples/Config/example-compute.xml | 70 +
modules/platforms/dotnet/examples/README.txt | 14 +
modules/platforms/licenses/apache-2.0.txt | 202 +
.../org/apache/ignite/IgniteSpringBean.java | 7 +
modules/yardstick/config/ignite-base-config.xml | 37 +-
.../cache/IgniteSqlQueryPutBenchmark.java | 5 +
.../yardstick/cache/model/Organization.java | 19 +-
.../ignite/yardstick/cache/model/Person.java | 24 +-
.../ignite/yardstick/cache/model/SampleKey.java | 16 +-
.../yardstick/cache/model/SampleValue.java | 16 +-
parent/pom.xml | 34 +-
pom.xml | 11 -
1758 files changed, 173924 insertions(+), 140526 deletions(-)
----------------------------------------------------------------------
[42/55] [abbrv] ignite git commit: IGNITE-1968: Fixed missing
serialization modes in Java.
Posted by ag...@apache.org.
IGNITE-1968: Fixed missing serialization modes in Java.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3430586c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3430586c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3430586c
Branch: refs/heads/ignite-1.5
Commit: 3430586c6ec7b224018b668e0f9e7d8aed012c1d
Parents: 0d56b41
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 14:19:01 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 14:19:01 2015 +0300
----------------------------------------------------------------------
.../internal/portable/PortableClassDescriptor.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3430586c/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index bc9d6f4..974f891 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -165,6 +165,14 @@ public class PortableClassDescriptor {
mode = serializer != null ? BinaryWriteMode.PORTABLE : PortableUtils.mode(cls);
switch (mode) {
+ case P_BYTE:
+ case P_BOOLEAN:
+ case P_SHORT:
+ case P_CHAR:
+ case P_INT:
+ case P_LONG:
+ case P_FLOAT:
+ case P_DOUBLE:
case BYTE:
case SHORT:
case INT:
@@ -363,41 +371,49 @@ public class PortableClassDescriptor {
writer.typeId(typeId);
switch (mode) {
+ case P_BYTE:
case BYTE:
writer.writeByteFieldPrimitive((byte) obj);
break;
+ case P_SHORT:
case SHORT:
writer.writeShortFieldPrimitive((short)obj);
break;
+ case P_INT:
case INT:
writer.writeIntFieldPrimitive((int) obj);
break;
+ case P_LONG:
case LONG:
writer.writeLongFieldPrimitive((long) obj);
break;
+ case P_FLOAT:
case FLOAT:
writer.writeFloatFieldPrimitive((float) obj);
break;
+ case P_DOUBLE:
case DOUBLE:
writer.writeDoubleFieldPrimitive((double) obj);
break;
+ case P_CHAR:
case CHAR:
writer.writeCharFieldPrimitive((char) obj);
break;
+ case P_BOOLEAN:
case BOOLEAN:
writer.writeBooleanFieldPrimitive((boolean) obj);
[13/55] [abbrv] ignite git commit: IGNITE-1847: GIT failed to change
class name casing (2/2).
Posted by ag...@apache.org.
IGNITE-1847: GIT failed to change class name casing (2/2).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/66c84ea3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/66c84ea3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/66c84ea3
Branch: refs/heads/ignite-1.5
Commit: 66c84ea32fec0a62b7a01f4094503e8ebc297fed
Parents: a0efe76
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 18 10:30:46 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 18 10:30:46 2015 +0300
----------------------------------------------------------------------
.../portable/BinaryMetadataCollector.java | 254 +++++++++++++++++++
.../portable/BinaryMetadataCollector2.java | 254 -------------------
.../portable/PortableClassDescriptor.java | 2 +-
.../CacheObjectBinaryProcessorImpl.java | 44 ++--
.../cache/portable/PortableMetadataKey.java | 82 ++++++
.../cache/portable/PortableMetadataKey2.java | 82 ------
6 files changed, 359 insertions(+), 359 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/66c84ea3/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
new file mode 100644
index 0000000..67e1a0d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Writer for meta data collection.
+ */
+class BinaryMetadataCollector implements BinaryWriter {
+ /** */
+ private final Map<String, Integer> meta = new HashMap<>();
+
+ /** */
+ private final String typeName;
+
+ /**
+ * @param typeName Type name.
+ */
+ BinaryMetadataCollector(String typeName) {
+ this.typeName = typeName;
+ }
+
+ /**
+ * @return Field meta data.
+ */
+ Map<String, Integer> meta() {
+ return meta;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BYTE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShort(String fieldName, short val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.SHORT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeInt(String fieldName, int val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.INT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLong(String fieldName, long val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.LONG);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeFloat(String fieldName, float val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.FLOAT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDouble(String fieldName, double val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DOUBLE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeChar(String fieldName, char val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.CHAR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BOOLEAN);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DECIMAL);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.STRING);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.UUID);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DATE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.ENUM);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.ENUM_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.OBJECT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BYTE_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.SHORT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.INT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.LONG_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.FLOAT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DOUBLE_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.CHAR_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BOOLEAN_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeStringArray(String fieldName, @Nullable String[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.STRING_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.UUID_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DATE_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.OBJECT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
+ throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.COL);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.MAP);
+ }
+
+ /** {@inheritDoc} */
+ @Override public BinaryRawWriter rawWriter() {
+ return (BinaryRawWriter)Proxy.newProxyInstance(getClass().getClassLoader(),
+ new Class<?>[] { BinaryRawWriterEx.class },
+ new InvocationHandler() {
+ @Override public Object invoke(Object proxy, Method mtd, Object[] args) throws Throwable {
+ return null;
+ }
+ });
+ }
+
+ /**
+ * @param name Field name.
+ * @param mode Field mode.
+ * @throws BinaryObjectException In case of error.
+ */
+ private void add(String name, PortableClassDescriptor.Mode mode) throws BinaryObjectException {
+ assert name != null;
+
+ int fieldTypeId = mode.typeId();
+
+ Integer oldFieldTypeId = meta.put(name, fieldTypeId);
+
+ if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) {
+ throw new BinaryObjectException(
+ "Field is written twice with different types [" +
+ "typeName=" + typeName +
+ ", fieldName=" + name +
+ ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldTypeId) +
+ ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) +
+ ']'
+ );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/66c84ea3/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java
deleted file mode 100644
index 701c619..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Writer for meta data collection.
- */
-class BinaryMetadataCollector2 implements BinaryWriter {
- /** */
- private final Map<String, Integer> meta = new HashMap<>();
-
- /** */
- private final String typeName;
-
- /**
- * @param typeName Type name.
- */
- BinaryMetadataCollector2(String typeName) {
- this.typeName = typeName;
- }
-
- /**
- * @return Field meta data.
- */
- Map<String, Integer> meta() {
- return meta;
- }
-
- /** {@inheritDoc} */
- @Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BYTE);
- }
-
- /** {@inheritDoc} */
- @Override public void writeShort(String fieldName, short val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.SHORT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeInt(String fieldName, int val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.INT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeLong(String fieldName, long val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.LONG);
- }
-
- /** {@inheritDoc} */
- @Override public void writeFloat(String fieldName, float val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.FLOAT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDouble(String fieldName, double val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DOUBLE);
- }
-
- /** {@inheritDoc} */
- @Override public void writeChar(String fieldName, char val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.CHAR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BOOLEAN);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL);
- }
-
- /** {@inheritDoc} */
- @Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.STRING);
- }
-
- /** {@inheritDoc} */
- @Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.UUID);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DATE);
- }
-
- /** {@inheritDoc} */
- @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP);
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.ENUM);
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.ENUM_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.OBJECT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BYTE_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.SHORT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.INT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.LONG_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.FLOAT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DOUBLE_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.CHAR_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BOOLEAN_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeStringArray(String fieldName, @Nullable String[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.STRING_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.UUID_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DATE_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.OBJECT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
- throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.COL);
- }
-
- /** {@inheritDoc} */
- @Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.MAP);
- }
-
- /** {@inheritDoc} */
- @Override public BinaryRawWriter rawWriter() {
- return (BinaryRawWriter)Proxy.newProxyInstance(getClass().getClassLoader(),
- new Class<?>[] { BinaryRawWriterEx.class },
- new InvocationHandler() {
- @Override public Object invoke(Object proxy, Method mtd, Object[] args) throws Throwable {
- return null;
- }
- });
- }
-
- /**
- * @param name Field name.
- * @param mode Field mode.
- * @throws BinaryObjectException In case of error.
- */
- private void add(String name, PortableClassDescriptor.Mode mode) throws BinaryObjectException {
- assert name != null;
-
- int fieldTypeId = mode.typeId();
-
- Integer oldFieldTypeId = meta.put(name, fieldTypeId);
-
- if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) {
- throw new BinaryObjectException(
- "Field is written twice with different types [" +
- "typeName=" + typeName +
- ", fieldName=" + name +
- ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldTypeId) +
- ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) +
- ']'
- );
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/66c84ea3/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 7fa6bc3..225e0ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -546,7 +546,7 @@ public class PortableClassDescriptor {
if (obj.getClass() != BinaryMetadata.class
&& ctx.isMetaDataChanged(typeId, writer.metaDataHashSum())) {
- BinaryMetadataCollector2 metaCollector = new BinaryMetadataCollector2(typeName);
+ BinaryMetadataCollector metaCollector = new BinaryMetadataCollector(typeName);
if (serializer != null)
serializer.writeBinary(obj, metaCollector);
http://git-wip-us.apache.org/repos/asf/ignite/blob/66c84ea3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
index e6eb494..117eece 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
@@ -110,7 +110,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private final boolean clientNode;
/** */
- private volatile IgniteCacheProxy<PortableMetadataKey2, BinaryMetadata> metaDataCache;
+ private volatile IgniteCacheProxy<PortableMetadataKey, BinaryMetadata> metaDataCache;
/** */
private final ConcurrentHashMap8<Integer, BinaryTypeImpl> clientMetaDataCache;
@@ -120,7 +120,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private static final long serialVersionUID = 0L;
@Override public boolean apply(GridCacheEntryEx e) {
- return e.key().value(e.context().cacheObjectContext(), false) instanceof PortableMetadataKey2;
+ return e.key().value(e.context().cacheObjectContext(), false) instanceof PortableMetadataKey;
}
};
@@ -238,7 +238,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
GridCacheQueryManager qryMgr = metaDataCache.context().queries();
- CacheQuery<Map.Entry<PortableMetadataKey2, BinaryMetadata>> qry =
+ CacheQuery<Map.Entry<PortableMetadataKey, BinaryMetadata>> qry =
qryMgr.createScanQuery(new MetaDataPredicate(), null, false);
qry.keepAll(false);
@@ -246,9 +246,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
qry.projection(ctx.cluster().get().forNode(oldestSrvNode));
try {
- CacheQueryFuture<Map.Entry<PortableMetadataKey2, BinaryMetadata>> fut = qry.execute();
+ CacheQueryFuture<Map.Entry<PortableMetadataKey, BinaryMetadata>> fut = qry.execute();
- Map.Entry<PortableMetadataKey2, BinaryMetadata> next;
+ Map.Entry<PortableMetadataKey, BinaryMetadata> next;
while ((next = fut.next()) != null) {
assert next.getKey() != null : next;
@@ -294,7 +294,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
* @param key Metadata key.
* @param newMeta Metadata.
*/
- private void addClientCacheMetaData(PortableMetadataKey2 key, final BinaryMetadata newMeta) {
+ private void addClientCacheMetaData(PortableMetadataKey key, final BinaryMetadata newMeta) {
int key0 = key.typeId();
clientMetaDataCache.compute(key0,
@@ -460,7 +460,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
BinaryMetadata newMeta0 = ((BinaryTypeImpl)newMeta).metadata();
- final PortableMetadataKey2 key = new PortableMetadataKey2(typeId);
+ final PortableMetadataKey key = new PortableMetadataKey(typeId);
try {
BinaryMetadata oldMeta = metaDataCache.localPeek(key);
@@ -483,7 +483,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (clientNode)
return clientMetaDataCache.get(typeId);
else {
- BinaryMetadata meta = metaDataCache.localPeek(new PortableMetadataKey2(typeId));
+ BinaryMetadata meta = metaDataCache.localPeek(new PortableMetadataKey(typeId));
return meta != null ? meta.wrap(portableCtx) : null;
}
@@ -497,16 +497,16 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@Override public Map<Integer, BinaryType> metadata(Collection<Integer> typeIds)
throws BinaryObjectException {
try {
- Collection<PortableMetadataKey2> keys = new ArrayList<>(typeIds.size());
+ Collection<PortableMetadataKey> keys = new ArrayList<>(typeIds.size());
for (Integer typeId : typeIds)
- keys.add(new PortableMetadataKey2(typeId));
+ keys.add(new PortableMetadataKey(typeId));
- Map<PortableMetadataKey2, BinaryMetadata> meta = metaDataCache.getAll(keys);
+ Map<PortableMetadataKey, BinaryMetadata> meta = metaDataCache.getAll(keys);
Map<Integer, BinaryType> res = U.newHashMap(meta.size());
- for (Map.Entry<PortableMetadataKey2, BinaryMetadata> e : meta.entrySet())
+ for (Map.Entry<PortableMetadataKey, BinaryMetadata> e : meta.entrySet())
res.put(e.getKey().typeId(), e.getValue().wrap(portableCtx));
return res;
@@ -527,10 +527,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
});
else {
return F.viewReadOnly(metaDataCache.entrySetx(metaPred),
- new C1<Cache.Entry<PortableMetadataKey2, BinaryMetadata>, BinaryType>() {
+ new C1<Cache.Entry<PortableMetadataKey, BinaryMetadata>, BinaryType>() {
private static final long serialVersionUID = 0L;
- @Override public BinaryType apply(Cache.Entry<PortableMetadataKey2, BinaryMetadata> e) {
+ @Override public BinaryType apply(Cache.Entry<PortableMetadataKey, BinaryMetadata> e) {
return e.getValue().wrap(portableCtx);
}
});
@@ -799,7 +799,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
*/
private static class MetaDataProcessor implements
- EntryProcessor<PortableMetadataKey2, BinaryMetadata, BinaryObjectException>, Externalizable {
+ EntryProcessor<PortableMetadataKey, BinaryMetadata, BinaryObjectException>, Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -829,7 +829,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public BinaryObjectException process(
- MutableEntry<PortableMetadataKey2, BinaryMetadata> entry,
+ MutableEntry<PortableMetadataKey, BinaryMetadata> entry,
Object... args) {
try {
BinaryMetadata oldMeta = entry.getValue();
@@ -873,15 +873,15 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
*
*/
- class MetaDataEntryListener implements CacheEntryUpdatedListener<PortableMetadataKey2, BinaryMetadata> {
+ class MetaDataEntryListener implements CacheEntryUpdatedListener<PortableMetadataKey, BinaryMetadata> {
/** {@inheritDoc} */
@Override public void onUpdated(
- Iterable<CacheEntryEvent<? extends PortableMetadataKey2, ? extends BinaryMetadata>> evts)
+ Iterable<CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata>> evts)
throws CacheEntryListenerException {
- for (CacheEntryEvent<? extends PortableMetadataKey2, ? extends BinaryMetadata> evt : evts) {
+ for (CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata> evt : evts) {
assert evt.getEventType() == EventType.CREATED || evt.getEventType() == EventType.UPDATED : evt;
- PortableMetadataKey2 key = evt.getKey();
+ PortableMetadataKey key = evt.getKey();
final BinaryMetadata newMeta = evt.getValue();
@@ -906,7 +906,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean evaluate(CacheEntryEvent<?, ?> evt) throws CacheEntryListenerException {
- return evt.getKey() instanceof PortableMetadataKey2;
+ return evt.getKey() instanceof PortableMetadataKey;
}
/** {@inheritDoc} */
@@ -924,7 +924,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean apply(Object key, Object val) {
- return key instanceof PortableMetadataKey2;
+ return key instanceof PortableMetadataKey;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/66c84ea3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey.java
new file mode 100644
index 0000000..f838c82
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey.java
@@ -0,0 +1,82 @@
+/*
+ * 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.processors.cache.portable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Key for portable meta data.
+ */
+class PortableMetadataKey extends GridCacheUtilityKey<PortableMetadataKey> implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private int typeId;
+
+ /**
+ * For {@link Externalizable}.
+ */
+ public PortableMetadataKey() {
+ // No-op.
+ }
+
+ /**
+ * @param typeId Type ID.
+ */
+ PortableMetadataKey(int typeId) {
+ this.typeId = typeId;
+ }
+
+ /**
+ * @return Type id.
+ */
+ public int typeId() {
+ return typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(typeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ typeId = in.readInt();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean equalsx(PortableMetadataKey key) {
+ return typeId == key.typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PortableMetadataKey.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/66c84ea3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java
deleted file mode 100644
index 4c99b70..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java
+++ /dev/null
@@ -1,82 +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.processors.cache.portable;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Key for portable meta data.
- */
-class PortableMetadataKey2 extends GridCacheUtilityKey<PortableMetadataKey2> implements Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private int typeId;
-
- /**
- * For {@link Externalizable}.
- */
- public PortableMetadataKey2() {
- // No-op.
- }
-
- /**
- * @param typeId Type ID.
- */
- PortableMetadataKey2(int typeId) {
- this.typeId = typeId;
- }
-
- /**
- * @return Type id.
- */
- public int typeId() {
- return typeId;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(typeId);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- typeId = in.readInt();
- }
-
- /** {@inheritDoc} */
- @Override protected boolean equalsx(PortableMetadataKey2 key) {
- return typeId == key.typeId;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return typeId;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PortableMetadataKey2.class, this);
- }
-}
\ No newline at end of file
[29/55] [abbrv] ignite git commit: IGNITE-1953: Reworked ID mappers
handling.
Posted by ag...@apache.org.
IGNITE-1953: Reworked ID mappers handling.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d69b177d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d69b177d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d69b177d
Branch: refs/heads/ignite-1.5
Commit: d69b177de2084b879f5b9b5c3fb981d00996f066
Parents: 4a1af37
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 09:58:40 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 09:58:40 2015 +0300
----------------------------------------------------------------------
.../portable/BinaryInternalIdMapper.java | 152 +++++++++++++++++++
.../portable/PortableClassDescriptor.java | 9 --
.../internal/portable/PortableContext.java | 121 ++-------------
.../portable/BinaryObjectBuilderSelfTest.java | 4 +-
4 files changed, 166 insertions(+), 120 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69b177d/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java
new file mode 100644
index 0000000..dd434ff
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Internal ID mapper. Mimics ID mapper interface, but provides default implementation and offers slightly better
+ * performance on micro-level in default case because it doesn't need virtual calls.
+ */
+public class BinaryInternalIdMapper implements BinaryIdMapper {
+ /** Maximum lower-case character. */
+ private static final char MAX_LOWER_CASE_CHAR = 0x7e;
+
+ /** Cached lower-case characters. */
+ private static final char[] LOWER_CASE_CHARS;
+
+ /** Default implementation. */
+ private static final BinaryInternalIdMapper DFLT = new BinaryInternalIdMapper();
+
+ /**
+ * Static initializer.
+ */
+ static {
+ LOWER_CASE_CHARS = new char[MAX_LOWER_CASE_CHAR + 1];
+
+ for (char c = 0; c <= MAX_LOWER_CASE_CHAR; c++)
+ LOWER_CASE_CHARS[c] = Character.toLowerCase(c);
+ }
+
+ /**
+ * Get default instance.
+ *
+ * @return Default instance.
+ */
+ public static BinaryInternalIdMapper defaultInstance() {
+ return DFLT;
+ }
+
+ /**
+ * Create internal mapper.
+ *
+ * @param mapper Public mapper.
+ * @return Internal mapper.
+ */
+ public static BinaryInternalIdMapper create(@Nullable BinaryIdMapper mapper) {
+ return mapper == null ? DFLT : new Wrapper(mapper);
+ }
+
+ /**
+ * Private constructor.
+ */
+ protected BinaryInternalIdMapper() {
+ // No-op.
+ }
+
+ /**
+ * Get type ID.
+ *
+ * @param typeName Type name.
+ * @return Type ID.
+ */
+ public int typeId(String typeName) {
+ assert typeName != null;
+
+ return lowerCaseHashCode(typeName);
+ }
+
+ /**
+ * Get field ID.
+ *
+ * @param typeId Type ID.
+ * @param fieldName Field name.
+ * @return Field ID.
+ */
+ public int fieldId(int typeId, String fieldName) {
+ assert fieldName != null;
+
+ return lowerCaseHashCode(fieldName);
+ }
+
+ /**
+ * Routine to calculate string hash code an
+ *
+ * @param str String.
+ * @return Hash code for given string converted to lower case.
+ */
+ private static int lowerCaseHashCode(String str) {
+ int len = str.length();
+
+ int h = 0;
+
+ for (int i = 0; i < len; i++) {
+ int c = str.charAt(i);
+
+ c = c <= MAX_LOWER_CASE_CHAR ? LOWER_CASE_CHARS[c] : Character.toLowerCase(c);
+
+ h = 31 * h + c;
+ }
+
+ return h;
+ }
+
+ /**
+ * Wrapping ID mapper.
+ */
+ private static class Wrapper extends BinaryInternalIdMapper {
+ /** Delegate. */
+ private final BinaryIdMapper mapper;
+
+ /**
+ * Constructor.
+ *
+ * @param mapper Delegate.
+ */
+ private Wrapper(BinaryIdMapper mapper) {
+ assert mapper != null;
+
+ this.mapper = mapper;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int typeId(String typeName) {
+ int id = mapper.typeId(typeName);
+
+ return id != 0 ? id : super.typeId(typeName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int fieldId(int typeId, String fieldName) {
+ int id = mapper.fieldId(typeId, fieldName);
+
+ return id != 0 ? id : super.fieldId(typeId, fieldName);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69b177d/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 3edf980..c233267 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -351,15 +351,6 @@ public class PortableClassDescriptor {
}
/**
- * Get ID mapper.
- *
- * @return ID mapper.
- */
- public BinaryIdMapper idMapper() {
- return idMapper;
- }
-
- /**
* @return portableWriteReplace() method
*/
@Nullable Method getWriteReplaceMethod() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69b177d/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index e3caba4..a88498a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -85,28 +85,6 @@ public class PortableContext implements Externalizable {
private static final ClassLoader dfltLdr = U.gridClassLoader();
/** */
- static final BinaryIdMapper DFLT_ID_MAPPER = new IdMapperWrapper(null);
-
- /** */
- static final BinaryIdMapper BASIC_CLS_ID_MAPPER = new BasicClassIdMapper();
-
- /** */
- static final char[] LOWER_CASE_CHARS;
-
- /** */
- static final char MAX_LOWER_CASE_CHAR = 0x7e;
-
- /**
- *
- */
- static {
- LOWER_CASE_CHARS = new char[MAX_LOWER_CASE_CHAR + 1];
-
- for (char c = 0; c <= MAX_LOWER_CASE_CHAR; c++)
- LOWER_CASE_CHARS[c] = Character.toLowerCase(c);
- }
-
- /** */
private final ConcurrentMap<Class<?>, PortableClassDescriptor> descByCls = new ConcurrentHashMap8<>();
/** Holds classes loaded by default class loader only. */
@@ -287,7 +265,7 @@ public class PortableContext implements Externalizable {
TypeDescriptors descs = new TypeDescriptors();
if (clsNames != null) {
- BinaryIdMapper idMapper = new IdMapperWrapper(globalIdMapper);
+ BinaryIdMapper idMapper = BinaryInternalIdMapper.create(globalIdMapper);
for (String clsName : clsNames) {
if (clsName.endsWith(".*")) { // Package wildcard
@@ -320,7 +298,7 @@ public class PortableContext implements Externalizable {
if (typeCfg.getIdMapper() != null)
idMapper = typeCfg.getIdMapper();
- idMapper = new IdMapperWrapper(idMapper);
+ idMapper = BinaryInternalIdMapper.create(idMapper);
BinarySerializer serializer = globalSerializer;
@@ -510,7 +488,7 @@ public class PortableContext implements Externalizable {
clsName.hashCode(),
clsName,
null,
- BASIC_CLS_ID_MAPPER,
+ BinaryInternalIdMapper.defaultInstance(),
null,
false,
keepDeserialized,
@@ -613,9 +591,9 @@ public class PortableContext implements Externalizable {
* @return Type ID.
*/
public int typeId(String typeName) {
- String shortTypeName = typeName(typeName);
+ String typeName0 = typeName(typeName);
- Integer id = predefinedTypeNames.get(shortTypeName);
+ Integer id = predefinedTypeNames.get(typeName0);
if (id != null)
return id;
@@ -623,7 +601,7 @@ public class PortableContext implements Externalizable {
if (marshCtx.isSystemType(typeName))
return typeName.hashCode();
- return userTypeIdMapper(shortTypeName).typeId(shortTypeName);
+ return userTypeIdMapper(typeName0).typeId(typeName0);
}
/**
@@ -642,13 +620,7 @@ public class PortableContext implements Externalizable {
public BinaryIdMapper userTypeIdMapper(int typeId) {
BinaryIdMapper idMapper = mappers.get(typeId);
- if (idMapper != null)
- return idMapper;
-
- if (predefinedTypes.containsKey(typeId))
- return DFLT_ID_MAPPER;
-
- return BASIC_CLS_ID_MAPPER;
+ return idMapper != null ? idMapper : BinaryInternalIdMapper.defaultInstance();
}
/**
@@ -658,7 +630,7 @@ public class PortableContext implements Externalizable {
private BinaryIdMapper userTypeIdMapper(String typeName) {
BinaryIdMapper idMapper = typeMappers.get(typeName);
- return idMapper != null ? idMapper : DFLT_ID_MAPPER;
+ return idMapper != null ? idMapper : BinaryInternalIdMapper.defaultInstance();
}
/** {@inheritDoc} */
@@ -704,7 +676,7 @@ public class PortableContext implements Externalizable {
id,
typeName,
null,
- DFLT_ID_MAPPER,
+ BinaryInternalIdMapper.defaultInstance(),
null,
false,
false,
@@ -746,7 +718,9 @@ public class PortableContext implements Externalizable {
// No-op.
}
- int id = idMapper.typeId(clsName);
+ String typeName = typeName(clsName);
+
+ int id = idMapper.typeId(typeName);
//Workaround for IGNITE-1358
if (predefinedTypes.get(id) != null)
@@ -760,8 +734,6 @@ public class PortableContext implements Externalizable {
throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
}
- String typeName = typeName(clsName);
-
typeMappers.put(typeName, idMapper);
Map<String, Integer> fieldsMeta = null;
@@ -934,26 +906,6 @@ public class PortableContext implements Externalizable {
}
/**
- * @param str String.
- * @return Hash code for given string converted to lower case.
- */
- private static int lowerCaseHashCode(String str) {
- int len = str.length();
-
- int h = 0;
-
- for (int i = 0; i < len; i++) {
- int c = str.charAt(i);
-
- c = c <= MAX_LOWER_CASE_CHAR ? LOWER_CASE_CHARS[c] : Character.toLowerCase(c);
-
- h = 31 * h + c;
- }
-
- return h;
- }
-
- /**
* Undeployment callback invoked when class loader is being undeployed.
*
* Some marshallers may want to clean their internal state that uses the undeployed class loader somehow.
@@ -970,55 +922,6 @@ public class PortableContext implements Externalizable {
}
/**
- */
- private static class IdMapperWrapper implements BinaryIdMapper {
- /** */
- private final BinaryIdMapper mapper;
-
- /**
- * @param mapper Custom ID mapper.
- */
- private IdMapperWrapper(@Nullable BinaryIdMapper mapper) {
- this.mapper = mapper;
- }
-
- /** {@inheritDoc} */
- @Override public int typeId(String clsName) {
- int id = 0;
-
- if (mapper != null)
- id = mapper.typeId(clsName);
-
- return id != 0 ? id : lowerCaseHashCode(typeName(clsName));
- }
-
- /** {@inheritDoc} */
- @Override public int fieldId(int typeId, String fieldName) {
- int id = 0;
-
- if (mapper != null)
- id = mapper.fieldId(typeId, fieldName);
-
- return id != 0 ? id : lowerCaseHashCode(fieldName);
- }
- }
-
- /**
- * Basic class ID mapper.
- */
- private static class BasicClassIdMapper implements BinaryIdMapper {
- /** {@inheritDoc} */
- @Override public int typeId(String clsName) {
- return clsName.hashCode();
- }
-
- /** {@inheritDoc} */
- @Override public int fieldId(int typeId, String fieldName) {
- return lowerCaseHashCode(fieldName);
- }
- }
-
- /**
* Type descriptors.
*/
private static class TypeDescriptors {
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69b177d/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
index e88db99..2dfa6d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
@@ -75,11 +75,11 @@ public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
customIdMapper.setClassName(CustomIdMapper.class.getName());
customIdMapper.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
- return ~PortableContext.DFLT_ID_MAPPER.typeId(clsName);
+ return ~BinaryInternalIdMapper.defaultInstance().typeId(clsName);
}
@Override public int fieldId(int typeId, String fieldName) {
- return typeId + ~PortableContext.DFLT_ID_MAPPER.fieldId(typeId, fieldName);
+ return typeId + ~BinaryInternalIdMapper.defaultInstance().fieldId(typeId, fieldName);
}
});
[28/55] [abbrv] ignite git commit: IGNITE-1917: Binary protocol
performance optimizations.
Posted by ag...@apache.org.
IGNITE-1917: Binary protocol performance optimizations.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4a1af37e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4a1af37e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4a1af37e
Branch: refs/heads/ignite-1.5
Commit: 4a1af37e39783d57b924138fb1e4aeddc137fc8a
Parents: 5ea0625
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 09:29:19 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 09:29:19 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 5 +-
.../internal/portable/BinaryEnumCache.java | 69 +
.../internal/portable/BinaryFieldAccessor.java | 805 ++++++++
.../portable/BinaryMetadataCollector.java | 66 +-
.../internal/portable/BinaryObjectEx.java | 8 +-
.../internal/portable/BinaryObjectImpl.java | 47 +-
.../portable/BinaryObjectOffheapImpl.java | 105 +-
.../internal/portable/BinaryReaderExImpl.java | 1823 +++++++++---------
.../internal/portable/BinaryReaderHandles.java | 108 ++
.../portable/BinaryThreadLocalContext.java | 69 +
.../internal/portable/BinaryTypeImpl.java | 1 +
.../internal/portable/BinaryWriteMode.java | 178 ++
.../internal/portable/BinaryWriterExImpl.java | 866 ++++-----
.../internal/portable/BinaryWriterHandles.java | 101 +
.../portable/BinaryWriterSchemaHolder.java | 148 ++
.../portable/GridPortableMarshaller.java | 11 +-
.../portable/PortableClassDescriptor.java | 747 +------
.../internal/portable/PortableContext.java | 8 +-
.../portable/PortableReaderContext.java | 105 -
.../internal/portable/PortableSchema.java | 405 ++--
.../PortableThreadLocalMemoryAllocator.java | 162 --
.../ignite/internal/portable/PortableUtils.java | 120 +-
.../builder/BinaryObjectBuilderImpl.java | 8 +-
.../portable/builder/PortableBuilderReader.java | 54 +-
.../streams/PortableAbstractOutputStream.java | 40 +-
.../streams/PortableHeapInputStream.java | 17 +
.../streams/PortableHeapOutputStream.java | 100 +-
.../streams/PortableMemoryAllocator.java | 67 +-
.../streams/PortableMemoryAllocatorChunk.java | 117 ++
.../streams/PortableOffheapOutputStream.java | 53 +-
.../portable/streams/PortableOutputStream.java | 79 +
.../streams/PortableSimpleMemoryAllocator.java | 66 -
.../PlatformBigEndianOutputStreamImpl.java | 30 +
.../memory/PlatformOutputStreamImpl.java | 63 +
.../ignite/internal/util/GridEnumCache.java | 56 -
.../portable/BinaryMarshallerSelfTest.java | 30 +-
.../testframework/junits/GridAbstractTest.java | 4 +-
.../Cache/Query/CacheQueriesTest.cs | 2 -
38 files changed, 3832 insertions(+), 2911 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 2b6eaad..2e8520e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -102,7 +102,6 @@ import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessor;
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.clock.GridClockSyncProcessor;
@@ -132,7 +131,7 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessor;
import org.apache.ignite.internal.processors.session.GridTaskSessionProcessor;
import org.apache.ignite.internal.processors.task.GridTaskProcessor;
import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
-import org.apache.ignite.internal.util.GridEnumCache;
+import org.apache.ignite.internal.portable.BinaryEnumCache;
import org.apache.ignite.internal.util.GridTimerTask;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -1941,7 +1940,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
// Clean internal class/classloader caches to avoid stopped contexts held in memory.
U.clearClassCache();
MarshallerExclusions.clearCache();
- GridEnumCache.clear();
+ BinaryEnumCache.clear();
gw.writeLock();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumCache.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumCache.java
new file mode 100644
index 0000000..fc042e5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryEnumCache.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.jsr166.ConcurrentHashMap8;
+
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Cache for enum constants.
+ */
+public class BinaryEnumCache {
+ /** Cache for enum constants. */
+ private static final ConcurrentMap<Class<?>, Object[]> ENUM_CACHE = new ConcurrentHashMap8<>();
+
+ /**
+ * Get value for the given class and ordinal.
+ *
+ * @param cls Class.
+ * @param ord Ordinal.
+ * @return Value.
+ * @throws BinaryObjectException In case of invalid ordinal.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T get(Class<?> cls, int ord) throws BinaryObjectException {
+ assert cls != null;
+
+ if (ord >= 0) {
+ Object[] vals = ENUM_CACHE.get(cls);
+
+ if (vals == null) {
+ vals = cls.getEnumConstants();
+
+ ENUM_CACHE.putIfAbsent(cls, vals);
+ }
+
+ if (ord < vals.length)
+ return (T) vals[ord];
+ else
+ throw new BinaryObjectException("Failed to get enum value for ordinal (do you have correct class " +
+ "version?) [cls=" + cls.getName() + ", ordinal=" + ord + ", totalValues=" + vals.length + ']');
+ }
+ else
+ return null;
+ }
+
+ /**
+ * Clears cache.
+ */
+ public static void clear() {
+ ENUM_CACHE.clear();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java
new file mode 100644
index 0000000..0eda375
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldAccessor.java
@@ -0,0 +1,805 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.util.GridUnsafe;
+import sun.misc.Unsafe;
+
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * Field accessor to speedup access.
+ */
+public abstract class BinaryFieldAccessor {
+ /** Field ID. */
+ protected final int id;
+
+ /** Mode. */
+ protected final BinaryWriteMode mode;
+
+ /**
+ * Create accessor for the field.
+ *
+ * @param field Field.
+ * @param id FIeld ID.
+ * @return Accessor.
+ */
+ public static BinaryFieldAccessor create(Field field, int id) {
+ BinaryWriteMode mode = PortableUtils.mode(field.getType());
+
+ switch (mode) {
+ case P_BYTE:
+ return new BytePrimitiveAccessor(field, id);
+
+ case P_BOOLEAN:
+ return new BooleanPrimitiveAccessor(field, id);
+
+ case P_SHORT:
+ return new ShortPrimitiveAccessor(field, id);
+
+ case P_CHAR:
+ return new CharPrimitiveAccessor(field, id);
+
+ case P_INT:
+ return new IntPrimitiveAccessor(field, id);
+
+ case P_LONG:
+ return new LongPrimitiveAccessor(field, id);
+
+ case P_FLOAT:
+ return new FloatPrimitiveAccessor(field, id);
+
+ case P_DOUBLE:
+ return new DoublePrimitiveAccessor(field, id);
+
+ default:
+ return new DefaultAccessor(field, id, mode);
+ }
+ }
+
+ /**
+ * Protected constructor.
+ *
+ * @param id Field ID.
+ * @param mode Mode;
+ */
+ protected BinaryFieldAccessor(int id, BinaryWriteMode mode) {
+ assert id != 0;
+ assert mode != null;
+
+ this.id = id;
+ this.mode = mode;
+ }
+
+ /**
+ * Get mode.
+ *
+ * @return Mode.
+ */
+ public BinaryWriteMode mode() {
+ return mode;
+ }
+
+ /**
+ * Write field.
+ *
+ * @param obj Object.
+ * @param writer Writer.
+ * @throws BinaryObjectException If failed.
+ */
+ public abstract void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException;
+
+ /**
+ * Read field.
+ *
+ * @param obj Object.
+ * @param reader Reader.
+ * @throws BinaryObjectException If failed.
+ */
+ public abstract void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException;
+
+ /**
+ * Base primitive field accessor.
+ */
+ private static abstract class AbstractPrimitiveAccessor extends BinaryFieldAccessor {
+ /** Unsafe instance. */
+ protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
+
+ /** Offset. */
+ protected final long offset;
+
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ * @param id Field ID.
+ * @param mode Mode.
+ */
+ protected AbstractPrimitiveAccessor(Field field, int id, BinaryWriteMode mode) {
+ super(id, mode);
+
+ assert field != null;
+
+ offset = UNSAFE.objectFieldOffset(field);
+ }
+ }
+
+ /**
+ * Byte field accessor.
+ */
+ private static class BytePrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public BytePrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_BYTE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ byte val = UNSAFE.getByte(obj, offset);
+
+ writer.writeByteFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ byte val = reader.readByte(id);
+
+ UNSAFE.putByte(obj, offset, val);
+ }
+ }
+
+ /**
+ * Boolean field accessor.
+ */
+ private static class BooleanPrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public BooleanPrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_BOOLEAN);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ boolean val = UNSAFE.getBoolean(obj, offset);
+
+ writer.writeBooleanFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ boolean val = reader.readBoolean(id);
+
+ UNSAFE.putBoolean(obj, offset, val);
+ }
+ }
+
+ /**
+ * Short field accessor.
+ */
+ private static class ShortPrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public ShortPrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_SHORT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ short val = UNSAFE.getShort(obj, offset);
+
+ writer.writeShortFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ short val = reader.readShort(id);
+
+ UNSAFE.putShort(obj, offset, val);
+ }
+ }
+
+ /**
+ * Char field accessor.
+ */
+ private static class CharPrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public CharPrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_CHAR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ char val = UNSAFE.getChar(obj, offset);
+
+ writer.writeCharFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ char val = reader.readChar(id);
+
+ UNSAFE.putChar(obj, offset, val);
+ }
+ }
+
+ /**
+ * Int field accessor.
+ */
+ private static class IntPrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public IntPrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_INT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ int val = UNSAFE.getInt(obj, offset);
+
+ writer.writeIntFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ int val = reader.readInt(id);
+
+ UNSAFE.putInt(obj, offset, val);
+ }
+ }
+
+ /**
+ * Long field accessor.
+ */
+ private static class LongPrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public LongPrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_LONG);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ long val = UNSAFE.getLong(obj, offset);
+
+ writer.writeLongFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ long val = reader.readLong(id);
+
+ UNSAFE.putLong(obj, offset, val);
+ }
+ }
+
+ /**
+ * Float field accessor.
+ */
+ private static class FloatPrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public FloatPrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_FLOAT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ float val = UNSAFE.getFloat(obj, offset);
+
+ writer.writeFloatFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ float val = reader.readFloat(id);
+
+ UNSAFE.putFloat(obj, offset, val);
+ }
+ }
+
+ /**
+ * Double field accessor.
+ */
+ private static class DoublePrimitiveAccessor extends AbstractPrimitiveAccessor {
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public DoublePrimitiveAccessor(Field field, int id) {
+ super(field, id, BinaryWriteMode.P_DOUBLE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ double val = UNSAFE.getDouble(obj, offset);
+
+ writer.writeDoubleFieldPrimitive(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ double val = reader.readDouble(id);
+
+ UNSAFE.putDouble(obj, offset, val);
+ }
+ }
+
+ /**
+ * Default accessor.
+ */
+ private static class DefaultAccessor extends BinaryFieldAccessor {
+ /** Target field. */
+ private final Field field;
+
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ * @param id Field ID.
+ * @param mode Mode.
+ */
+ public DefaultAccessor(Field field, int id, BinaryWriteMode mode) {
+ super(id, mode);
+
+ assert field != null;
+
+ this.field = field;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
+ assert obj != null;
+ assert writer != null;
+
+ writer.writeFieldIdNoSchemaUpdate(id);
+
+ Object val;
+
+ try {
+ val = field.get(obj);
+ }
+ catch (IllegalAccessException e) {
+ throw new BinaryObjectException("Failed to get value for field: " + field, e);
+ }
+
+ switch (mode) {
+ case BYTE:
+ writer.writeByteField((Byte) val);
+
+ break;
+
+ case SHORT:
+ writer.writeShortField((Short) val);
+
+ break;
+
+ case INT:
+ writer.writeIntField((Integer) val);
+
+ break;
+
+ case LONG:
+ writer.writeLongField((Long)val);
+
+ break;
+
+ case FLOAT:
+ writer.writeFloatField((Float)val);
+
+ break;
+
+ case DOUBLE:
+ writer.writeDoubleField((Double)val);
+
+ break;
+
+ case CHAR:
+ writer.writeCharField((Character)val);
+
+ break;
+
+ case BOOLEAN:
+ writer.writeBooleanField((Boolean)val);
+
+ break;
+
+ case DECIMAL:
+ writer.writeDecimalField((BigDecimal)val);
+
+ break;
+
+ case STRING:
+ writer.writeStringField((String)val);
+
+ break;
+
+ case UUID:
+ writer.writeUuidField((UUID)val);
+
+ break;
+
+ case DATE:
+ writer.writeDateField((Date)val);
+
+ break;
+
+ case TIMESTAMP:
+ writer.writeTimestampField((Timestamp)val);
+
+ break;
+
+ case BYTE_ARR:
+ writer.writeByteArrayField((byte[])val);
+
+ break;
+
+ case SHORT_ARR:
+ writer.writeShortArrayField((short[])val);
+
+ break;
+
+ case INT_ARR:
+ writer.writeIntArrayField((int[])val);
+
+ break;
+
+ case LONG_ARR:
+ writer.writeLongArrayField((long[])val);
+
+ break;
+
+ case FLOAT_ARR:
+ writer.writeFloatArrayField((float[])val);
+
+ break;
+
+ case DOUBLE_ARR:
+ writer.writeDoubleArrayField((double[])val);
+
+ break;
+
+ case CHAR_ARR:
+ writer.writeCharArrayField((char[])val);
+
+ break;
+
+ case BOOLEAN_ARR:
+ writer.writeBooleanArrayField((boolean[])val);
+
+ break;
+
+ case DECIMAL_ARR:
+ writer.writeDecimalArrayField((BigDecimal[])val);
+
+ break;
+
+ case STRING_ARR:
+ writer.writeStringArrayField((String[])val);
+
+ break;
+
+ case UUID_ARR:
+ writer.writeUuidArrayField((UUID[])val);
+
+ break;
+
+ case DATE_ARR:
+ writer.writeDateArrayField((Date[])val);
+
+ break;
+
+ case TIMESTAMP_ARR:
+ writer.writeTimestampArrayField((Timestamp[])val);
+
+ break;
+
+ case OBJECT_ARR:
+ writer.writeObjectArrayField((Object[])val);
+
+ break;
+
+ case COL:
+ writer.writeCollectionField((Collection<?>)val);
+
+ break;
+
+ case MAP:
+ writer.writeMapField((Map<?, ?>)val);
+
+ break;
+
+ case MAP_ENTRY:
+ writer.writeMapEntryField((Map.Entry<?, ?>)val);
+
+ break;
+
+ case PORTABLE_OBJ:
+ writer.writePortableObjectField((BinaryObjectImpl)val);
+
+ break;
+
+ case ENUM:
+ writer.writeEnumField((Enum<?>)val);
+
+ break;
+
+ case ENUM_ARR:
+ writer.writeEnumArrayField((Object[])val);
+
+ break;
+
+ case PORTABLE:
+ case EXTERNALIZABLE:
+ case OBJECT:
+ writer.writeObjectField(val);
+
+ break;
+
+ case CLASS:
+ writer.writeClassField((Class)val);
+
+ break;
+
+ default:
+ assert false : "Invalid mode: " + mode;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
+ Object val = null;
+
+ switch (mode) {
+ case BYTE:
+ val = reader.readByteNullable(id);
+
+ break;
+
+ case SHORT:
+ val = reader.readShortNullable(id);
+
+ break;
+
+ case INT:
+ val = reader.readIntNullable(id);
+
+ break;
+
+ case LONG:
+ val = reader.readLongNullable(id);
+
+ break;
+
+ case FLOAT:
+ val = reader.readFloatNullable(id);
+
+ break;
+
+ case DOUBLE:
+ val = reader.readDoubleNullable(id);
+
+ break;
+
+ case CHAR:
+ val = reader.readCharNullable(id);
+
+ break;
+
+ case BOOLEAN:
+ val = reader.readBooleanNullable(id);
+
+ break;
+
+ case DECIMAL:
+ val = reader.readDecimal(id);
+
+ break;
+
+ case STRING:
+ val = reader.readString(id);
+
+ break;
+
+ case UUID:
+ val = reader.readUuid(id);
+
+ break;
+
+ case DATE:
+ val = reader.readDate(id);
+
+ break;
+
+ case TIMESTAMP:
+ val = reader.readTimestamp(id);
+
+ break;
+
+ case BYTE_ARR:
+ val = reader.readByteArray(id);
+
+ break;
+
+ case SHORT_ARR:
+ val = reader.readShortArray(id);
+
+ break;
+
+ case INT_ARR:
+ val = reader.readIntArray(id);
+
+ break;
+
+ case LONG_ARR:
+ val = reader.readLongArray(id);
+
+ break;
+
+ case FLOAT_ARR:
+ val = reader.readFloatArray(id);
+
+ break;
+
+ case DOUBLE_ARR:
+ val = reader.readDoubleArray(id);
+
+ break;
+
+ case CHAR_ARR:
+ val = reader.readCharArray(id);
+
+ break;
+
+ case BOOLEAN_ARR:
+ val = reader.readBooleanArray(id);
+
+ break;
+
+ case DECIMAL_ARR:
+ val = reader.readDecimalArray(id);
+
+ break;
+
+ case STRING_ARR:
+ val = reader.readStringArray(id);
+
+ break;
+
+ case UUID_ARR:
+ val = reader.readUuidArray(id);
+
+ break;
+
+ case DATE_ARR:
+ val = reader.readDateArray(id);
+
+ break;
+
+ case TIMESTAMP_ARR:
+ val = reader.readTimestampArray(id);
+
+ break;
+
+ case OBJECT_ARR:
+ val = reader.readObjectArray(id);
+
+ break;
+
+ case COL:
+ val = reader.readCollection(id, null);
+
+ break;
+
+ case MAP:
+ val = reader.readMap(id, null);
+
+ break;
+
+ case MAP_ENTRY:
+ val = reader.readMapEntry(id);
+
+ break;
+
+ case PORTABLE_OBJ:
+ val = reader.readPortableObject(id);
+
+ break;
+
+ case ENUM:
+ val = reader.readEnum(id, field.getType());
+
+ break;
+
+ case ENUM_ARR:
+ val = reader.readEnumArray(id, field.getType().getComponentType());
+
+ break;
+
+ case PORTABLE:
+ case EXTERNALIZABLE:
+ case OBJECT:
+ val = reader.readObject(id);
+
+ break;
+
+ case CLASS:
+ val = reader.readClass(id);
+
+ break;
+
+ default:
+ assert false : "Invalid mode: " + mode;
+ }
+
+ try {
+ if (val != null || !field.getType().isPrimitive())
+ field.set(obj, val);
+ }
+ catch (IllegalAccessException e) {
+ throw new BinaryObjectException("Failed to set value for field: " + field, e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
index 28eb1d0..6ad0ad1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
@@ -82,163 +82,163 @@ class BinaryMetadataCollector implements BinaryWriter {
/** {@inheritDoc} */
@Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BYTE);
+ add(fieldName, BinaryWriteMode.BYTE);
}
/** {@inheritDoc} */
@Override public void writeShort(String fieldName, short val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.SHORT);
+ add(fieldName, BinaryWriteMode.SHORT);
}
/** {@inheritDoc} */
@Override public void writeInt(String fieldName, int val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.INT);
+ add(fieldName, BinaryWriteMode.INT);
}
/** {@inheritDoc} */
@Override public void writeLong(String fieldName, long val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.LONG);
+ add(fieldName, BinaryWriteMode.LONG);
}
/** {@inheritDoc} */
@Override public void writeFloat(String fieldName, float val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.FLOAT);
+ add(fieldName, BinaryWriteMode.FLOAT);
}
/** {@inheritDoc} */
@Override public void writeDouble(String fieldName, double val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DOUBLE);
+ add(fieldName, BinaryWriteMode.DOUBLE);
}
/** {@inheritDoc} */
@Override public void writeChar(String fieldName, char val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.CHAR);
+ add(fieldName, BinaryWriteMode.CHAR);
}
/** {@inheritDoc} */
@Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BOOLEAN);
+ add(fieldName, BinaryWriteMode.BOOLEAN);
}
/** {@inheritDoc} */
@Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL);
+ add(fieldName, BinaryWriteMode.DECIMAL);
}
/** {@inheritDoc} */
@Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.STRING);
+ add(fieldName, BinaryWriteMode.STRING);
}
/** {@inheritDoc} */
@Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.UUID);
+ add(fieldName, BinaryWriteMode.UUID);
}
/** {@inheritDoc} */
@Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DATE);
+ add(fieldName, BinaryWriteMode.DATE);
}
/** {@inheritDoc} */
@Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP);
+ add(fieldName, BinaryWriteMode.TIMESTAMP);
}
/** {@inheritDoc} */
@Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.ENUM);
+ add(fieldName, BinaryWriteMode.ENUM);
}
/** {@inheritDoc} */
@Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.ENUM_ARR);
+ add(fieldName, BinaryWriteMode.ENUM_ARR);
}
/** {@inheritDoc} */
@Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.OBJECT);
+ add(fieldName, BinaryWriteMode.OBJECT);
}
/** {@inheritDoc} */
@Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BYTE_ARR);
+ add(fieldName, BinaryWriteMode.BYTE_ARR);
}
/** {@inheritDoc} */
@Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.SHORT_ARR);
+ add(fieldName, BinaryWriteMode.SHORT_ARR);
}
/** {@inheritDoc} */
@Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.INT_ARR);
+ add(fieldName, BinaryWriteMode.INT_ARR);
}
/** {@inheritDoc} */
@Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.LONG_ARR);
+ add(fieldName, BinaryWriteMode.LONG_ARR);
}
/** {@inheritDoc} */
@Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.FLOAT_ARR);
+ add(fieldName, BinaryWriteMode.FLOAT_ARR);
}
/** {@inheritDoc} */
@Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DOUBLE_ARR);
+ add(fieldName, BinaryWriteMode.DOUBLE_ARR);
}
/** {@inheritDoc} */
@Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.CHAR_ARR);
+ add(fieldName, BinaryWriteMode.CHAR_ARR);
}
/** {@inheritDoc} */
@Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BOOLEAN_ARR);
+ add(fieldName, BinaryWriteMode.BOOLEAN_ARR);
}
/** {@inheritDoc} */
@Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR);
+ add(fieldName, BinaryWriteMode.DECIMAL_ARR);
}
/** {@inheritDoc} */
@Override public void writeStringArray(String fieldName, @Nullable String[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.STRING_ARR);
+ add(fieldName, BinaryWriteMode.STRING_ARR);
}
/** {@inheritDoc} */
@Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.UUID_ARR);
+ add(fieldName, BinaryWriteMode.UUID_ARR);
}
/** {@inheritDoc} */
@Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DATE_ARR);
+ add(fieldName, BinaryWriteMode.DATE_ARR);
}
/** {@inheritDoc} */
@Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP_ARR);
+ add(fieldName, BinaryWriteMode.TIMESTAMP_ARR);
}
/** {@inheritDoc} */
@Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.OBJECT_ARR);
+ add(fieldName, BinaryWriteMode.OBJECT_ARR);
}
/** {@inheritDoc} */
@Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.COL);
+ add(fieldName, BinaryWriteMode.COL);
}
/** {@inheritDoc} */
@Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.MAP);
+ add(fieldName, BinaryWriteMode.MAP);
}
/** {@inheritDoc} */
@@ -257,7 +257,7 @@ class BinaryMetadataCollector implements BinaryWriter {
* @param mode Field mode.
* @throws BinaryObjectException In case of error.
*/
- private void add(String name, PortableClassDescriptor.Mode mode) throws BinaryObjectException {
+ private void add(String name, BinaryWriteMode mode) throws BinaryObjectException {
assert name != null;
int fieldTypeId = mode.typeId();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
index 6902675..597fad5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
@@ -79,7 +79,7 @@ public abstract class BinaryObjectEx implements BinaryObject {
* @param fieldName Field name.
* @return Field value.
*/
- @Nullable protected abstract <F> F field(PortableReaderContext ctx, String fieldName);
+ @Nullable protected abstract <F> F field(BinaryReaderHandles ctx, String fieldName);
/**
* Get schema ID.
@@ -157,7 +157,7 @@ public abstract class BinaryObjectEx implements BinaryObject {
* @param handles Handles for already traversed objects.
* @return String representation.
*/
- private String toString(PortableReaderContext ctx, IdentityHashMap<BinaryObject, Integer> handles) {
+ private String toString(BinaryReaderHandles ctx, IdentityHashMap<BinaryObject, Integer> handles) {
int idHash = System.identityHashCode(this);
BinaryType meta;
@@ -232,9 +232,9 @@ public abstract class BinaryObjectEx implements BinaryObject {
/** {@inheritDoc} */
@Override public String toString() {
try {
- PortableReaderContext ctx = new PortableReaderContext();
+ BinaryReaderHandles ctx = new BinaryReaderHandles();
- ctx.setPortableHandler(start(), this);
+ ctx.put(start(), this);
return toString(ctx, new IdentityHashMap<BinaryObject, Integer>());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
index d9339f8..7ab9497 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
@@ -33,7 +32,6 @@ import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryField;
import org.jetbrains.annotations.Nullable;
import java.io.Externalizable;
@@ -257,17 +255,13 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Nullable @Override public <F> F field(String fieldName) throws BinaryObjectException {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, start, null);
-
- return (F)reader.unmarshalField(fieldName);
+ return (F)newReader().unmarshalField(fieldName);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Nullable @Override public <F> F field(int fieldId) throws BinaryObjectException {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, start, null);
-
- return (F)reader.unmarshalField(fieldId);
+ return (F)newReader().unmarshalField(fieldId);
}
/** {@inheritDoc} */
@@ -400,11 +394,13 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
break;
- default: {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, start, null);
+ default:
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, PortableHeapInputStream.create(arr, fieldPos),
+ null, new BinaryReaderHandles());
- val = reader.unmarshalFieldByAbsolutePosition(fieldPos);
- }
+ val = reader.unmarshal();
+
+ break;
}
return (F)val;
@@ -412,21 +408,15 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Nullable @Override protected <F> F field(PortableReaderContext rCtx, String fieldName) {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx,
- new PortableHeapInputStream(arr),
- start,
- null,
- rCtx);
+ @Nullable @Override protected <F> F field(BinaryReaderHandles rCtx, String fieldName) {
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, PortableHeapInputStream.create(arr, start), null, rCtx);
return (F)reader.unmarshalField(fieldName);
}
/** {@inheritDoc} */
@Override public boolean hasField(String fieldName) {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, start, null);
-
- return reader.hasField(fieldName);
+ return newReader().hasField(fieldName);
}
/** {@inheritDoc} */
@@ -458,9 +448,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
/** {@inheritDoc} */
@Override protected PortableSchema createSchema() {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, start, null);
-
- return reader.getOrCreateSchema();
+ return newReader().getOrCreateSchema();
}
/** {@inheritDoc} */
@@ -569,7 +557,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
*/
private Object deserializeValue() {
// TODO: IGNITE-1272 - Deserialize with proper class loader.
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, start, null);
+ BinaryReaderExImpl reader = newReader();
Object obj0 = reader.deserialize();
@@ -582,4 +570,13 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
return obj0;
}
+
+ /**
+ * Create new reader for this object.
+ *
+ * @return Reader.
+ */
+ private BinaryReaderExImpl newReader() {
+ return new BinaryReaderExImpl(ctx, PortableHeapInputStream.create(arr, start), null, new BinaryReaderHandles());
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
index a71c98a..6f9190a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
@@ -17,18 +17,11 @@
package org.apache.ignite.internal.portable;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.UUID;
-
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryField;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.internal.portable.streams.PortableOffheapInputStream;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
@@ -37,13 +30,20 @@ import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryField;
import org.jetbrains.annotations.Nullable;
import sun.misc.Unsafe;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.UUID;
+
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE;
@@ -131,12 +131,7 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
/** {@inheritDoc} */
@Override protected PortableSchema createSchema() {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx,
- new PortableOffheapInputStream(ptr, size, false),
- start,
- null);
-
- return reader.getOrCreateSchema();
+ return newReader().getOrCreateSchema();
}
/** {@inheritDoc} */
@@ -170,23 +165,13 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Nullable @Override public <F> F field(String fieldName) throws BinaryObjectException {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx,
- new PortableOffheapInputStream(ptr, size, false),
- start,
- null);
-
- return (F)reader.unmarshalField(fieldName);
+ return (F)newReader().unmarshalField(fieldName);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Nullable @Override public <F> F field(int fieldId) throws BinaryObjectException {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx,
- new PortableOffheapInputStream(ptr, size, false),
- start,
- null);
-
- return (F)reader.unmarshalField(fieldId);
+ return (F)newReader().unmarshalField(fieldId);
}
/** {@inheritDoc} */
@@ -320,14 +305,16 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
break;
- default: {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx,
- new PortableOffheapInputStream(ptr, size, false),
- start,
- null);
+ default:
+ PortableOffheapInputStream stream = new PortableOffheapInputStream(ptr, size, false);
- val = reader.unmarshalFieldByAbsolutePosition(fieldPos);
- }
+ stream.position(fieldPos);
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, stream, null, new BinaryReaderHandles());
+
+ val = reader.unmarshal();
+
+ break;
}
return (F)val;
@@ -335,24 +322,19 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Nullable @Override protected <F> F field(PortableReaderContext rCtx, String fieldName) {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx,
- new PortableOffheapInputStream(ptr, size, false),
- start,
- null,
- rCtx);
+ @Nullable @Override protected <F> F field(BinaryReaderHandles rCtx, String fieldName) {
+ PortableOffheapInputStream stream = new PortableOffheapInputStream(ptr, size, false);
+
+ stream.position(start);
+
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, stream, null, rCtx);
return (F)reader.unmarshalField(fieldName);
}
/** {@inheritDoc} */
@Override public boolean hasField(String fieldName) {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx,
- new PortableOffheapInputStream(ptr, size, false),
- start,
- null);
-
- return reader.hasField(fieldName);
+ return newReader().hasField(fieldName);
}
/** {@inheritDoc} */
@@ -438,12 +420,19 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
*/
private Object deserializeValue() {
// TODO: IGNITE-1272 - Deserialize with proper class loader.
- BinaryReaderExImpl reader = new BinaryReaderExImpl(
- ctx,
- new PortableOffheapInputStream(ptr, size, false),
- start,
- null);
+ return newReader().deserialize();
+ }
+
+ /**
+ * Create new reader for this object.
+ *
+ * @return Reader.
+ */
+ private BinaryReaderExImpl newReader() {
+ PortableOffheapInputStream stream = new PortableOffheapInputStream(ptr, size, false);
+
+ stream.position(start);
- return reader.deserialize();
+ return new BinaryReaderExImpl(ctx, stream, null, new BinaryReaderHandles());
}
}
\ No newline at end of file
[49/55] [abbrv] ignite git commit: IGNITE-1282 - Backward
compatibility.
Posted by ag...@apache.org.
IGNITE-1282 - Backward compatibility.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f17dfd03
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f17dfd03
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f17dfd03
Branch: refs/heads/ignite-1.5
Commit: f17dfd03b3c7db5a8fc54a095ae17a14a1e32455
Parents: 70746cb
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 19:57:51 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 19:57:51 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/configuration/CacheConfiguration.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f17dfd03/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 5b246b3..e87346f 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -1836,7 +1836,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @return {@code this} for chaining.
*/
public CacheConfiguration<K, V> setIndexedTypes(Class<?>... indexedTypes) {
- A.notNull(indexedTypes, "indexedTypes");
+ if (F.isEmpty(indexedTypes))
+ return this;
int len = indexedTypes.length;
[34/55] [abbrv] ignite git commit: Merged ignite-1945 into ignite-1282
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
index aaefc90..1cde3f8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
@@ -21,8 +21,6 @@ import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.testframework.config.GridTestProperties;
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.CLOCK;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java
index c1144b6..7ee6cb6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractDataStreamerSelfTest.java
@@ -26,11 +26,12 @@ import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.binary.BinaryReader;
@@ -61,12 +62,13 @@ public abstract class GridCacheBinaryObjectsAbstractDataStreamerSelfTest extends
cfg.setCacheConfiguration(cacheCfg);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setTypeConfigurations(Arrays.asList(
+ bCfg.setTypeConfigurations(Arrays.asList(
new BinaryTypeConfiguration(TestObject.class.getName())));
- cfg.setMarshaller(marsh);
+ cfg.setBinaryConfiguration(bCfg);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java
index b626093..5fb02b6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractMultiThreadedSelfTest.java
@@ -27,12 +27,13 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.binary.BinaryObject;
@@ -67,12 +68,13 @@ public abstract class GridCacheBinaryObjectsAbstractMultiThreadedSelfTest extend
cfg.setCacheConfiguration(cacheCfg);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setTypeConfigurations(Arrays.asList(
+ bCfg.setTypeConfigurations(Arrays.asList(
new BinaryTypeConfiguration(TestObject.class.getName())));
- cfg.setMarshaller(marsh);
+ cfg.setBinaryConfiguration(bCfg);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractSelfTest.java
index 0892750..3925045 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -46,7 +46,7 @@ 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.U;
import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.Binarylizable;
@@ -107,7 +107,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
cfg.setCacheConfiguration(cacheCfg);
- cfg.setMarshaller(new PortableMarshaller());
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
index d19c1ce..99e2073 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
@@ -33,7 +33,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -63,7 +63,7 @@ public class GridCacheClientNodeBinaryObjectMetadataMultinodeTest extends GridCo
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder).setForceServerMode(true);
- cfg.setMarshaller(new PortableMarshaller());
+ cfg.setMarshaller(new BinaryMarshaller());
CacheConfiguration ccfg = new CacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
index 10c06a7..256e5fd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
@@ -20,16 +20,17 @@ package org.apache.ignite.internal.processors.cache.portable;
import java.util.Arrays;
import java.util.Collection;
import org.apache.ignite.Ignite;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheKeyConfiguration;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -62,19 +63,23 @@ public class GridCacheClientNodeBinaryObjectMetadataTest extends GridCacheAbstra
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
+
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
+ bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
- typeCfg.setClassName(TestObject1.class.getName());
+ typeCfg.setTypeName(TestObject1.class.getName());
CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(TestObject1.class.getName(), "val2");
cfg.setCacheKeyCfg(keyCfg);
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+ bCfg.setTypeConfigurations(Arrays.asList(typeCfg));
+
+ cfg.setBinaryConfiguration(bCfg);
if (gridName.equals(getTestGridName(gridCount() - 1)))
cfg.setClientMode(true);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java
index 13a4c12..d3df9b7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableStoreAbstractSelfTest.java
@@ -25,9 +25,10 @@ import java.util.Map;
import java.util.Set;
import javax.cache.Cache;
import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -50,11 +51,13 @@ public abstract class GridCachePortableStoreAbstractSelfTest extends GridCommonA
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName()));
+ bCfg.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setBinaryConfiguration(bCfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
CacheConfiguration cacheCfg = new CacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
index 2e868da..30a7ca5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
@@ -25,7 +25,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryMemorySizeSelfT
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
*
@@ -33,13 +33,15 @@ import org.apache.ignite.marshaller.portable.PortableMarshaller;
public class GridPortableCacheEntryMemorySizeSelfTest extends GridCacheEntryMemorySizeSelfTest {
/** {@inheritDoc} */
@Override protected Marshaller createMarshaller() throws IgniteCheckedException {
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
marsh.setContext(new MarshallerContextTestImpl(null));
- PortableContext pCtx = new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
+ IgniteConfiguration iCfg = new IgniteConfiguration();
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", pCtx);
+ PortableContext pCtx = new PortableContext(BinaryNoopMetadataHandler.instance(), iCfg);
+
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", pCtx, iCfg);
return marsh;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java
index 4b7286a..b01a363 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableDuplicateIndexObjectsAbstractSelfTest.java
@@ -26,11 +26,12 @@ import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheTypeMetadata;
import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObject;
/**
@@ -46,11 +47,13 @@ public abstract class GridPortableDuplicateIndexObjectsAbstractSelfTest extends
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Collections.singletonList(TestPortable.class.getName()));
+ bCfg.setClassNames(Collections.singletonList(TestPortable.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setBinaryConfiguration(bCfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java
index 58adfe3..3777a20 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/DataStreamProcessorPortableSelfTest.java
@@ -23,7 +23,7 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.stream.StreamReceiver;
/**
@@ -34,7 +34,7 @@ public class DataStreamProcessorPortableSelfTest extends DataStreamProcessorSelf
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
cfg.setMarshaller(marsh);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java
index 3bc3575..6ce5961 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/datastreaming/GridDataStreamerImplSelfTest.java
@@ -30,7 +30,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.binary.BinaryObject;
@@ -67,7 +67,7 @@ public class GridDataStreamerImplSelfTest extends GridCommonAbstractTest {
cfg.setDiscoverySpi(discoSpi);
if (portables) {
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
cfg.setMarshaller(marsh);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java
index d5639fd..c18260b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheAffinityRoutingPortableSelfTest.java
@@ -19,9 +19,10 @@ package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import java.util.Collections;
import org.apache.ignite.cache.CacheKeyConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryTypeConfiguration;
/**
@@ -34,17 +35,19 @@ public class GridCacheAffinityRoutingPortableSelfTest extends GridCacheAffinityR
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
- typeCfg.setClassName(AffinityTestKey.class.getName());
+ typeCfg.setTypeName(AffinityTestKey.class.getName());
CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(AffinityTestKey.class.getName(), "affKey");
cfg.setCacheKeyCfg(keyCfg);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setTypeConfigurations(Collections.singleton(typeCfg));
+ bCfg.setTypeConfigurations(Collections.singleton(typeCfg));
- cfg.setMarshaller(marsh);
+ cfg.setBinaryConfiguration(bCfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.java
index ab6b0dd..0f3e67c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheMemoryModePortableSelfTest.java
@@ -19,7 +19,7 @@ package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheMemoryModeSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
* Memory models test.
@@ -29,7 +29,7 @@ public class GridCacheMemoryModePortableSelfTest extends GridCacheMemoryModeSelf
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- cfg.setMarshaller(new PortableMarshaller());
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java
index 0c6b77c..8996355 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredAtomicPortableSelfTest.java
@@ -18,9 +18,10 @@
package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import java.util.Arrays;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredAtomicSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
*
@@ -36,11 +37,11 @@ public class GridCacheOffHeapTieredAtomicPortableSelfTest extends GridCacheOffHe
// Enable binary.
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(TestValue.class.getName()));
+ bCfg.setClassNames(Arrays.asList(TestValue.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java
index 215567c..1eb5d1a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionAtomicPortableSelfTest.java
@@ -18,9 +18,10 @@
package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import java.util.Arrays;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionAtomicSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObject;
/**
@@ -32,11 +33,11 @@ public class GridCacheOffHeapTieredEvictionAtomicPortableSelfTest extends GridCa
// Enable binary.
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(TestValue.class.getName()));
+ bCfg.setClassNames(Arrays.asList(TestValue.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java
index 674e17a..85f0298 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredEvictionPortableSelfTest.java
@@ -18,9 +18,10 @@
package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import java.util.Arrays;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObject;
/**
@@ -32,11 +33,11 @@ public class GridCacheOffHeapTieredEvictionPortableSelfTest extends GridCacheOff
// Enable binary.
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(TestValue.class.getName()));
+ bCfg.setClassNames(Arrays.asList(TestValue.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java
index 9f4e2c5..22c9a70 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCacheOffHeapTieredPortableSelfTest.java
@@ -18,9 +18,10 @@
package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import java.util.Arrays;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
*
@@ -36,11 +37,11 @@ public class GridCacheOffHeapTieredPortableSelfTest extends GridCacheOffHeapTier
// Enable binary.
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(TestValue.class.getName()));
+ bCfg.setClassNames(Arrays.asList(TestValue.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java
index d984756..8e4bb35 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesNearPartitionedByteArrayValuesSelfTest.java
@@ -18,7 +18,7 @@ package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheAbstractNearPartitionedByteArrayValuesSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
*
@@ -34,7 +34,7 @@ public class GridCachePortablesNearPartitionedByteArrayValuesSelfTest
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- cfg.setMarshaller(new PortableMarshaller());
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java
index 5830b12..256e0c2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/distributed/dht/GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest.java
@@ -19,7 +19,7 @@ package org.apache.ignite.internal.processors.cache.portable.distributed.dht;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheAbstractPartitionedOnlyByteArrayValuesSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
*
@@ -35,7 +35,7 @@ public class GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- cfg.setMarshaller(new PortableMarshaller());
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.java
index d7dda61..5c5bb5a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheFullApiTestSuite.java
@@ -18,7 +18,7 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.config.GridTestProperties;
/**
@@ -30,7 +30,7 @@ public class IgnitePortableCacheFullApiTestSuite extends TestSuite {
* @throws Exception In case of error.
*/
public static TestSuite suite() throws Exception {
- GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, PortableMarshaller.class.getName());
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
return IgniteCacheFullApiSelfTestSuite.suite();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java
index db20e48..09a0adb 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheTestSuite.java
@@ -44,7 +44,7 @@ import org.apache.ignite.internal.processors.cache.portable.distributed.dht.Grid
import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortablesNearPartitionedByteArrayValuesSelfTest;
import org.apache.ignite.internal.processors.cache.portable.distributed.dht.GridCachePortablesPartitionedOnlyByteArrayValuesSelfTest;
import org.apache.ignite.internal.processors.datastreamer.DataStreamProcessorSelfTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.config.GridTestProperties;
/**
@@ -56,7 +56,7 @@ public class IgnitePortableCacheTestSuite extends TestSuite {
* @throws Exception In case of error.
*/
public static TestSuite suite() throws Exception {
- GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, PortableMarshaller.class.getName());
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
TestSuite suite = new TestSuite("Portable Cache Test Suite");
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
index 1128d67..16eeb2b 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
@@ -62,7 +62,7 @@ public class IgnitePortableObjectsTestSuite extends TestSuite {
* @throws Exception If failed.
*/
public static TestSuite suite() throws Exception {
- TestSuite suite = new TestSuite("GridGain Portable Objects Test Suite");
+ TestSuite suite = new TestSuite("Ignite Binary Objects Test Suite");
suite.addTestSuite(BinaryMarshallerSelfTest.class);
suite.addTestSuite(GridPortableMarshallerCtxDisabledSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
index 01c2db2..e5c9425 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
* Checks behavior on exception while unmarshalling key.
@@ -90,8 +91,9 @@ public class IgniteCacheP2pUnmarshallingQueryErrorTest extends IgniteCacheP2pUnm
* @return {@code True} if portable marshaller is configured.
*/
private boolean portableMarshaller() {
- IgniteEx kernal = (IgniteKernal)ignite(0);
+ IgniteEx kernal = (IgniteEx)ignite(0);
- return "PortableMarshaller".equals(kernal.context().config().getMarshaller().getClass().getSimpleName());
+ return BinaryMarshaller.class.getSimpleName().equals(kernal.context().config().getMarshaller().getClass()
+ .getSimpleName());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java
index 27ac436..b241b86 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgnitePortableCacheQueryTestSuite.java
@@ -45,7 +45,7 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon
import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest;
import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest;
import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest;
import org.apache.ignite.testframework.config.GridTestProperties;
@@ -58,7 +58,7 @@ public class IgnitePortableCacheQueryTestSuite extends TestSuite {
* @throws Exception In case of error.
*/
public static TestSuite suite() throws Exception {
- GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, PortableMarshaller.class.getName());
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
TestSuite suite = new TestSuite("Grid Cache Query Test Suite using PortableMarshaller");
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
index 9755033..79909c3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
@@ -22,12 +22,12 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
- <property name="gridName" value="grid1"/>
+ <property name="gridName" value="grid1"/>
- <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsUpdateFrequency" value="1000"/>
<property name="metricsLogFrequency" value="0"/>
<property name="userAttributes">
@@ -52,6 +52,26 @@
</list>
</property>
+ <property name="binaryConfiguration">
+ <bean class="org.apache.ignite.configuration.BinaryConfiguration">
+ <property name="compactFooter" value="false"/>
+ <property name="typeConfigurations">
+ <list>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
+ </bean>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
+ </bean>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeEnum"/>
+ </bean>
+ </list>
+ </property>
+
+ </bean>
+ </property>
+
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
@@ -69,23 +89,7 @@
<!-- Binary marshaller configuration -->
<property name="marshaller">
- <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
- <property name="compactFooter" value="false" />
- <property name="typeConfigurations">
- <list>
- <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
- </bean>
- <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
- </bean>
- <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputeEnum"/>
- </bean>
- </list>
- </property>
- </bean>
+ <bean class="org.apache.ignite.marshaller.portable.BinaryMarshaller"/>
</property>
-
</bean>
</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
index 74444a1..2f7d746 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
@@ -25,12 +25,16 @@
<property name="localHost" value="127.0.0.1"/>
<property name="connectorConfiguration"><null/></property>
- <property name="marshaller">
- <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
+ <property name="binaryConfiguration">
+ <bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="false"/>
</bean>
</property>
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.portable.BinaryMarshaller"/>
+ </property>
+
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
[33/55] [abbrv] ignite git commit: IGNITE-1958: Removed unused method.
Posted by ag...@apache.org.
IGNITE-1958: Removed unused method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b876f76b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b876f76b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b876f76b
Branch: refs/heads/ignite-1.5
Commit: b876f76bedceab4d8ffbfb9b3fc69700fd005af4
Parents: 6d83421
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 11:32:30 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 11:32:30 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/portable/BinaryObjectImpl.java | 2 +-
.../internal/portable/BinaryObjectOffheapImpl.java | 4 +---
.../ignite/internal/portable/BinaryReaderExImpl.java | 12 ++----------
3 files changed, 4 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b876f76b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
index 7ab9497..37c88e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
@@ -416,7 +416,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
/** {@inheritDoc} */
@Override public boolean hasField(String fieldName) {
- return newReader().hasField(fieldName);
+ return newReader().findFieldByName(fieldName);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b876f76b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
index 6f9190a..1db3470 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.portable;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryField;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
@@ -26,7 +25,6 @@ import org.apache.ignite.internal.portable.streams.PortableOffheapInputStream;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -334,7 +332,7 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
/** {@inheritDoc} */
@Override public boolean hasField(String fieldName) {
- return newReader().hasField(fieldName);
+ return newReader().findFieldByName(fieldName);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b876f76b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 5e31532..356aaae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -300,7 +300,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @throws BinaryObjectException In case of error.
*/
@Nullable Object unmarshalField(String fieldName) throws BinaryObjectException {
- return hasField(fieldName) ? unmarshal() : null;
+ return findFieldByName(fieldName) ? unmarshal() : null;
}
/**
@@ -1374,14 +1374,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
", actual=" + flag + ']');
}
- /**
- * @param fieldName Field name.
- * @return {@code True} if field is set.
- */
- public boolean hasField(String fieldName) {
- return findFieldById(fieldId(fieldName));
- }
-
/** {@inheritDoc} */
@Override public BinaryRawReader rawReader() {
in.position(rawOff);
@@ -2475,7 +2467,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @param name Field name.
* @return Offset.
*/
- private boolean findFieldByName(String name) {
+ public boolean findFieldByName(String name) {
assert hdrLen != 0;
if (footerLen == 0)
[37/55] [abbrv] ignite git commit: IGNITE-1960: Reworked and
simplified binary object header write logic.
Posted by ag...@apache.org.
IGNITE-1960: Reworked and simplified binary object header write logic.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/462f8332
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/462f8332
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/462f8332
Branch: refs/heads/ignite-1.5
Commit: 462f8332b5b745c6f748d157657365cf576355db
Parents: b876f76
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 13:01:21 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 13:01:21 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryWriterExImpl.java | 101 ++++++++++++-------
.../portable/PortableClassDescriptor.java | 45 ++++-----
.../ignite/internal/portable/PortableUtils.java | 32 +-----
.../builder/BinaryObjectBuilderImpl.java | 8 +-
.../streams/PortableAbstractOutputStream.java | 7 +-
.../portable/streams/PortableOutputStream.java | 7 ++
.../memory/PlatformOutputStreamImpl.java | 7 +-
7 files changed, 107 insertions(+), 100 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8332/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
index 6f8534a..ec47f57 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
@@ -51,11 +51,11 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DECIMAL;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DECIMAL_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DOUBLE;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DOUBLE_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.ENUM;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.ENUM_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLAGS_POS;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLOAT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLOAT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT;
@@ -65,18 +65,17 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG_AR
import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENTRY;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.OPTM_MARSH;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.PORTABLE_OBJ;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SCHEMA_ID_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
@@ -265,44 +264,53 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
- * @param bytes Number of bytes to reserve.
- * @return Offset.
+ * Perform pre-write. Reserves space for header and writes class name if needed.
+ *
+ * @param clsName Class name (optional).
*/
- public int reserve(int bytes) {
- int pos = out.position();
+ public void preWrite(@Nullable String clsName) {
+ out.position(out.position() + DFLT_HDR_LEN);
- out.position(pos + bytes);
-
- return pos;
+ if (clsName != null)
+ doWriteString(clsName);
}
/**
- * Perform post-write activity. This includes:
- * - writing flags;
- * - writing object length;
- * - writing schema offset;
- * - writing schema to the tail.
+ * Perform post-write. Fills object header.
*
* @param userType User type flag.
+ * @param registered Whether type is registered.
+ * @param hashCode Hash code.
*/
- public void postWrite(boolean userType) {
- short flags = userType ? PortableUtils.FLAG_USR_TYP : 0;
+ public void postWrite(boolean userType, boolean registered, int hashCode) {
+ short flags;
+ boolean useCompactFooter;
- boolean useCompactFooter = ctx.isCompactFooter() && userType;
+ if (userType) {
+ if (ctx.isCompactFooter()) {
+ flags = PortableUtils.FLAG_USR_TYP | PortableUtils.FLAG_COMPACT_FOOTER;
+ useCompactFooter = true;
+ }
+ else {
+ flags = PortableUtils.FLAG_USR_TYP;
+ useCompactFooter = false;
+ }
+ }
+ else {
+ flags = 0;
+ useCompactFooter = false;
+ }
- if (useCompactFooter)
- flags |= PortableUtils.FLAG_COMPACT_FOOTER;
+ int finalSchemaId;
+ int offset;
if (fieldCnt != 0) {
- flags |= PortableUtils.FLAG_HAS_SCHEMA;
-
- // Write schema ID.
- out.unsafeWriteInt(start + SCHEMA_ID_POS, schemaId);
-
- // Write schema offset.
- out.unsafeWriteInt(start + SCHEMA_OR_RAW_OFF_POS, out.position() - start);
+ finalSchemaId = schemaId;
+ offset = out.position() - start;
// Write the schema.
+ flags |= PortableUtils.FLAG_HAS_SCHEMA;
+
int offsetByteCnt = schema.write(out, fieldCnt, useCompactFooter);
if (offsetByteCnt == PortableUtils.OFFSET_1)
@@ -319,20 +327,33 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
else {
if (rawOffPos != 0) {
- // If there are no schema, we are free to write raw offset to schema offset.
- flags |= PortableUtils.FLAG_HAS_RAW;
+ finalSchemaId = 0;
+ offset = rawOffPos - start;
- out.unsafeWriteInt(start + SCHEMA_OR_RAW_OFF_POS, rawOffPos - start);
+ // If there is no schema, we are free to write raw offset to schema offset.
+ flags |= PortableUtils.FLAG_HAS_RAW;
+ }
+ else {
+ finalSchemaId = 0;
+ offset = 0;
}
- else
- out.unsafeWriteInt(start + SCHEMA_OR_RAW_OFF_POS, 0);
}
- // Write flags.
- out.unsafeWriteShort(start + FLAGS_POS, flags);
+ // Actual write.
+ int retPos = out.position();
- // Write length.
- out.unsafeWriteInt(start + TOTAL_LEN_POS, out.position() - start);
+ out.unsafePosition(start);
+
+ out.unsafeWriteByte(OBJ);
+ out.unsafeWriteByte(PROTO_VER);
+ out.unsafeWriteShort(flags);
+ out.unsafeWriteInt(registered ? typeId : UNREGISTERED_TYPE_ID);
+ out.unsafeWriteInt(hashCode);
+ out.unsafeWriteInt(retPos - start);
+ out.unsafeWriteInt(finalSchemaId);
+ out.unsafeWriteInt(offset);
+
+ out.unsafePosition(retPos);
}
/**
@@ -1645,7 +1666,11 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public int reserveInt() {
- return reserve(LEN_INT);
+ int pos = out.position();
+
+ out.position(pos + LEN_INT);
+
+ return pos;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8332/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index c233267..7c857be 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -548,14 +548,14 @@ public class PortableClassDescriptor {
break;
case PORTABLE:
- if (writeHeader(obj, writer)) {
+ if (preWrite(writer, obj)) {
try {
if (serializer != null)
serializer.writeBinary(obj, writer);
else
((Binarylizable)obj).writeBinary(writer);
- writer.postWrite(userType);
+ postWrite(writer, obj);
// Check whether we need to update metadata.
if (obj.getClass() != BinaryMetadata.class) {
@@ -590,13 +590,13 @@ public class PortableClassDescriptor {
break;
case EXTERNALIZABLE:
- if (writeHeader(obj, writer)) {
+ if (preWrite(writer, obj)) {
writer.rawWriter();
try {
((Externalizable)obj).writeExternal(writer);
- writer.postWrite(userType);
+ postWrite(writer, obj);
}
catch (IOException e) {
throw new BinaryObjectException("Failed to write Externalizable object: " + obj, e);
@@ -609,14 +609,14 @@ public class PortableClassDescriptor {
break;
case OBJECT:
- if (writeHeader(obj, writer)) {
+ if (preWrite(writer, obj)) {
try {
for (BinaryFieldAccessor info : fields)
info.write(obj, writer);
writer.schemaId(stableSchema.schemaId());
- writer.postWrite(userType);
+ postWrite(writer, obj);
}
finally {
writer.popSchema();
@@ -705,35 +705,32 @@ public class PortableClassDescriptor {
}
/**
- * @param obj Object.
+ * Pre-write phase.
+ *
* @param writer Writer.
+ * @param obj Object.
* @return Whether further write is needed.
*/
- private boolean writeHeader(Object obj, BinaryWriterExImpl writer) {
+ private boolean preWrite(BinaryWriterExImpl writer, Object obj) {
if (writer.tryWriteAsHandle(obj))
return false;
- if (registered) {
- PortableUtils.writeHeader(
- writer,
- typeId,
- obj instanceof CacheObjectImpl ? 0 : obj.hashCode(),
- null
- );
- }
- else {
- PortableUtils.writeHeader(
- writer,
- GridPortableMarshaller.UNREGISTERED_TYPE_ID,
- obj instanceof CacheObjectImpl ? 0 : obj.hashCode(),
- cls.getName()
- );
- }
+ writer.preWrite(registered ? null : cls.getName());
return true;
}
/**
+ * Post-write phase.
+ *
+ * @param writer Writer.
+ * @param obj Object.
+ */
+ private void postWrite(BinaryWriterExImpl writer, Object obj) {
+ writer.postWrite(userType, registered, obj instanceof CacheObjectImpl ? 0 : obj.hashCode());
+ }
+
+ /**
* @return Instance.
* @throws BinaryObjectException In case of error.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8332/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index 53d414c..6d155fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -17,14 +17,13 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.portable.builder.PortableLazyValue;
-import org.apache.ignite.internal.portable.streams.PortableOutputStream;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryObject;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -663,33 +662,6 @@ public class PortableUtils {
}
/**
- * Write portable header.
- *
- * @param writer Writer.
- * @param typeId Type ID.
- * @param hashCode Hash code.
- * @param clsName Class name (optional).
- * @return Position where length should be written.
- */
- public static int writeHeader(BinaryWriterExImpl writer, int typeId, int hashCode, @Nullable String clsName) {
- PortableOutputStream out = writer.out();
-
- out.unsafeEnsure(12);
- out.unsafeWriteByte(GridPortableMarshaller.OBJ);
- out.unsafeWriteByte(GridPortableMarshaller.PROTO_VER);
- out.unsafeWriteShort((short) 0);
- out.unsafeWriteInt(typeId);
- out.unsafeWriteInt(hashCode);
-
- int reserved = writer.reserve(12);
-
- if (clsName != null)
- writer.doWriteString(clsName);
-
- return reserved;
- }
-
- /**
* Get portable object length.
*
* @param in Input stream.
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8332/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
index 2ce2416..b2fb7d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
@@ -199,11 +199,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
*/
void serializeTo(BinaryWriterExImpl writer, PortableBuilderSerializer serializer) {
try {
- PortableUtils.writeHeader(writer,
- registeredType ? typeId : UNREGISTERED_TYPE_ID,
- hashCode,
- registeredType ? null : clsNameToWrite
- );
+ writer.preWrite(registeredType ? null : clsNameToWrite);
Set<Integer> remainsFlds = null;
@@ -363,7 +359,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
reader.position(start + PortableUtils.length(reader, start));
}
- writer.postWrite(true);
+ writer.postWrite(true, registeredType, hashCode);
// Update metadata if needed.
int schemaId = writer.schemaId();
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8332/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
index b68e9d1..7efc942 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractOutputStream.java
@@ -239,7 +239,7 @@ public abstract class PortableAbstractOutputStream extends PortableAbstractStrea
@Override public void position(int pos) {
ensureCapacity(pos);
- this.pos = pos;
+ unsafePosition(pos);
}
/** {@inheritDoc} */
@@ -253,6 +253,11 @@ public abstract class PortableAbstractOutputStream extends PortableAbstractStrea
}
/** {@inheritDoc} */
+ @Override public void unsafePosition(int pos) {
+ this.pos = pos;
+ }
+
+ /** {@inheritDoc} */
@Override public void unsafeWriteBoolean(boolean val) {
unsafeWriteByte(val ? BYTE_ONE : BYTE_ZERO);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8332/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
index 3a2e9e1..e516ff5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableOutputStream.java
@@ -172,6 +172,13 @@ public interface PortableOutputStream extends PortableStream, AutoCloseable {
@Override public void close();
/**
+ * Set position in unsafe mode.
+ *
+ * @param pos Position.
+ */
+ public void unsafePosition(int pos);
+
+ /**
* Ensure capacity for unsafe writes.
*
* @param cap Capacity.
http://git-wip-us.apache.org/repos/asf/ignite/blob/462f8332/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
index 670dd28..59d8981 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
@@ -186,7 +186,7 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
@Override public void position(int pos) {
ensureCapacity(pos);
- this.pos = pos;
+ unsafePosition(pos);
}
/** {@inheritDoc} */
@@ -228,6 +228,11 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
}
/** {@inheritDoc} */
+ @Override public void unsafePosition(int pos) {
+ this.pos = pos;
+ }
+
+ /** {@inheritDoc} */
@Override public void unsafeWriteByte(byte val) {
UNSAFE.putByte(data + pos++, val);
}
[19/55] [abbrv] ignite git commit: IGNITE-1816: Implemented compact
footers.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index 31f2bf9..95ef9591 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -98,16 +98,22 @@ public class PortableUtils {
private static final Collection<Class<?>> PORTABLE_CLS = new HashSet<>();
/** Flag: user type. */
- public static final short FLAG_USR_TYP = 0x1;
+ public static final short FLAG_USR_TYP = 0x0001;
/** Flag: only raw data exists. */
- public static final short FLAG_RAW_ONLY = 0x2;
+ public static final short FLAG_HAS_SCHEMA = 0x0002;
+
+ /** Flag indicating that object has raw data. */
+ public static final short FLAG_HAS_RAW = 0x0004;
/** Flag: offsets take 1 byte. */
- public static final short FLAG_OFFSET_ONE_BYTE = 0x4;
+ public static final short FLAG_OFFSET_ONE_BYTE = 0x0008;
/** Flag: offsets take 2 bytes. */
- public static final short FLAG_OFFSET_TWO_BYTES = 0x8;
+ public static final short FLAG_OFFSET_TWO_BYTES = 0x0010;
+
+ /** Flag: compact footer, no field IDs. */
+ public static final short FLAG_COMPACT_FOOTER = 0x0020;
/** Offset which fits into 1 byte. */
public static final int OFFSET_1 = 1;
@@ -118,10 +124,99 @@ public class PortableUtils {
/** Offset which fits into 4 bytes. */
public static final int OFFSET_4 = 4;
+ /** Field ID length. */
+ public static final int FIELD_ID_LEN = 4;
+
/** Field type names. */
private static final String[] FIELD_TYPE_NAMES;
+ /** FNV1 hash offset basis. */
+ private static final int FNV1_OFFSET_BASIS = 0x811C9DC5;
+
+ /** FNV1 hash prime. */
+ private static final int FNV1_PRIME = 0x01000193;
+
+ /**
+ * Static class initializer.
+ */
static {
+ PLAIN_CLASS_TO_FLAG.put(Byte.class, GridPortableMarshaller.BYTE);
+ PLAIN_CLASS_TO_FLAG.put(Short.class, GridPortableMarshaller.SHORT);
+ PLAIN_CLASS_TO_FLAG.put(Integer.class, GridPortableMarshaller.INT);
+ PLAIN_CLASS_TO_FLAG.put(Long.class, GridPortableMarshaller.LONG);
+ PLAIN_CLASS_TO_FLAG.put(Float.class, GridPortableMarshaller.FLOAT);
+ PLAIN_CLASS_TO_FLAG.put(Double.class, GridPortableMarshaller.DOUBLE);
+ PLAIN_CLASS_TO_FLAG.put(Character.class, GridPortableMarshaller.CHAR);
+ PLAIN_CLASS_TO_FLAG.put(Boolean.class, GridPortableMarshaller.BOOLEAN);
+ PLAIN_CLASS_TO_FLAG.put(BigDecimal.class, GridPortableMarshaller.DECIMAL);
+ PLAIN_CLASS_TO_FLAG.put(String.class, GridPortableMarshaller.STRING);
+ PLAIN_CLASS_TO_FLAG.put(UUID.class, GridPortableMarshaller.UUID);
+ PLAIN_CLASS_TO_FLAG.put(Date.class, GridPortableMarshaller.DATE);
+ PLAIN_CLASS_TO_FLAG.put(Timestamp.class, GridPortableMarshaller.TIMESTAMP);
+
+ PLAIN_CLASS_TO_FLAG.put(byte[].class, GridPortableMarshaller.BYTE_ARR);
+ PLAIN_CLASS_TO_FLAG.put(short[].class, GridPortableMarshaller.SHORT_ARR);
+ PLAIN_CLASS_TO_FLAG.put(int[].class, GridPortableMarshaller.INT_ARR);
+ PLAIN_CLASS_TO_FLAG.put(long[].class, GridPortableMarshaller.LONG_ARR);
+ PLAIN_CLASS_TO_FLAG.put(float[].class, GridPortableMarshaller.FLOAT_ARR);
+ PLAIN_CLASS_TO_FLAG.put(double[].class, GridPortableMarshaller.DOUBLE_ARR);
+ PLAIN_CLASS_TO_FLAG.put(char[].class, GridPortableMarshaller.CHAR_ARR);
+ PLAIN_CLASS_TO_FLAG.put(boolean[].class, GridPortableMarshaller.BOOLEAN_ARR);
+ PLAIN_CLASS_TO_FLAG.put(BigDecimal[].class, GridPortableMarshaller.DECIMAL_ARR);
+ PLAIN_CLASS_TO_FLAG.put(String[].class, GridPortableMarshaller.STRING_ARR);
+ PLAIN_CLASS_TO_FLAG.put(UUID[].class, GridPortableMarshaller.UUID_ARR);
+ PLAIN_CLASS_TO_FLAG.put(Date[].class, GridPortableMarshaller.DATE_ARR);
+ PLAIN_CLASS_TO_FLAG.put(Timestamp[].class, GridPortableMarshaller.TIMESTAMP_ARR);
+
+ for (Map.Entry<Class<?>, Byte> entry : PLAIN_CLASS_TO_FLAG.entrySet())
+ FLAG_TO_CLASS.put(entry.getValue(), entry.getKey());
+
+ PLAIN_CLASS_TO_FLAG.put(byte.class, GridPortableMarshaller.BYTE);
+ PLAIN_CLASS_TO_FLAG.put(short.class, GridPortableMarshaller.SHORT);
+ PLAIN_CLASS_TO_FLAG.put(int.class, GridPortableMarshaller.INT);
+ PLAIN_CLASS_TO_FLAG.put(long.class, GridPortableMarshaller.LONG);
+ PLAIN_CLASS_TO_FLAG.put(float.class, GridPortableMarshaller.FLOAT);
+ PLAIN_CLASS_TO_FLAG.put(double.class, GridPortableMarshaller.DOUBLE);
+ PLAIN_CLASS_TO_FLAG.put(char.class, GridPortableMarshaller.CHAR);
+ PLAIN_CLASS_TO_FLAG.put(boolean.class, GridPortableMarshaller.BOOLEAN);
+
+ for (byte b : new byte[] {
+ BYTE, SHORT, INT, LONG, FLOAT, DOUBLE,
+ CHAR, BOOLEAN, DECIMAL, STRING, UUID, DATE, TIMESTAMP,
+ BYTE_ARR, SHORT_ARR, INT_ARR, LONG_ARR, FLOAT_ARR, DOUBLE_ARR,
+ CHAR_ARR, BOOLEAN_ARR, DECIMAL_ARR, STRING_ARR, UUID_ARR, DATE_ARR, TIMESTAMP_ARR,
+ ENUM, ENUM_ARR, NULL}) {
+
+ PLAIN_TYPE_FLAG[b] = true;
+ }
+
+ PORTABLE_CLS.add(Byte.class);
+ PORTABLE_CLS.add(Short.class);
+ PORTABLE_CLS.add(Integer.class);
+ PORTABLE_CLS.add(Long.class);
+ PORTABLE_CLS.add(Float.class);
+ PORTABLE_CLS.add(Double.class);
+ PORTABLE_CLS.add(Character.class);
+ PORTABLE_CLS.add(Boolean.class);
+ PORTABLE_CLS.add(String.class);
+ PORTABLE_CLS.add(UUID.class);
+ PORTABLE_CLS.add(Date.class);
+ PORTABLE_CLS.add(Timestamp.class);
+ PORTABLE_CLS.add(BigDecimal.class);
+ PORTABLE_CLS.add(byte[].class);
+ PORTABLE_CLS.add(short[].class);
+ PORTABLE_CLS.add(int[].class);
+ PORTABLE_CLS.add(long[].class);
+ PORTABLE_CLS.add(float[].class);
+ PORTABLE_CLS.add(double[].class);
+ PORTABLE_CLS.add(char[].class);
+ PORTABLE_CLS.add(boolean[].class);
+ PORTABLE_CLS.add(String[].class);
+ PORTABLE_CLS.add(UUID[].class);
+ PORTABLE_CLS.add(Date[].class);
+ PORTABLE_CLS.add(Timestamp[].class);
+ PORTABLE_CLS.add(BigDecimal[].class);
+
FIELD_TYPE_NAMES = new String[104];
FIELD_TYPE_NAMES[BYTE] = "byte";
@@ -162,168 +257,113 @@ public class PortableUtils {
}
/**
- * @param typeName Field type name.
- * @return Field type ID;
+ * Check if user type flag is set.
+ *
+ * @param flags Flags.
+ * @return {@code True} if set.
*/
- @SuppressWarnings("StringEquality")
- public static int fieldTypeId(String typeName) {
- for (int i = 0; i < FIELD_TYPE_NAMES.length; i++) {
- String typeName0 = FIELD_TYPE_NAMES[i];
-
- if (typeName.equals(typeName0))
- return i;
- }
-
- throw new IllegalArgumentException("Invalid metadata type name: " + typeName);
+ public static boolean isUserType(short flags) {
+ return isFlagSet(flags, FLAG_USR_TYP);
}
/**
- * @param typeId Field type ID.
- * @return Field type name.
+ * Check if raw-only flag is set.
+ *
+ * @param flags Flags.
+ * @return {@code True} if set.
*/
- public static String fieldTypeName(int typeId) {
- assert typeId >= 0 && typeId < FIELD_TYPE_NAMES.length : typeId;
-
- String typeName = FIELD_TYPE_NAMES[typeId];
-
- assert typeName != null : typeId;
-
- return typeName;
+ public static boolean hasSchema(short flags) {
+ return isFlagSet(flags, FLAG_HAS_SCHEMA);
}
/**
- * @param typeIds Field type IDs.
- * @return Field type names.
+ * Check if raw-only flag is set.
+ *
+ * @param flags Flags.
+ * @return {@code True} if set.
*/
- public static Map<String, String> fieldTypeNames(Map<String, Integer> typeIds) {
- Map<String, String> names = U.newHashMap(typeIds.size());
-
- for (Map.Entry<String, Integer> e : typeIds.entrySet())
- names.put(e.getKey(), fieldTypeName(e.getValue()));
-
- return names;
+ public static boolean hasRaw(short flags) {
+ return isFlagSet(flags, FLAG_HAS_RAW);
}
/**
- * Write flags.
+ * Check if "no-field-ids" flag is set.
*
- * @param writer Writer.
- * @param userType User type flag.
+ * @param flags Flags.
+ * @return {@code True} if set.
*/
- public static void writeFlags(BinaryWriterExImpl writer, boolean userType) {
- short val = 0;
-
- if (userType)
- val |= FLAG_USR_TYP;
-
- writer.doWriteShort(val);
+ public static boolean isCompactFooter(short flags) {
+ return isFlagSet(flags, FLAG_COMPACT_FOOTER);
}
/**
- * Check if user type flag is set.
+ * Check whether particular flag is set.
*
* @param flags Flags.
- * @return {@code True} if set.
+ * @param flag Flag.
+ * @return {@code True} if flag is set in flags.
*/
- public static boolean isUserType(short flags) {
- return (flags & FLAG_USR_TYP) == FLAG_USR_TYP;
+ private static boolean isFlagSet(short flags, short flag) {
+ return (flags & flag) == flag;
}
-
+
/**
- * Check if raw-only flag is set.
+ * Schema initial ID.
*
- * @param flags Flags.
- * @return {@code True} if set.
+ * @return ID.
*/
- public static boolean isRawOnly(short flags) {
- return (flags & FLAG_RAW_ONLY) == FLAG_RAW_ONLY;
+ public static int schemaInitialId() {
+ return FNV1_OFFSET_BASIS;
}
/**
+ * Update schema ID when new field is added.
*
+ * @param schemaId Current schema ID.
+ * @param fieldId Field ID.
+ * @return New schema ID.
*/
- static {
- PORTABLE_CLS.add(Byte.class);
- PORTABLE_CLS.add(Short.class);
- PORTABLE_CLS.add(Integer.class);
- PORTABLE_CLS.add(Long.class);
- PORTABLE_CLS.add(Float.class);
- PORTABLE_CLS.add(Double.class);
- PORTABLE_CLS.add(Character.class);
- PORTABLE_CLS.add(Boolean.class);
- PORTABLE_CLS.add(String.class);
- PORTABLE_CLS.add(UUID.class);
- PORTABLE_CLS.add(Date.class);
- PORTABLE_CLS.add(Timestamp.class);
- PORTABLE_CLS.add(BigDecimal.class);
- PORTABLE_CLS.add(byte[].class);
- PORTABLE_CLS.add(short[].class);
- PORTABLE_CLS.add(int[].class);
- PORTABLE_CLS.add(long[].class);
- PORTABLE_CLS.add(float[].class);
- PORTABLE_CLS.add(double[].class);
- PORTABLE_CLS.add(char[].class);
- PORTABLE_CLS.add(boolean[].class);
- PORTABLE_CLS.add(String[].class);
- PORTABLE_CLS.add(UUID[].class);
- PORTABLE_CLS.add(Date[].class);
- PORTABLE_CLS.add(Timestamp[].class);
- PORTABLE_CLS.add(BigDecimal[].class);
+ public static int updateSchemaId(int schemaId, int fieldId) {
+ schemaId = schemaId ^ (fieldId & 0xFF);
+ schemaId = schemaId * FNV1_PRIME;
+ schemaId = schemaId ^ ((fieldId >> 8) & 0xFF);
+ schemaId = schemaId * FNV1_PRIME;
+ schemaId = schemaId ^ ((fieldId >> 16) & 0xFF);
+ schemaId = schemaId * FNV1_PRIME;
+ schemaId = schemaId ^ ((fieldId >> 24) & 0xFF);
+ schemaId = schemaId * FNV1_PRIME;
+
+ return schemaId;
}
/**
- *
+ * @param typeName Field type name.
+ * @return Field type ID;
*/
- static {
- PLAIN_CLASS_TO_FLAG.put(Byte.class, GridPortableMarshaller.BYTE);
- PLAIN_CLASS_TO_FLAG.put(Short.class, GridPortableMarshaller.SHORT);
- PLAIN_CLASS_TO_FLAG.put(Integer.class, GridPortableMarshaller.INT);
- PLAIN_CLASS_TO_FLAG.put(Long.class, GridPortableMarshaller.LONG);
- PLAIN_CLASS_TO_FLAG.put(Float.class, GridPortableMarshaller.FLOAT);
- PLAIN_CLASS_TO_FLAG.put(Double.class, GridPortableMarshaller.DOUBLE);
- PLAIN_CLASS_TO_FLAG.put(Character.class, GridPortableMarshaller.CHAR);
- PLAIN_CLASS_TO_FLAG.put(Boolean.class, GridPortableMarshaller.BOOLEAN);
- PLAIN_CLASS_TO_FLAG.put(BigDecimal.class, GridPortableMarshaller.DECIMAL);
- PLAIN_CLASS_TO_FLAG.put(String.class, GridPortableMarshaller.STRING);
- PLAIN_CLASS_TO_FLAG.put(UUID.class, GridPortableMarshaller.UUID);
- PLAIN_CLASS_TO_FLAG.put(Date.class, GridPortableMarshaller.DATE);
- PLAIN_CLASS_TO_FLAG.put(Timestamp.class, GridPortableMarshaller.TIMESTAMP);
+ @SuppressWarnings("StringEquality")
+ public static int fieldTypeId(String typeName) {
+ for (int i = 0; i < FIELD_TYPE_NAMES.length; i++) {
+ String typeName0 = FIELD_TYPE_NAMES[i];
- PLAIN_CLASS_TO_FLAG.put(byte[].class, GridPortableMarshaller.BYTE_ARR);
- PLAIN_CLASS_TO_FLAG.put(short[].class, GridPortableMarshaller.SHORT_ARR);
- PLAIN_CLASS_TO_FLAG.put(int[].class, GridPortableMarshaller.INT_ARR);
- PLAIN_CLASS_TO_FLAG.put(long[].class, GridPortableMarshaller.LONG_ARR);
- PLAIN_CLASS_TO_FLAG.put(float[].class, GridPortableMarshaller.FLOAT_ARR);
- PLAIN_CLASS_TO_FLAG.put(double[].class, GridPortableMarshaller.DOUBLE_ARR);
- PLAIN_CLASS_TO_FLAG.put(char[].class, GridPortableMarshaller.CHAR_ARR);
- PLAIN_CLASS_TO_FLAG.put(boolean[].class, GridPortableMarshaller.BOOLEAN_ARR);
- PLAIN_CLASS_TO_FLAG.put(BigDecimal[].class, GridPortableMarshaller.DECIMAL_ARR);
- PLAIN_CLASS_TO_FLAG.put(String[].class, GridPortableMarshaller.STRING_ARR);
- PLAIN_CLASS_TO_FLAG.put(UUID[].class, GridPortableMarshaller.UUID_ARR);
- PLAIN_CLASS_TO_FLAG.put(Date[].class, GridPortableMarshaller.DATE_ARR);
- PLAIN_CLASS_TO_FLAG.put(Timestamp[].class, GridPortableMarshaller.TIMESTAMP_ARR);
+ if (typeName.equals(typeName0))
+ return i;
+ }
- for (Map.Entry<Class<?>, Byte> entry : PLAIN_CLASS_TO_FLAG.entrySet())
- FLAG_TO_CLASS.put(entry.getValue(), entry.getKey());
+ throw new IllegalArgumentException("Invalid metadata type name: " + typeName);
+ }
- PLAIN_CLASS_TO_FLAG.put(byte.class, GridPortableMarshaller.BYTE);
- PLAIN_CLASS_TO_FLAG.put(short.class, GridPortableMarshaller.SHORT);
- PLAIN_CLASS_TO_FLAG.put(int.class, GridPortableMarshaller.INT);
- PLAIN_CLASS_TO_FLAG.put(long.class, GridPortableMarshaller.LONG);
- PLAIN_CLASS_TO_FLAG.put(float.class, GridPortableMarshaller.FLOAT);
- PLAIN_CLASS_TO_FLAG.put(double.class, GridPortableMarshaller.DOUBLE);
- PLAIN_CLASS_TO_FLAG.put(char.class, GridPortableMarshaller.CHAR);
- PLAIN_CLASS_TO_FLAG.put(boolean.class, GridPortableMarshaller.BOOLEAN);
+ /**
+ * @param typeId Field type ID.
+ * @return Field type name.
+ */
+ public static String fieldTypeName(int typeId) {
+ assert typeId >= 0 && typeId < FIELD_TYPE_NAMES.length : typeId;
- for (byte b : new byte[] {
- BYTE, SHORT, INT, LONG, FLOAT, DOUBLE,
- CHAR, BOOLEAN, DECIMAL, STRING, UUID, DATE, TIMESTAMP,
- BYTE_ARR, SHORT_ARR, INT_ARR, LONG_ARR, FLOAT_ARR, DOUBLE_ARR,
- CHAR_ARR, BOOLEAN_ARR, DECIMAL_ARR, STRING_ARR, UUID_ARR, DATE_ARR, TIMESTAMP_ARR,
- ENUM, ENUM_ARR, NULL}) {
+ String typeName = FIELD_TYPE_NAMES[typeId];
- PLAIN_TYPE_FLAG[b] = true;
- }
+ assert typeName != null : typeId;
+
+ return typeName;
}
/**
@@ -623,18 +663,16 @@ public class PortableUtils {
* Write portable header.
*
* @param writer Writer.
- * @param usrTyp User type flag.
* @param typeId Type ID.
* @param hashCode Hash code.
* @param clsName Class name (optional).
* @return Position where length should be written.
*/
- public static int writeHeader(BinaryWriterExImpl writer, boolean usrTyp, int typeId, int hashCode,
- @Nullable String clsName) {
+ public static int writeHeader(BinaryWriterExImpl writer, int typeId, int hashCode, @Nullable String clsName) {
writer.doWriteByte(GridPortableMarshaller.OBJ);
writer.doWriteByte(GridPortableMarshaller.PROTO_VER);
- PortableUtils.writeFlags(writer, usrTyp);
+ writer.doWriteShort((short) 0);
writer.doWriteInt(typeId);
writer.doWriteInt(hashCode);
@@ -668,12 +706,12 @@ public class PortableUtils {
public static int footerStartRelative(PortablePositionReadable in, int start) {
short flags = in.readShortPositioned(start + GridPortableMarshaller.FLAGS_POS);
- if (PortableUtils.isRawOnly(flags))
- // No schema, footer start equals to object end.
- return length(in, start);
- else
+ if (hasSchema(flags))
// Schema exists, use offset.
return in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
+ else
+ // No schema, footer start equals to object end.
+ return length(in, start);
}
/**
@@ -692,56 +730,73 @@ public class PortableUtils {
*
* @param in Input stream.
* @param start Start position.
- * @param fieldOffsetSize Field offset size.
* @return Footer.
*/
- public static IgniteBiTuple<Integer, Integer> footerAbsolute(PortablePositionReadable in, int start,
- int fieldOffsetSize) {
- int footerStart = footerStartRelative(in, start);
+ public static IgniteBiTuple<Integer, Integer> footerAbsolute(PortablePositionReadable in, int start) {
+ short flags = in.readShortPositioned(start + GridPortableMarshaller.FLAGS_POS);
+
int footerEnd = length(in, start);
- // Take in count possible raw offset.
- if ((footerEnd - footerStart) % (4 + fieldOffsetSize) != 0)
- footerEnd -= 4;
+ if (hasSchema(flags)) {
+ // Schema exists.
+ int footerStart = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
+
+ if (hasRaw(flags))
+ footerEnd -= 4;
- return F.t(start + footerStart, start + footerEnd);
+ assert footerStart <= footerEnd;
+
+ return F.t(start + footerStart, start + footerEnd);
+ }
+ else
+ // No schema.
+ return F.t(start + footerEnd, start + footerEnd);
}
/**
- * Get raw offset of the object.
+ * Get relative raw offset of the object.
*
* @param in Input stream.
* @param start Object start position inside the stream.
- * @param fieldOffsetSize Field offset size.
* @return Raw offset.
*/
- public static int rawOffsetAbsolute(PortablePositionReadable in, int start, int fieldOffsetSize) {
- int len = length(in, start);
-
+ public static int rawOffsetRelative(PortablePositionReadable in, int start) {
short flags = in.readShortPositioned(start + GridPortableMarshaller.FLAGS_POS);
- if (PortableUtils.isRawOnly(flags))
- // No schema, raw offset is located on schema offset position.
- return start + in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
- else {
- // Schema exists.
- int schemaOff = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
+ int len = length(in, start);
- if (((len - schemaOff) % (4 + fieldOffsetSize)) == 0x0)
- // Even amount of records in schema => no raw offset.
- return start + schemaOff;
+ if (hasSchema(flags)){
+ // Schema exists.
+ if (hasRaw(flags))
+ // Raw offset is set, it is at the very end of the object.
+ return in.readIntPositioned(start + len - 4);
else
- // Odd amount of records in schema => raw offset is the very last 4 bytes in object.
- return start + in.readIntPositioned(start + len - 4);
+ // Raw offset is not set, so just return schema offset.
+ return in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
}
+ else
+ // No schema, raw offset is located on schema offset position.
+ return in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
+ }
+
+ /**
+ * Get absolute raw offset of the object.
+ *
+ * @param in Input stream.
+ * @param start Object start position inside the stream.
+ * @return Raw offset.
+ */
+ public static int rawOffsetAbsolute(PortablePositionReadable in, int start) {
+ return start + rawOffsetRelative(in, start);
}
/**
- * Get offset size for the given flags.
+ * Get offset length for the given flags.
+ *
* @param flags Flags.
* @return Offset size.
*/
- public static int fieldOffsetSize(short flags) {
+ public static int fieldOffsetLength(short flags) {
if ((flags & FLAG_OFFSET_ONE_BYTE) == FLAG_OFFSET_ONE_BYTE)
return OFFSET_1;
else if ((flags & FLAG_OFFSET_TWO_BYTES) == FLAG_OFFSET_TWO_BYTES)
@@ -751,6 +806,16 @@ public class PortableUtils {
}
/**
+ * Get field ID length.
+ *
+ * @param flags Flags.
+ * @return Field ID length.
+ */
+ public static int fieldIdLength(short flags) {
+ return isCompactFooter(flags) ? 0 : FIELD_ID_LEN;
+ }
+
+ /**
* Get relative field offset.
*
* @param stream Stream.
@@ -770,4 +835,72 @@ public class PortableUtils {
return res;
}
+
+ /**
+ * Merge old and new metas.
+ *
+ * @param oldMeta Old meta.
+ * @param newMeta New meta.
+ * @return New meta if old meta was null, old meta if no changes detected, merged meta otherwise.
+ * @throws BinaryObjectException If merge failed due to metadata conflict.
+ */
+ public static BinaryMetadata mergeMetadata(@Nullable BinaryMetadata oldMeta, BinaryMetadata newMeta) {
+ assert newMeta != null;
+
+ if (oldMeta == null)
+ return newMeta;
+ else {
+ assert oldMeta.typeId() == newMeta.typeId();
+
+ // Check type name.
+ if (!F.eq(oldMeta.typeName(), newMeta.typeName())) {
+ throw new BinaryObjectException(
+ "Two portable types have duplicate type ID [" + "typeId=" + oldMeta.typeId() +
+ ", typeName1=" + oldMeta.typeName() + ", typeName2=" + newMeta.typeName() + ']'
+ );
+ }
+
+ // Check affinity field names.
+ if (!F.eq(oldMeta.affinityKeyFieldName(), newMeta.affinityKeyFieldName())) {
+ throw new BinaryObjectException(
+ "Binary type has different affinity key fields [" + "typeName=" + newMeta.typeName() +
+ ", affKeyFieldName1=" + oldMeta.affinityKeyFieldName() +
+ ", affKeyFieldName2=" + newMeta.affinityKeyFieldName() + ']'
+ );
+ }
+
+ // Check and merge fields.
+ boolean changed = false;
+
+ Map<String, Integer> mergedFields = new HashMap<>(oldMeta.fieldsMap());
+ Map<String, Integer> newFields = newMeta.fieldsMap();
+
+ for (Map.Entry<String, Integer> newField : newFields.entrySet()) {
+ Integer oldFieldType = mergedFields.put(newField.getKey(), newField.getValue());
+
+ if (oldFieldType == null)
+ changed = true;
+ else if (!F.eq(oldFieldType, newField.getValue())) {
+ throw new BinaryObjectException(
+ "Binary type has different field types [" + "typeName=" + oldMeta.typeName() +
+ ", fieldName=" + newField.getKey() +
+ ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldType) +
+ ", fieldTypeName2=" + PortableUtils.fieldTypeName(newField.getValue()) + ']'
+ );
+ }
+ }
+
+ // Check and merge schemas.
+ Collection<PortableSchema> mergedSchemas = new HashSet<>(oldMeta.schemas());
+
+ for (PortableSchema newSchema : newMeta.schemas()) {
+ if (mergedSchemas.add(newSchema))
+ changed = true;
+ }
+
+ // Return either old meta if no changes detected, or new merged meta.
+ return changed ? new BinaryMetadata(oldMeta.typeId(), oldMeta.typeName(), mergedFields,
+ oldMeta.affinityKeyFieldName(), mergedSchemas) : oldMeta;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
index ca8f09b..dfc2330 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
@@ -22,11 +22,14 @@ import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.internal.portable.BinaryMetadata;
import org.apache.ignite.internal.portable.BinaryObjectImpl;
import org.apache.ignite.internal.portable.BinaryObjectOffheapImpl;
import org.apache.ignite.internal.portable.BinaryWriterExImpl;
import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
+import org.apache.ignite.internal.portable.PortableSchema;
+import org.apache.ignite.internal.portable.PortableSchemaRegistry;
import org.apache.ignite.internal.portable.PortableUtils;
import org.apache.ignite.internal.util.GridArgumentCheck;
import org.apache.ignite.internal.util.typedef.F;
@@ -176,7 +179,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
/** {@inheritDoc} */
@Override public BinaryObject build() {
try (BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, typeId, false)) {
-
PortableBuilderSerializer serializationCtx = new PortableBuilderSerializer();
serializationCtx.registerObjectWriting(this, 0);
@@ -196,50 +198,57 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
void serializeTo(BinaryWriterExImpl writer, PortableBuilderSerializer serializer) {
try {
PortableUtils.writeHeader(writer,
- true,
registeredType ? typeId : UNREGISTERED_TYPE_ID,
hashCode,
- registeredType ? null : clsNameToWrite);
+ registeredType ? null : clsNameToWrite
+ );
Set<Integer> remainsFlds = null;
if (reader != null) {
+ PortableSchema schema = reader.schema(start);
+
Map<Integer, Object> assignedFldsById;
if (assignedVals != null) {
assignedFldsById = U.newHashMap(assignedVals.size());
for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
- int fldId = ctx.fieldId(typeId, entry.getKey());
+ int fieldId = ctx.fieldId(typeId, entry.getKey());
- assignedFldsById.put(fldId, entry.getValue());
+ assignedFldsById.put(fieldId, entry.getValue());
}
remainsFlds = assignedFldsById.keySet();
- } else
+ }
+ else
assignedFldsById = Collections.emptyMap();
// Get footer details.
- int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
+ int fieldIdLen = PortableUtils.fieldIdLength(flags);
+ int fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
- IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader, start, fieldOffsetSize);
+ IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader, start);
int footerPos = footer.get1();
int footerEnd = footer.get2();
// Get raw position.
- int rawPos = PortableUtils.rawOffsetAbsolute(reader, start, fieldOffsetSize);
+ int rawPos = PortableUtils.rawOffsetAbsolute(reader, start);
// Position reader on data.
reader.position(start + hdrLen);
- while (reader.position() + 4 < rawPos) {
- int fieldId = reader.readIntPositioned(footerPos);
- int fieldLen = fieldPositionAndLength(footerPos, footerEnd, rawPos, fieldOffsetSize).get2();
+ int idx = 0;
+
+ while (reader.position() < rawPos) {
+ int fieldId = schema.fieldId(idx++);
+ int fieldLen =
+ fieldPositionAndLength(footerPos, footerEnd, rawPos, fieldIdLen, fieldOffsetLen).get2();
int postPos = reader.position() + fieldLen; // Position where reader will be placed afterwards.
- footerPos += 4 + fieldOffsetSize;
+ footerPos += fieldIdLen + fieldOffsetLen;
if (assignedFldsById.containsKey(fieldId)) {
Object assignedVal = assignedFldsById.remove(fieldId);
@@ -281,11 +290,11 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
}
- if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
- BinaryType metadata = ctx.metaData(typeId);
+ BinaryType meta = ctx.metadata(typeId);
- Map<String, Integer> newFldsMetadata = null;
+ Map<String, Integer> fieldsMeta = null;
+ if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
Object val = entry.getValue();
@@ -294,16 +303,16 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
String name = entry.getKey();
- int fldId = ctx.fieldId(typeId, name);
+ int fieldId = ctx.fieldId(typeId, name);
- if (remainsFlds != null && !remainsFlds.contains(fldId))
+ if (remainsFlds != null && !remainsFlds.contains(fieldId))
continue;
- writer.writeFieldId(fldId);
+ writer.writeFieldId(fieldId);
serializer.writeValue(writer, val);
- String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name);
+ String oldFldTypeName = meta == null ? null : meta.fieldTypeName(name);
int newFldTypeId;
@@ -316,11 +325,10 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
if (oldFldTypeName == null) {
// It's a new field, we have to add it to metadata.
+ if (fieldsMeta == null)
+ fieldsMeta = new HashMap<>();
- if (newFldsMetadata == null)
- newFldsMetadata = new HashMap<>();
-
- newFldsMetadata.put(name, PortableUtils.fieldTypeId(newFldTypeName));
+ fieldsMeta.put(name, PortableUtils.fieldTypeId(newFldTypeName));
}
else {
String objTypeName = PortableUtils.fieldTypeName(GridPortableMarshaller.OBJ);
@@ -328,7 +336,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
if (!objTypeName.equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
throw new BinaryObjectException(
"Wrong value has been set [" +
- "typeName=" + (typeName == null ? metadata.typeName() : typeName) +
+ "typeName=" + (typeName == null ? meta.typeName() : typeName) +
", fieldName=" + name +
", fieldType=" + oldFldTypeName +
", assignedValueType=" + newFldTypeName + ']'
@@ -336,25 +344,11 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
}
}
-
- if (newFldsMetadata != null) {
- String typeName = this.typeName;
-
- if (typeName == null) {
- assert metadata != null;
-
- typeName = metadata.typeName();
- }
-
- ctx.updateMetaData(typeId, typeName, newFldsMetadata);
- }
}
if (reader != null) {
// Write raw data if any.
- int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
-
- int rawOff = PortableUtils.rawOffsetAbsolute(reader, start, fieldOffsetSize);
+ int rawOff = PortableUtils.rawOffsetAbsolute(reader, start);
int footerStart = PortableUtils.footerStartAbsolute(reader, start);
if (rawOff < footerStart) {
@@ -368,6 +362,28 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
writer.postWrite(true);
+
+ // Update metadata if needed.
+ int schemaId = writer.schemaId();
+
+ PortableSchemaRegistry schemaReg = ctx.schemaRegistry(typeId);
+
+ if (schemaReg.schema(schemaId) == null) {
+ String typeName = this.typeName;
+
+ if (typeName == null) {
+ assert meta != null;
+
+ typeName = meta.typeName();
+ }
+
+ PortableSchema curSchema = writer.currentSchema();
+
+ ctx.updateMetadata(typeId, new BinaryMetadata(typeId, typeName, fieldsMeta,
+ ctx.affinityKeyFieldName(typeId), Collections.singleton(curSchema)));
+
+ schemaReg.addSchema(curSchema.schemaId(), curSchema);
+ }
}
finally {
writer.popSchema();
@@ -387,25 +403,26 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
* @param footerPos Field position inside the footer (absolute).
* @param footerEnd Footer end (absolute).
* @param rawPos Raw data position (absolute).
- * @param fieldOffsetSize Size of field's offset.
+ * @param fieldIdLen Field ID length.
+ * @param fieldOffsetLen Field offset length.
* @return Tuple with field position and length.
*/
private IgniteBiTuple<Integer, Integer> fieldPositionAndLength(int footerPos, int footerEnd, int rawPos,
- int fieldOffsetSize) {
+ int fieldIdLen, int fieldOffsetLen) {
// Get field offset first.
- int fieldOffset = PortableUtils.fieldOffsetRelative(reader, footerPos + 4, fieldOffsetSize);
+ int fieldOffset = PortableUtils.fieldOffsetRelative(reader, footerPos + fieldIdLen, fieldOffsetLen);
int fieldPos = start + fieldOffset;
// Get field length.
int fieldLen;
- if (footerPos + 4 + fieldOffsetSize == footerEnd)
+ if (footerPos + fieldIdLen + fieldOffsetLen == footerEnd)
// This is the last field, compare to raw offset.
fieldLen = rawPos - fieldPos;
else {
// Field is somewhere in the middle, get difference with the next offset.
- int nextFieldOffset = PortableUtils.fieldOffsetRelative(reader, footerPos + 4 + fieldOffsetSize + 4,
- fieldOffsetSize);
+ int nextFieldOffset = PortableUtils.fieldOffsetRelative(reader,
+ footerPos + fieldIdLen + fieldOffsetLen + fieldIdLen, fieldOffsetLen);
fieldLen = nextFieldOffset - fieldOffset;
}
@@ -417,30 +434,37 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
* Initialize read cache if needed.
*/
private void ensureReadCacheInit() {
+ assert reader != null;
+
if (readCache == null) {
- int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
+ int fieldIdLen = PortableUtils.fieldIdLength(flags);
+ int fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
+
+ PortableSchema schema = reader.schema(start);
Map<Integer, Object> readCache = new HashMap<>();
- IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader, start, fieldOffsetSize);
+ IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader, start);
int footerPos = footer.get1();
int footerEnd = footer.get2();
- int rawPos = PortableUtils.rawOffsetAbsolute(reader, start, fieldOffsetSize);
+ int rawPos = PortableUtils.rawOffsetAbsolute(reader, start);
+
+ int idx = 0;
- while (footerPos + 4 < footerEnd) {
- int fieldId = reader.readIntPositioned(footerPos);
+ while (footerPos + fieldIdLen < footerEnd) {
+ int fieldId = schema.fieldId(idx++);
IgniteBiTuple<Integer, Integer> posAndLen =
- fieldPositionAndLength(footerPos, footerEnd, rawPos, fieldOffsetSize);
+ fieldPositionAndLength(footerPos, footerEnd, rawPos, fieldIdLen, fieldOffsetLen);
Object val = reader.getValueQuickly(posAndLen.get1(), posAndLen.get2());
readCache.put(fieldId, val);
// Shift current footer position.
- footerPos += 4 + fieldOffsetSize;
+ footerPos += fieldIdLen + fieldOffsetLen;
}
this.readCache = readCache;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
index 5c6a131..b6a6b54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -27,6 +27,7 @@ import org.apache.ignite.internal.portable.PortablePositionReadable;
import org.apache.ignite.internal.portable.BinaryObjectImpl;
import org.apache.ignite.internal.portable.PortablePrimitives;
import org.apache.ignite.internal.portable.BinaryReaderExImpl;
+import org.apache.ignite.internal.portable.PortableSchema;
import org.apache.ignite.internal.portable.PortableUtils;
import org.apache.ignite.internal.portable.BinaryWriterExImpl;
import org.apache.ignite.binary.BinaryObjectException;
@@ -63,7 +64,7 @@ public class PortableBuilderReader implements PortablePositionReadable {
pos = objImpl.start();
// TODO: IGNITE-1272 - Is class loader needed here?
- reader = new BinaryReaderExImpl(portableContext(), arr, pos, null);
+ reader = new BinaryReaderExImpl(ctx, arr, pos, null);
}
/**
@@ -81,6 +82,24 @@ public class PortableBuilderReader implements PortablePositionReadable {
}
/**
+ * Get schema of the object, starting at the given position.
+ *
+ * @param start Start position.
+ * @return Object's schema.
+ */
+ public PortableSchema schema(int start) {
+ // We can use current reader in case start is equal to initially recorded position.
+ BinaryReaderExImpl targetReader;
+
+ if (start == pos)
+ targetReader = reader;
+ else
+ targetReader = new BinaryReaderExImpl(ctx, arr, start, null);
+
+ return targetReader.getOrCreateSchema();
+ }
+
+ /**
* @return Read int value.
*/
public int readInt() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
index cac0dcf..e4db77c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessor.java
@@ -59,7 +59,7 @@ public interface CacheObjectBinaryProcessor extends IgniteCacheObjectProcessor {
* @param fieldTypeIds Fields map.
* @throws IgniteException In case of error.
*/
- public void updateMetaData(int typeId, String typeName, @Nullable String affKeyFieldName,
+ public void updateMetadata(int typeId, String typeName, @Nullable String affKeyFieldName,
Map<String, Integer> fieldTypeIds) throws IgniteException;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
index 117eece..551ada5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
@@ -31,12 +31,12 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.portable.BinaryMetadata;
+import org.apache.ignite.internal.portable.BinaryMetadataHandler;
import org.apache.ignite.internal.portable.BinaryObjectImpl;
import org.apache.ignite.internal.portable.BinaryObjectOffheapImpl;
import org.apache.ignite.internal.portable.BinaryTypeImpl;
import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
-import org.apache.ignite.internal.portable.BinaryMetadataHandler;
import org.apache.ignite.internal.portable.PortableUtils;
import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.portable.streams.PortableInputStream;
@@ -88,7 +88,6 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -168,17 +167,14 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (metaDataCache == null) {
BinaryMetadata oldMeta = metaBuf.get(typeId);
+ BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta0);
- if (oldMeta == null || checkMeta(typeId, oldMeta, newMeta0, null)) {
+ if (oldMeta != mergedMeta) {
synchronized (this) {
- Map<String, Integer> fields = new HashMap<>();
-
- if (checkMeta(typeId, oldMeta, newMeta0, fields)) {
- newMeta0 = new BinaryMetadata(typeId, newMeta0.typeName(), fields,
- newMeta0.affinityKeyFieldName());
+ mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta0);
- metaBuf.put(typeId, newMeta0);
- }
+ if (oldMeta != mergedMeta)
+ metaBuf.put(typeId, mergedMeta);
else
return;
}
@@ -192,6 +188,8 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
return;
}
+ assert metaDataCache != null;
+
CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta0.wrap(portableCtx));
}
@@ -297,24 +295,22 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private void addClientCacheMetaData(PortableMetadataKey key, final BinaryMetadata newMeta) {
int key0 = key.typeId();
- clientMetaDataCache.compute(key0,
- new ConcurrentHashMap8.BiFun<Integer, BinaryTypeImpl, BinaryTypeImpl>() {
- @Override public BinaryTypeImpl apply(Integer key, BinaryTypeImpl oldMeta) {
- BinaryMetadata res;
+ clientMetaDataCache.compute(key0, new ConcurrentHashMap8.BiFun<Integer, BinaryTypeImpl, BinaryTypeImpl>() {
+ @Override public BinaryTypeImpl apply(Integer key, BinaryTypeImpl oldMeta) {
+ BinaryMetadata res;
- BinaryMetadata oldMeta0 = oldMeta != null ? oldMeta.metadata() : null;
+ BinaryMetadata oldMeta0 = oldMeta != null ? oldMeta.metadata() : null;
- try {
- res = checkMeta(key, oldMeta0, newMeta, null) ? newMeta : oldMeta0;
- }
- catch (BinaryObjectException e) {
- res = oldMeta0;
- }
-
- return res != null ? res.wrap(portableCtx) : null;
+ try {
+ res = PortableUtils.mergeMetadata(oldMeta0, newMeta);
+ }
+ catch (BinaryObjectException e) {
+ res = oldMeta0;
}
+
+ return res != null ? res.wrap(portableCtx) : null;
}
- );
+ });
}
/** {@inheritDoc} */
@@ -448,9 +444,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/** {@inheritDoc} */
- @Override public void updateMetaData(int typeId, String typeName, @Nullable String affKeyFieldName,
+ @Override public void updateMetadata(int typeId, String typeName, @Nullable String affKeyFieldName,
Map<String, Integer> fieldTypeIds) throws BinaryObjectException {
- portableCtx.updateMetaData(typeId, new BinaryMetadata(typeId, typeName, fieldTypeIds, affKeyFieldName));
+ portableCtx.updateMetadata(typeId, new BinaryMetadata(typeId, typeName, fieldTypeIds, affKeyFieldName, null));
}
/** {@inheritDoc} */
@@ -464,13 +460,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
try {
BinaryMetadata oldMeta = metaDataCache.localPeek(key);
+ BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta0);
- if (oldMeta == null || checkMeta(typeId, oldMeta, newMeta0, null)) {
- BinaryObjectException err = metaDataCache.invoke(key, new MetaDataProcessor(typeId, newMeta0));
+ BinaryObjectException err = metaDataCache.invoke(key, new MetadataProcessor(mergedMeta));
- if (err != null)
- throw err;
- }
+ if (err != null)
+ throw err;
}
catch (CacheException e) {
throw new BinaryObjectException("Failed to update meta data for type: " + newMeta.typeName(), e);
@@ -727,125 +722,44 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/**
- * @param typeId Type ID.
- * @param oldMeta Old meta.
- * @param newMeta New meta.
- * @param fields Fields map.
- * @return Whether meta is changed.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- private static boolean checkMeta(int typeId, @Nullable BinaryMetadata oldMeta,
- BinaryMetadata newMeta, @Nullable Map<String, Integer> fields) throws BinaryObjectException {
- assert newMeta != null;
-
- Map<String, Integer> oldFields = oldMeta != null ? oldMeta.fieldsMap() : null;
- Map<String, Integer> newFields = newMeta.fieldsMap();
-
- boolean changed = false;
-
- if (oldMeta != null) {
- if (!oldMeta.typeName().equals(newMeta.typeName())) {
- throw new BinaryObjectException(
- "Two portable types have duplicate type ID [" +
- "typeId=" + typeId +
- ", typeName1=" + oldMeta.typeName() +
- ", typeName2=" + newMeta.typeName() +
- ']'
- );
- }
-
- if (!F.eq(oldMeta.affinityKeyFieldName(), newMeta.affinityKeyFieldName())) {
- throw new BinaryObjectException(
- "Portable type has different affinity key fields on different clients [" +
- "typeName=" + newMeta.typeName() +
- ", affKeyFieldName1=" + oldMeta.affinityKeyFieldName() +
- ", affKeyFieldName2=" + newMeta.affinityKeyFieldName() +
- ']'
- );
- }
-
- if (fields != null)
- fields.putAll(oldFields);
- }
- else
- changed = true;
-
- for (Map.Entry<String, Integer> e : newFields.entrySet()) {
- Integer oldTypeId = oldFields != null ? oldFields.get(e.getKey()) : null;
-
- if (oldTypeId != null) {
- if (!oldTypeId.equals(e.getValue())) {
- throw new BinaryObjectException(
- "Portable field has different types on different clients [" +
- "typeName=" + newMeta.typeName() +
- ", fieldName=" + e.getKey() +
- ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldTypeId) +
- ", fieldTypeName2=" + PortableUtils.fieldTypeName(e.getValue()) +
- ']'
- );
- }
- }
- else {
- if (fields != null)
- fields.put(e.getKey(), e.getValue());
-
- changed = true;
- }
- }
-
- return changed;
- }
-
- /**
+ * Processor responsible for metadata update.
*/
- private static class MetaDataProcessor implements
- EntryProcessor<PortableMetadataKey, BinaryMetadata, BinaryObjectException>, Externalizable {
+ private static class MetadataProcessor
+ implements EntryProcessor<PortableMetadataKey, BinaryMetadata, BinaryObjectException>, Externalizable {
/** */
private static final long serialVersionUID = 0L;
/** */
- private int typeId;
-
- /** */
private BinaryMetadata newMeta;
/**
* For {@link Externalizable}.
*/
- public MetaDataProcessor() {
+ public MetadataProcessor() {
// No-op.
}
/**
- * @param typeId Type ID.
* @param newMeta New metadata.
*/
- private MetaDataProcessor(int typeId, BinaryMetadata newMeta) {
+ private MetadataProcessor(BinaryMetadata newMeta) {
assert newMeta != null;
- this.typeId = typeId;
this.newMeta = newMeta;
}
/** {@inheritDoc} */
- @Override public BinaryObjectException process(
- MutableEntry<PortableMetadataKey, BinaryMetadata> entry,
+ @Override public BinaryObjectException process(MutableEntry<PortableMetadataKey, BinaryMetadata> entry,
Object... args) {
try {
BinaryMetadata oldMeta = entry.getValue();
- Map<String, Integer> fields = new HashMap<>();
+ BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta);
- if (checkMeta(typeId, oldMeta, newMeta, fields)) {
- BinaryMetadata res = new BinaryMetadata(typeId, newMeta.typeName(), fields,
- newMeta.affinityKeyFieldName());
+ if (mergedMeta != oldMeta)
+ entry.setValue(mergedMeta);
- entry.setValue(res);
-
- return null;
- }
- else
- return null;
+ return null;
}
catch (BinaryObjectException e) {
return e;
@@ -854,19 +768,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(typeId);
out.writeObject(newMeta);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- typeId = in.readInt();
newMeta = (BinaryMetadata)in.readObject();
}
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(MetaDataProcessor.class, this);
+ return S.toString(MetadataProcessor.class, this);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 05d3515..d999466 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.platform;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.CacheEvent;
@@ -33,10 +34,10 @@ import org.apache.ignite.events.JobEvent;
import org.apache.ignite.events.SwapSpaceEvent;
import org.apache.ignite.events.TaskEvent;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.portable.GridPortableMarshaller;
-import org.apache.ignite.internal.portable.BinaryMetadata;
import org.apache.ignite.internal.portable.BinaryRawReaderEx;
import org.apache.ignite.internal.portable.BinaryRawWriterEx;
+import org.apache.ignite.internal.portable.BinaryTypeImpl;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter;
import org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilterImpl;
@@ -69,7 +70,6 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T4;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.binary.BinaryType;
import org.jetbrains.annotations.Nullable;
import java.sql.Timestamp;
@@ -359,7 +359,7 @@ public class PlatformContextImpl implements PlatformContext {
);
for (T4<Integer, String, String, Map<String, Integer>> meta : metas)
- cacheObjProc.updateMetaData(meta.get1(), meta.get2(), meta.get3(), meta.get4());
+ cacheObjProc.updateMetadata(meta.get1(), meta.get2(), meta.get3(), meta.get4());
}
/** {@inheritDoc} */
@@ -390,7 +390,7 @@ public class PlatformContextImpl implements PlatformContext {
else {
writer.writeBoolean(true);
- Map<String, Integer> fields = ((BinaryMetadata)meta).fieldsMap();
+ Map<String, Integer> fields = ((BinaryTypeImpl)meta).metadata().fieldsMap();
writer.writeInt(typeId);
writer.writeString(meta.typeName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index 9f17bdd..e9cd1e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -71,7 +71,11 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
Marshaller marsh = igniteCfg.getMarshaller();
if (marsh == null) {
- igniteCfg.setMarshaller(new PortableMarshaller());
+ PortableMarshaller marsh0 = new PortableMarshaller();
+
+ marsh0.setCompactFooter(false);
+
+ igniteCfg.setMarshaller(marsh0);
cppCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
@@ -79,6 +83,9 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
else if (!(marsh instanceof PortableMarshaller))
throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
" can be used when running Apache Ignite C++): " + marsh.getClass().getName());
+ else if (((PortableMarshaller)marsh).isCompactFooter())
+ throw new IgniteException("Unsupported " + PortableMarshaller.class.getName() +
+ " \"compactFooter\" flag: must be false when running Apache Ignite C++.");
// Set Ignite home so that marshaller context works.
String ggHome = igniteCfg.getIgniteHome();
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index d0462e9..a59fd22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -92,7 +92,11 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
Marshaller marsh = igniteCfg.getMarshaller();
if (marsh == null) {
- igniteCfg.setMarshaller(new PortableMarshaller());
+ PortableMarshaller marsh0 = new PortableMarshaller();
+
+ marsh0.setCompactFooter(false);
+
+ igniteCfg.setMarshaller(marsh0);
dotNetCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
@@ -100,6 +104,9 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
else if (!(marsh instanceof PortableMarshaller))
throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
" can be used when running Apache Ignite.NET): " + marsh.getClass().getName());
+ else if (((PortableMarshaller)marsh).isCompactFooter())
+ throw new IgniteException("Unsupported " + PortableMarshaller.class.getName() +
+ " \"compactFooter\" flag: must be false when running Apache Ignite.NET.");
// Set Ignite home so that marshaller context works.
String ggHome = igniteCfg.getIgniteHome();
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 259d8c9..7337378 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -4983,6 +4983,31 @@ public abstract class IgniteUtils {
}
/**
+ * Read hash map.
+ *
+ * @param in Input.
+ * @return Read map.
+ * @throws IOException If de-serialization failed.
+ * @throws ClassNotFoundException If deserialized class could not be found.
+ */
+ @SuppressWarnings({"unchecked"})
+ @Nullable public static <K, V> HashMap<K, V> readHashMap(ObjectInput in)
+ throws IOException, ClassNotFoundException {
+ int size = in.readInt();
+
+ // Check null flag.
+ if (size == -1)
+ return null;
+
+ HashMap<K, V> map = U.newHashMap(size);
+
+ for (int i = 0; i < size; i++)
+ map.put((K)in.readObject(), (V)in.readObject());
+
+ return map;
+ }
+
+ /**
*
* @param in Input.
* @return Read map.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index 409a893..1704c8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@ -74,6 +74,12 @@ import org.jetbrains.annotations.Nullable;
* For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
*/
public class PortableMarshaller extends AbstractMarshaller {
+ /** Default value of "keep deserialized" flag. */
+ public static final boolean DFLT_KEEP_DESERIALIZED = true;
+
+ /** Default value of "compact footer" flag. */
+ public static final boolean DFLT_COMPACT_FOOTER = true;
+
// TODO ignite-1282 Move to IgniteConfiguration.
/** Class names. */
private Collection<String> clsNames;
@@ -88,7 +94,10 @@ public class PortableMarshaller extends AbstractMarshaller {
private Collection<BinaryTypeConfiguration> typeCfgs;
/** Keep deserialized flag. */
- private boolean keepDeserialized = true;
+ private boolean keepDeserialized = DFLT_KEEP_DESERIALIZED;
+
+ /** Compact footer. */
+ private boolean compactFooter = DFLT_COMPACT_FOOTER;
/** */
private GridPortableMarshaller impl;
@@ -192,6 +201,33 @@ public class PortableMarshaller extends AbstractMarshaller {
}
/**
+ * Get whether to write footers in compact form. When enabled, Ignite will not write fields metadata
+ * when serializing objects, because internally {@code PortableMarshaller} already distribute metadata inside
+ * cluster. This increases serialization performance.
+ * <p>
+ * <b>WARNING!</b> This mode should be disabled when already serialized data can be taken from some external
+ * sources (e.g. cache store which stores data in binary form, data center replication, etc.). Otherwise binary
+ * objects without any associated metadata could appear in the cluster and Ignite will not be able to deserialize
+ * it.
+ * <p>
+ * Defaults to {@link #DFLT_COMPACT_FOOTER}.
+ *
+ * @return Whether to write footers in compact form.
+ */
+ public boolean isCompactFooter() {
+ return compactFooter;
+ }
+
+ /**
+ * Set whether to write footers in compact form. See {@link #isCompactFooter()} for more info.
+ *
+ * @param compactFooter Whether to write footers in compact form.
+ */
+ public void setCompactFooter(boolean compactFooter) {
+ this.compactFooter = compactFooter;
+ }
+
+ /**
* Returns currently set {@link MarshallerContext}.
*
* @return Marshaller context.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index ae23d0e..45c8e0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -135,6 +135,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.events.EventType.EVT_NODE_METRICS_UPDATED;
import static org.apache.ignite.events.EventType.EVT_NODE_SEGMENTED;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_COMPACT_FOOTER;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_DFLT_SUID;
import static org.apache.ignite.spi.IgnitePortProtocol.TCP;
import static org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoverySpiState.AUTH_FAILED;
@@ -3160,8 +3161,8 @@ class ServerImpl extends TcpDiscoveryImpl {
" property value differs from remote node's value " +
"(to make sure all nodes in topology have identical marshaller settings, " +
"configure system property explicitly) " +
- "[locMarshUseDfltSuid=" + locMarshUseDfltSuid +
- ", rmtMarshUseDfltSuid=" + rmtMarshUseDfltSuid +
+ "[locMarshUseDfltSuid=" + rmtMarshUseDfltSuid +
+ ", rmtMarshUseDfltSuid=" + locMarshUseDfltSuid +
", locNodeAddrs=" + U.addressesAsString(node) + ", locPort=" + node.discoveryPort() +
", rmtNodeAddr=" + U.addressesAsString(locNode) + ", locNodeId=" + node.id() +
", rmtNodeId=" + locNode.id() + ']';
@@ -3182,6 +3183,52 @@ class ServerImpl extends TcpDiscoveryImpl {
return;
}
+ // Validate compact footer flags.
+ Boolean locMarshCompactFooter = locNode.attribute(ATTR_MARSHALLER_COMPACT_FOOTER);
+ boolean locMarshCompactFooterBool = locMarshCompactFooter != null ? locMarshCompactFooter : false;
+
+ Boolean rmtMarshCompactFooter = node.attribute(ATTR_MARSHALLER_COMPACT_FOOTER);
+ boolean rmtMarshCompactFooterBool = rmtMarshCompactFooter != null ? rmtMarshCompactFooter : false;
+
+ if (locMarshCompactFooterBool != rmtMarshCompactFooterBool) {
+ String errMsg = "Local node's portable marshaller \"compactFooter\" property differs from " +
+ "the same property on remote node (make sure all nodes in topology have the same value " +
+ "of \"compactFooter\" property) [locMarshallerCompactFooter=" + locMarshCompactFooterBool +
+ ", rmtMarshallerCompactFooter=" + rmtMarshCompactFooterBool +
+ ", locNodeAddrs=" + U.addressesAsString(locNode) +
+ ", rmtNodeAddrs=" + U.addressesAsString(node) +
+ ", locNodeId=" + locNode.id() + ", rmtNodeId=" + msg.creatorNodeId() + ']';
+
+ LT.warn(log, null, errMsg);
+
+ // Always output in debug.
+ if (log.isDebugEnabled())
+ log.debug(errMsg);
+
+ try {
+ String sndMsg = "Local node's portable marshaller \"compactFooter\" property differs from " +
+ "the same property on remote node (make sure all nodes in topology have the same value " +
+ "of \"compactFooter\" property) [locMarshallerCompactFooter=" + rmtMarshCompactFooterBool +
+ ", rmtMarshallerCompactFooter=" + locMarshCompactFooterBool +
+ ", locNodeAddrs=" + U.addressesAsString(node) + ", locPort=" + node.discoveryPort() +
+ ", rmtNodeAddr=" + U.addressesAsString(locNode) + ", locNodeId=" + node.id() +
+ ", rmtNodeId=" + locNode.id() + ']';
+
+ trySendMessageDirectly(node, new TcpDiscoveryCheckFailedMessage(locNodeId, sndMsg));
+ }
+ catch (IgniteSpiException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send marshaller check failed message to node " +
+ "[node=" + node + ", err=" + e.getMessage() + ']');
+
+ onException("Failed to send marshaller check failed message to node " +
+ "[node=" + node + ", err=" + e.getMessage() + ']', e);
+ }
+
+ // Ignore join request.
+ return;
+ }
+
// Handle join.
node.internalOrder(ring.nextNodeOrder());
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
index 14fc6f3..8f79db1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
@@ -46,11 +46,13 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Portable marshaller.
* @throws Exception If failed.
*/
- protected static PortableMarshaller createMarshaller() throws Exception {
- PortableContext ctx = new PortableContext(new TestCachingMetadataHandler(), new IgniteConfiguration());
+ protected PortableMarshaller createMarshaller() throws Exception {
+ PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
PortableMarshaller marsh = new PortableMarshaller();
+ marsh.setCompactFooter(compactFooter());
+
marsh.setTypeConfigurations(Arrays.asList(
new BinaryTypeConfiguration(TestObject.class.getName()),
new BinaryTypeConfiguration(TestOuterObject.class.getName()),
@@ -65,6 +67,13 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
}
/**
+ * @return Whether to use compact footer.
+ */
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
* Get portable context for the current marshaller.
*
* @param marsh Marshaller.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
new file mode 100644
index 0000000..3ec0b83
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryField;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.marshaller.MarshallerContextTestImpl;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.util.Arrays;
+
+/**
+ * Contains tests for compact offsets.
+ */
+public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbstractTest {
+ /** 2 pow 8. */
+ private static int POW_8 = 1 << 8;
+
+ /** 2 pow 16. */
+ private static int POW_16 = 1 << 16;
+
+ /** Marshaller. */
+ protected PortableMarshaller marsh;
+
+ /** Portable context. */
+ protected PortableContext ctx;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
+
+ marsh = new PortableMarshaller();
+
+ marsh.setCompactFooter(compactFooter());
+
+ marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
+ marsh.setContext(new MarshallerContextTestImpl(null));
+
+ IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+ }
+
+ /**
+ * @return Whether to use compact footers.
+ */
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
+ * Test 1 byte.
+ *
+ * @throws Exception If failed.
+ */
+ public void test1Byte() throws Exception {
+ check(POW_8 >> 2);
+ }
+
+ /**
+ * Test 1 byte with sign altering.
+ *
+ * @throws Exception If failed.
+ */
+ public void test1ByteSign() throws Exception {
+ check(POW_8 >> 1);
+ }
+
+ /**
+ * Test 2 bytes.
+ *
+ * @throws Exception If failed.
+ */
+ public void test2Bytes() throws Exception {
+ check(POW_16 >> 2);
+ }
+
+ /**
+ * Test 2 bytes with sign altering.
+ *
+ * @throws Exception If failed.
+ */
+ public void test2BytesSign() throws Exception {
+ check(POW_16 >> 1);
+ }
+
+ /**
+ * Test 4 bytes.
+ *
+ * @throws Exception If failed.
+ */
+ public void test4Bytes() throws Exception {
+ check(POW_16 << 2);
+ }
+
+ /**
+ * Main check routine.
+ *
+ * @param len Length of the first field.
+ *
+ * @throws Exception If failed.
+ */
+ private void check(int len) throws Exception {
+ TestObject obj = new TestObject(len);
+
+ BinaryObjectEx portObj = toPortable(marsh, obj);
+
+ // 1. Test portable object content.
+ assert portObj.hasField("field1");
+ assert portObj.hasField("field2");
+
+ byte[] field1 = portObj.field("field1");
+ Integer field2 = portObj.field("field2");
+
+ assert field1 != null;
+ assert field2 != null;
+
+ assert Arrays.equals(obj.field1, field1);
+ assert obj.field2 == field2;
+
+ // 2. Test fields API.
+ BinaryField field1Desc = portObj.type().field("field1");
+ BinaryField field2Desc = portObj.type().field("field2");
+
+ assert field1Desc.exists(portObj);
+ assert field2Desc.exists(portObj);
+
+ assert Arrays.equals(obj.field1, (byte[])field1Desc.value(portObj));
+ assert obj.field2 == (Integer)field2Desc.value(portObj);
+
+ // 3. Test deserialize.
+ TestObject objRestored = portObj.deserialize();
+
+ assert objRestored != null;
+
+ assert Arrays.equals(obj.field1, objRestored.field1);
+ assert obj.field2 == objRestored.field2;
+ }
+
+ /**
+ * Convert object to portable object.
+ *
+ * @param marsh Marshaller.
+ * @param obj Object.
+ * @return Portable object.
+ * @throws Exception If failed.
+ */
+ protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
+
+ /**
+ * Test object.
+ */
+ public static class TestObject {
+ /** First field with variable length. */
+ public byte[] field1;
+
+ /** Second field. */
+ public int field2;
+
+ /**
+ * Default constructor.
+ */
+ public TestObject() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param len Array length.
+ */
+ public TestObject(int len) {
+ field1 = new byte[len];
+
+ field1[0] = 1;
+ field1[len - 1] = 2;
+
+ field2 = len;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
new file mode 100644
index 0000000..b23f012
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+
+/**
+ * Compact offsets tests for heap portable objects.
+ */
+public class BinaryFooterOffsetsHeapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
+ /** {@inheritDoc} */
+ @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ byte[] bytes = marsh.marshal(obj);
+
+ return new BinaryObjectImpl(ctx, bytes, 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
new file mode 100644
index 0000000..e52ebe7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.eclipse.jetty.util.ConcurrentHashSet;
+import sun.misc.Unsafe;
+
+/**
+ * Compact offsets tests for offheap portable objects.
+ */
+public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
+ /** Unsafe instance. */
+ private static final Unsafe UNSAFE = GridUnsafe.unsafe();
+
+ /** Byte array offset for unsafe mechanics. */
+ protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+ /** Allocated unsafe pointer. */
+ private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ // Cleanup allocated objects.
+ for (Long ptr : ptrs)
+ UNSAFE.freeMemory(ptr);
+
+ ptrs.clear();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ byte[] arr = marsh.marshal(obj);
+
+ long ptr = UNSAFE.allocateMemory(arr.length);
+
+ ptrs.add(ptr);
+
+ UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+
+ return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length);
+ }
+}
[31/55] [abbrv] ignite git commit: IGNITE-1950: Binary format: fixed
arrays - handles are not written/read for them any more.
Posted by ag...@apache.org.
IGNITE-1950: Binary format: fixed arrays - handles are not written/read for them any more.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3c745037
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3c745037
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3c745037
Branch: refs/heads/ignite-1.5
Commit: 3c745037c4e03c75ca6a98ec7f80888c02eb90ed
Parents: 60b805e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 11:08:26 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 11:08:26 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryReaderExImpl.java | 86 ++------------------
.../internal/portable/BinaryWriterExImpl.java | 42 +---------
.../portable/BinaryMarshallerSelfTest.java | 12 ---
3 files changed, 12 insertions(+), 128 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3c745037/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 6ba5981..5e31532 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -366,7 +366,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @param obj Object.
*/
void setHandler(Object obj) {
- rCtx.put(start, obj);
+ setHandler(obj, start);
}
/**
@@ -1886,120 +1886,72 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private byte[] doReadByteArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- byte[] arr = in.readByteArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readByteArray(len);
}
/**
* @return Value.
*/
private short[] doReadShortArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- short[] arr = in.readShortArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readShortArray(len);
}
/**
* @return Value.
*/
private int[] doReadIntArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- int[] arr = in.readIntArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readIntArray(len);
}
/**
* @return Value.
*/
private long[] doReadLongArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- long[] arr = in.readLongArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readLongArray(len);
}
/**
* @return Value.
*/
private float[] doReadFloatArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- float[] arr = in.readFloatArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readFloatArray(len);
}
/**
* @return Value.
*/
private double[] doReadDoubleArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- double[] arr = in.readDoubleArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readDoubleArray(len);
}
/**
* @return Value.
*/
private char[] doReadCharArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- char[] arr = in.readCharArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readCharArray(len);
}
/**
* @return Value.
*/
private boolean[] doReadBooleanArray() {
- int hPos = positionForHandle();
-
int len = in.readInt();
- boolean[] arr = in.readBooleanArray(len);
-
- setHandler(arr, hPos);
-
- return arr;
+ return in.readBooleanArray(len);
}
/**
@@ -2007,14 +1959,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @throws BinaryObjectException In case of error.
*/
private BigDecimal[] doReadDecimalArray() throws BinaryObjectException {
- int hPos = positionForHandle();
-
int len = in.readInt();
BigDecimal[] arr = new BigDecimal[len];
- setHandler(arr, hPos);
-
for (int i = 0; i < len; i++) {
byte flag = in.readByte();
@@ -2036,14 +1984,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @throws BinaryObjectException In case of error.
*/
private String[] doReadStringArray() throws BinaryObjectException {
- int hPos = positionForHandle();
-
int len = in.readInt();
String[] arr = new String[len];
- setHandler(arr, hPos);
-
for (int i = 0; i < len; i++) {
byte flag = in.readByte();
@@ -2065,14 +2009,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @throws BinaryObjectException In case of error.
*/
private UUID[] doReadUuidArray() throws BinaryObjectException {
- int hPos = positionForHandle();
-
int len = in.readInt();
UUID[] arr = new UUID[len];
- setHandler(arr, hPos);
-
for (int i = 0; i < len; i++) {
byte flag = in.readByte();
@@ -2094,14 +2034,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @throws BinaryObjectException In case of error.
*/
private Date[] doReadDateArray() throws BinaryObjectException {
- int hPos = positionForHandle();
-
int len = in.readInt();
Date[] arr = new Date[len];
- setHandler(arr, hPos);
-
for (int i = 0; i < len; i++) {
byte flag = in.readByte();
@@ -2123,14 +2059,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @throws BinaryObjectException In case of error.
*/
private Timestamp[] doReadTimestampArray() throws BinaryObjectException {
- int hPos = positionForHandle();
-
int len = in.readInt();
Timestamp[] arr = new Timestamp[len];
- setHandler(arr, hPos);
-
for (int i = 0; i < len; i++) {
byte flag = in.readByte();
http://git-wip-us.apache.org/repos/asf/ignite/blob/3c745037/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
index 7bb4c49..6f8534a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
@@ -472,9 +472,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(BYTE_ARR);
out.unsafeWriteInt(val.length);
@@ -490,9 +487,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(SHORT_ARR);
out.unsafeWriteInt(val.length);
@@ -508,9 +502,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(INT_ARR);
out.unsafeWriteInt(val.length);
@@ -526,9 +517,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(LONG_ARR);
out.unsafeWriteInt(val.length);
@@ -544,9 +532,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(FLOAT_ARR);
out.unsafeWriteInt(val.length);
@@ -562,9 +547,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(DOUBLE_ARR);
out.unsafeWriteInt(val.length);
@@ -580,9 +562,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(CHAR_ARR);
out.unsafeWriteInt(val.length);
@@ -598,9 +577,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(BOOLEAN_ARR);
out.unsafeWriteInt(val.length);
@@ -616,9 +592,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(DECIMAL_ARR);
out.unsafeWriteInt(val.length);
@@ -635,9 +608,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(STRING_ARR);
out.unsafeWriteInt(val.length);
@@ -654,9 +624,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(UUID_ARR);
out.unsafeWriteInt(val.length);
@@ -673,9 +640,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(DATE_ARR);
out.unsafeWriteInt(val.length);
@@ -692,9 +656,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (val == null)
out.writeByte(NULL);
else {
- if (tryWriteAsHandle(val))
- return;
-
out.unsafeEnsure(1 + 4);
out.unsafeWriteByte(TIMESTAMP_ARR);
out.unsafeWriteInt(val.length);
@@ -1801,6 +1762,9 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
out.unsafeWriteByte(GridPortableMarshaller.HANDLE);
out.unsafeWriteInt(pos - old);
+ if (obj.getClass().isArray())
+ System.out.println("CASE!");
+
return true;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3c745037/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
index 17ec7d6..dfc8109 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -2258,19 +2258,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
assertEquals(obj, res);
- assertTrue(res.bArr == res.inner.bArr);
- assertTrue(res.cArr == res.inner.cArr);
- assertTrue(res.boolArr == res.inner.boolArr);
- assertTrue(res.sArr == res.inner.sArr);
- assertTrue(res.strArr == res.inner.strArr);
- assertTrue(res.iArr == res.inner.iArr);
- assertTrue(res.lArr == res.inner.lArr);
- assertTrue(res.fArr == res.inner.fArr);
- assertTrue(res.dArr == res.inner.dArr);
- assertTrue(res.dateArr == res.inner.dateArr);
- assertTrue(res.uuidArr == res.inner.uuidArr);
assertTrue(res.objArr == res.inner.objArr);
- assertTrue(res.bdArr == res.inner.bdArr);
assertTrue(res.map == res.inner.map);
assertTrue(res.col == res.inner.col);
assertTrue(res.mEntry == res.inner.mEntry);
[22/55] [abbrv] ignite git commit: IGNITE-1949: C++ platform library
for Linux: make uninstall now delete directories.
Posted by ag...@apache.org.
IGNITE-1949: C++ platform library for Linux: make uninstall now delete directories.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/94afe3e2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/94afe3e2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/94afe3e2
Branch: refs/heads/ignite-1.5
Commit: 94afe3e2eb421323d1602c5f9845c93b23a96548
Parents: a7b22f8
Author: Igor Sapego <is...@gridgain.com>
Authored: Thu Nov 19 13:41:37 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Nov 19 13:41:37 2015 +0300
----------------------------------------------------------------------
modules/platforms/cpp/common/include/Makefile.am | 3 +++
modules/platforms/cpp/common/os/linux/include/Makefile.am | 3 +++
modules/platforms/cpp/core/include/Makefile.am | 3 +++
modules/platforms/cpp/core/os/linux/include/Makefile.am | 3 +++
4 files changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/94afe3e2/modules/platforms/cpp/common/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/Makefile.am b/modules/platforms/cpp/common/include/Makefile.am
index 7a02225..0df9741 100644
--- a/modules/platforms/cpp/common/include/Makefile.am
+++ b/modules/platforms/cpp/common/include/Makefile.am
@@ -21,3 +21,6 @@ nobase_include_HEADERS = ignite/common/concurrent.h \
ignite/common/java.h \
ignite/common/exports.h \
ignite/common/utils.h
+
+uninstall-hook:
+ find ${includedir}/ignite -type d -empty -delete
http://git-wip-us.apache.org/repos/asf/ignite/blob/94afe3e2/modules/platforms/cpp/common/os/linux/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/linux/include/Makefile.am b/modules/platforms/cpp/common/os/linux/include/Makefile.am
index 68e45e6..f6e2803 100644
--- a/modules/platforms/cpp/common/os/linux/include/Makefile.am
+++ b/modules/platforms/cpp/common/os/linux/include/Makefile.am
@@ -19,3 +19,6 @@ ACLOCAL_AMFLAGS = "-Im4"
nobase_include_HEADERS = ignite/common/common.h \
ignite/common/concurrent_os.h
+
+uninstall-hook:
+ find ${includedir}/ignite -type d -empty -delete
http://git-wip-us.apache.org/repos/asf/ignite/blob/94afe3e2/modules/platforms/cpp/core/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/Makefile.am b/modules/platforms/cpp/core/include/Makefile.am
index 1e7bf7d..b28caed 100644
--- a/modules/platforms/cpp/core/include/Makefile.am
+++ b/modules/platforms/cpp/core/include/Makefile.am
@@ -64,3 +64,6 @@ nobase_include_HEADERS = ignite/cache/cache.h \
ignite/ignite_error.h \
ignite/ignition.h \
ignite/guid.h
+
+uninstall-hook:
+ find ${includedir}/ignite -type d -empty -delete
http://git-wip-us.apache.org/repos/asf/ignite/blob/94afe3e2/modules/platforms/cpp/core/os/linux/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/os/linux/include/Makefile.am b/modules/platforms/cpp/core/os/linux/include/Makefile.am
index 2ee13eff..9fa5242 100644
--- a/modules/platforms/cpp/core/os/linux/include/Makefile.am
+++ b/modules/platforms/cpp/core/os/linux/include/Makefile.am
@@ -18,3 +18,6 @@
ACLOCAL_AMFLAGS = "-Im4"
nobase_include_HEADERS = ignite/impl/utils.h
+
+uninstall-hook:
+ find ${includedir}/ignite -type d -empty -delete
[46/55] [abbrv] ignite git commit: IGNITE-1282 - Fixed tests after
merge from ignite-1.5
Posted by ag...@apache.org.
IGNITE-1282 - Fixed tests after merge from ignite-1.5
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0410f0e5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0410f0e5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0410f0e5
Branch: refs/heads/ignite-1.5
Commit: 0410f0e596390ee28a1f1535e63030442c557988
Parents: 6d4ecfd
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 15:34:57 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 15:34:57 2015 +0300
----------------------------------------------------------------------
.../distributed/dht/GridPartitionedSingleGetFuture.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0410f0e5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index 32f4e80..f276cac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -49,7 +49,6 @@ import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.CIX1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteProductVersion;
@@ -448,7 +447,7 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
* @param nodeId Node ID.
* @param res Result.
*/
- public void onResult(UUID nodeId, GridNearGetResponse res) {
+ @Override public void onResult(UUID nodeId, GridNearGetResponse res) {
if (!processResponse(nodeId) ||
!checkError(res.error(), !F.isEmpty(res.invalidPartitions()), res.topologyVersion()))
return;
@@ -581,10 +580,7 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
}
else {
if (!keepCacheObjects) {
- Object res = CU.value(val, cctx, true);
-
- if (deserializePortable && !skipVals)
- res = cctx.unwrapPortableIfNeeded(res, false);
+ Object res = cctx.unwrapPortableIfNeeded(val, !deserializePortable && !skipVals);
onDone(res);
}
[23/55] [abbrv] ignite git commit: IGNITE-1941: Removed TODOs. Let's
keep these methods because they are convenient.
Posted by ag...@apache.org.
IGNITE-1941: Removed TODOs. Let's keep these methods because they are convenient.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5ea0625b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5ea0625b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5ea0625b
Branch: refs/heads/ignite-1.5
Commit: 5ea0625b47962a12da0aaa5357df514a7aad83c5
Parents: 94afe3e
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Nov 19 13:49:40 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Nov 19 13:49:40 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/binary/BinaryObject.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea0625b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
index 9481618..f098c16 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
@@ -123,16 +123,14 @@ public interface BinaryObject extends Serializable, Cloneable {
* @param fieldName Field name.
* @return Field value.
* @throws BinaryObjectException In case of any other error.
- * TODO ignite-1282 remove.
*/
public <F> F field(String fieldName) throws BinaryObjectException;
/**
- * Checks whether field is set.
- ** TODO ignite-1282 remove.
+ * Checks whether field exists in the object.
*
* @param fieldName Field name.
- * @return {@code true} if field is set.
+ * @return {@code True} if field exists.
*/
public boolean hasField(String fieldName);
[07/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
new file mode 100644
index 0000000..ea472eb
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryBuilderSelfTest.cs
@@ -0,0 +1,1721 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable UnassignedField.Global
+// ReSharper disable CollectionNeverUpdated.Global
+namespace Apache.Ignite.Core.Tests.Binary
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Binary builder self test.
+ /// </summary>
+ public class BinaryBuilderSelfTest
+ {
+ /** Undefined type: Empty. */
+ private const string TypeEmpty = "EmptyUndefined";
+
+ /** Grid. */
+ private Ignite _grid;
+
+ /** Marshaller. */
+ private Marshaller _marsh;
+
+ /// <summary>
+ /// Set up routine.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void SetUp()
+ {
+ TestUtils.KillProcesses();
+
+ var cfg = new IgniteConfiguration
+ {
+ BinaryConfiguration = new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (Empty)),
+ new BinaryTypeConfiguration(typeof (Primitives)),
+ new BinaryTypeConfiguration(typeof (PrimitiveArrays)),
+ new BinaryTypeConfiguration(typeof (StringDateGuidEnum)),
+ new BinaryTypeConfiguration(typeof (WithRaw)),
+ new BinaryTypeConfiguration(typeof (MetaOverwrite)),
+ new BinaryTypeConfiguration(typeof (NestedOuter)),
+ new BinaryTypeConfiguration(typeof (NestedInner)),
+ new BinaryTypeConfiguration(typeof (MigrationOuter)),
+ new BinaryTypeConfiguration(typeof (MigrationInner)),
+ new BinaryTypeConfiguration(typeof (InversionOuter)),
+ new BinaryTypeConfiguration(typeof (InversionInner)),
+ new BinaryTypeConfiguration(typeof (CompositeOuter)),
+ new BinaryTypeConfiguration(typeof (CompositeInner)),
+ new BinaryTypeConfiguration(typeof (CompositeArray)),
+ new BinaryTypeConfiguration(typeof (CompositeContainer)),
+ new BinaryTypeConfiguration(typeof (ToBinary)),
+ new BinaryTypeConfiguration(typeof (Remove)),
+ new BinaryTypeConfiguration(typeof (RemoveInner)),
+ new BinaryTypeConfiguration(typeof (BuilderInBuilderOuter)),
+ new BinaryTypeConfiguration(typeof (BuilderInBuilderInner)),
+ new BinaryTypeConfiguration(typeof (BuilderCollection)),
+ new BinaryTypeConfiguration(typeof (BuilderCollectionItem)),
+ new BinaryTypeConfiguration(typeof (DecimalHolder)),
+ new BinaryTypeConfiguration(TypeEmpty)
+ },
+ DefaultIdMapper = new IdMapper()
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = new List<string>
+ {
+ "-ea",
+ "-Xcheck:jni",
+ "-Xms4g",
+ "-Xmx4g",
+ "-DIGNITE_QUIET=false",
+ "-Xnoagent",
+ "-Djava.compiler=NONE",
+ "-Xdebug",
+ "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
+ "-XX:+HeapDumpOnOutOfMemoryError"
+ },
+ SpringConfigUrl = "config\\binary.xml"
+ };
+
+ _grid = (Ignite) Ignition.Start(cfg);
+
+ _marsh = _grid.Marshaller;
+ }
+
+ /// <summary>
+ /// Tear down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public virtual void TearDown()
+ {
+ if (_grid != null)
+ Ignition.Stop(_grid.Name, true);
+
+ _grid = null;
+ }
+
+ /// <summary>
+ /// Ensure that binary engine is able to work with type names, which are not configured.
+ /// </summary>
+ [Test]
+ public void TestNonConfigured()
+ {
+ string typeName1 = "Type1";
+ string typeName2 = "Type2";
+ string field1 = "field1";
+ string field2 = "field2";
+
+ // 1. Ensure that builder works fine.
+ IBinaryObject binObj1 = _grid.GetBinary().GetBuilder(typeName1).SetField(field1, 1).Build();
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+
+ // 2. Ensure that object can be unmarshalled without deserialization.
+ byte[] data = ((BinaryObject) binObj1).Data;
+
+ binObj1 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+
+ // 3. Ensure that we can nest one anonymous object inside another
+ IBinaryObject binObj2 =
+ _grid.GetBinary().GetBuilder(typeName2).SetField(field2, binObj1).Build();
+
+ Assert.AreEqual(typeName2, binObj2.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj2.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field2, binObj2.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, binObj2.GetBinaryType().GetFieldTypeName(field2));
+
+ binObj1 = binObj2.GetField<IBinaryObject>(field2);
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+
+ // 4. Ensure that we can unmarshal object with other nested object.
+ data = ((BinaryObject) binObj2).Data;
+
+ binObj2 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(typeName2, binObj2.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj2.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field2, binObj2.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, binObj2.GetBinaryType().GetFieldTypeName(field2));
+
+ binObj1 = binObj2.GetField<IBinaryObject>(field2);
+
+ Assert.AreEqual(typeName1, binObj1.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj1.GetBinaryType().Fields.Count);
+ Assert.AreEqual(field1, binObj1.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj1.GetBinaryType().GetFieldTypeName(field1));
+
+ Assert.AreEqual(1, binObj1.GetField<int>(field1));
+ }
+
+ /// <summary>
+ /// Test "ToBinary()" method.
+ /// </summary>
+ [Test]
+ public void TestToBinary()
+ {
+ DateTime date = DateTime.Now.ToUniversalTime();
+ Guid guid = Guid.NewGuid();
+
+ IIgniteBinary api = _grid.GetBinary();
+
+ // 1. Primitives.
+ Assert.AreEqual(1, api.ToBinary<byte>((byte)1));
+ Assert.AreEqual(1, api.ToBinary<short>((short)1));
+ Assert.AreEqual(1, api.ToBinary<int>(1));
+ Assert.AreEqual(1, api.ToBinary<long>((long)1));
+
+ Assert.AreEqual((float)1, api.ToBinary<float>((float)1));
+ Assert.AreEqual((double)1, api.ToBinary<double>((double)1));
+
+ Assert.AreEqual(true, api.ToBinary<bool>(true));
+ Assert.AreEqual('a', api.ToBinary<char>('a'));
+
+ // 2. Special types.
+ Assert.AreEqual("a", api.ToBinary<string>("a"));
+ Assert.AreEqual(date, api.ToBinary<DateTime>(date));
+ Assert.AreEqual(guid, api.ToBinary<Guid>(guid));
+ Assert.AreEqual(TestEnum.One, api.ToBinary<TestEnum>(TestEnum.One));
+
+ // 3. Arrays.
+ Assert.AreEqual(new byte[] { 1 }, api.ToBinary<byte[]>(new byte[] { 1 }));
+ Assert.AreEqual(new short[] { 1 }, api.ToBinary<short[]>(new short[] { 1 }));
+ Assert.AreEqual(new[] { 1 }, api.ToBinary<int[]>(new[] { 1 }));
+ Assert.AreEqual(new long[] { 1 }, api.ToBinary<long[]>(new long[] { 1 }));
+
+ Assert.AreEqual(new float[] { 1 }, api.ToBinary<float[]>(new float[] { 1 }));
+ Assert.AreEqual(new double[] { 1 }, api.ToBinary<double[]>(new double[] { 1 }));
+
+ Assert.AreEqual(new[] { true }, api.ToBinary<bool[]>(new[] { true }));
+ Assert.AreEqual(new[] { 'a' }, api.ToBinary<char[]>(new[] { 'a' }));
+
+ Assert.AreEqual(new[] { "a" }, api.ToBinary<string[]>(new[] { "a" }));
+ Assert.AreEqual(new[] { date }, api.ToBinary<DateTime[]>(new[] { date }));
+ Assert.AreEqual(new[] { guid }, api.ToBinary<Guid[]>(new[] { guid }));
+ Assert.AreEqual(new[] { TestEnum.One }, api.ToBinary<TestEnum[]>(new[] { TestEnum.One }));
+
+ // 4. Objects.
+ IBinaryObject binObj = api.ToBinary<IBinaryObject>(new ToBinary(1));
+
+ Assert.AreEqual(typeof(ToBinary).Name, binObj.GetBinaryType().TypeName);
+ Assert.AreEqual(1, binObj.GetBinaryType().Fields.Count);
+ Assert.AreEqual("Val", binObj.GetBinaryType().Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, binObj.GetBinaryType().GetFieldTypeName("Val"));
+
+ Assert.AreEqual(1, binObj.GetField<int>("val"));
+ Assert.AreEqual(1, binObj.Deserialize<ToBinary>().Val);
+
+ // 5. Object array.
+ var binObjArr = api.ToBinary<object[]>(new object[] {new ToBinary(1)})
+ .OfType<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(1, binObjArr.Length);
+ Assert.AreEqual(1, binObjArr[0].GetField<int>("Val"));
+ Assert.AreEqual(1, binObjArr[0].Deserialize<ToBinary>().Val);
+ }
+
+ /// <summary>
+ /// Test builder field remove logic.
+ /// </summary>
+ [Test]
+ public void TestRemove()
+ {
+ // Create empty object.
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Remove)).Build();
+
+ Assert.IsNull(binObj.GetField<object>("val"));
+ Assert.IsNull(binObj.Deserialize<Remove>().Val);
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+
+ // Populate it with field.
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(binObj);
+
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ object val = 1;
+
+ builder.SetField("val", val);
+
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ binObj = builder.Build();
+
+ Assert.AreEqual(val, binObj.GetField<object>("val"));
+ Assert.AreEqual(val, binObj.Deserialize<Remove>().Val);
+
+ meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("val", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
+
+ // Perform field remove.
+ builder = _grid.GetBinary().GetBuilder(binObj);
+
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ builder.RemoveField("val");
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ builder.SetField("val", val);
+ Assert.AreEqual(val, builder.GetField<object>("val"));
+
+ builder.RemoveField("val");
+ Assert.IsNull(builder.GetField<object>("val"));
+
+ binObj = builder.Build();
+
+ Assert.IsNull(binObj.GetField<object>("val"));
+ Assert.IsNull(binObj.Deserialize<Remove>().Val);
+
+ // Test correct removal of field being referenced by handle somewhere else.
+ RemoveInner inner = new RemoveInner(2);
+
+ binObj = _grid.GetBinary().GetBuilder(typeof(Remove))
+ .SetField("val", inner)
+ .SetField("val2", inner)
+ .Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).RemoveField("val").Build();
+
+ Remove obj = binObj.Deserialize<Remove>();
+
+ Assert.IsNull(obj.Val);
+ Assert.AreEqual(2, obj.Val2.Val);
+ }
+
+ /// <summary>
+ /// Test builder-in-builder scenario.
+ /// </summary>
+ [Test]
+ public void TestBuilderInBuilder()
+ {
+ // Test different builders assembly.
+ IBinaryObjectBuilder builderOuter = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter));
+ IBinaryObjectBuilder builderInner = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner));
+
+ builderOuter.SetField<object>("inner", builderInner);
+ builderInner.SetField<object>("outer", builderOuter);
+
+ IBinaryObject outerbinObj = builderOuter.Build();
+
+ IBinaryType meta = outerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("inner", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+
+ IBinaryObject innerbinObj = outerbinObj.GetField<IBinaryObject>("inner");
+
+ meta = innerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("outer", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
+
+ BuilderInBuilderOuter outer = outerbinObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer, outer.Inner.Outer);
+
+ // Test same builders assembly.
+ innerbinObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner)).Build();
+
+ outerbinObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter))
+ .SetField("inner", innerbinObj)
+ .SetField("inner2", innerbinObj)
+ .Build();
+
+ meta = outerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.IsTrue(meta.Fields.Contains("inner"));
+ Assert.IsTrue(meta.Fields.Contains("inner2"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
+
+ outer = outerbinObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer.Inner, outer.Inner2);
+
+ builderOuter = _grid.GetBinary().GetBuilder(outerbinObj);
+ IBinaryObjectBuilder builderInner2 = builderOuter.GetField<IBinaryObjectBuilder>("inner2");
+
+ builderInner2.SetField("outer", builderOuter);
+
+ outerbinObj = builderOuter.Build();
+
+ outer = outerbinObj.Deserialize<BuilderInBuilderOuter>();
+
+ Assert.AreSame(outer, outer.Inner.Outer);
+ Assert.AreSame(outer.Inner, outer.Inner2);
+ }
+
+ /// <summary>
+ /// Test for decimals building.
+ /// </summary>
+ [Test]
+ public void TestDecimals()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(DecimalHolder))
+ .SetField("val", decimal.One)
+ .SetField("valArr", new decimal?[] { decimal.MinusOne })
+ .Build();
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.IsTrue(meta.Fields.Contains("val"));
+ Assert.IsTrue(meta.Fields.Contains("valArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
+
+ Assert.AreEqual(decimal.One, binObj.GetField<decimal>("val"));
+ Assert.AreEqual(new decimal?[] { decimal.MinusOne }, binObj.GetField<decimal?[]>("valArr"));
+
+ DecimalHolder obj = binObj.Deserialize<DecimalHolder>();
+
+ Assert.AreEqual(decimal.One, obj.Val);
+ Assert.AreEqual(new decimal?[] { decimal.MinusOne }, obj.ValArr);
+ }
+
+ /// <summary>
+ /// Test for an object returning collection of builders.
+ /// </summary>
+ [Test]
+ public void TestBuilderCollection()
+ {
+ // Test collection with single element.
+ IBinaryObjectBuilder builderCol = _grid.GetBinary().GetBuilder(typeof(BuilderCollection));
+ IBinaryObjectBuilder builderItem =
+ _grid.GetBinary().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
+
+ builderCol.SetCollectionField("col", new ArrayList { builderItem });
+
+ IBinaryObject binCol = builderCol.Build();
+
+ IBinaryType meta = binCol.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("col", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+
+ var binColItems = binCol.GetField<ArrayList>("col");
+
+ Assert.AreEqual(1, binColItems.Count);
+
+ var binItem = (IBinaryObject) binColItems[0];
+
+ meta = binItem.GetBinaryType();
+
+ Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual("val", meta.Fields.First());
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
+
+ BuilderCollection col = binCol.Deserialize<BuilderCollection>();
+
+ Assert.IsNotNull(col.Col);
+ Assert.AreEqual(1, col.Col.Count);
+ Assert.AreEqual(1, ((BuilderCollectionItem) col.Col[0]).Val);
+
+ // Add more binary objects to collection.
+ builderCol = _grid.GetBinary().GetBuilder(binCol);
+
+ IList builderColItems = builderCol.GetField<IList>("col");
+
+ Assert.AreEqual(1, builderColItems.Count);
+
+ BinaryObjectBuilder builderColItem = (BinaryObjectBuilder) builderColItems[0];
+
+ builderColItem.SetField("val", 2); // Change nested value.
+
+ builderColItems.Add(builderColItem); // Add the same object to check handles.
+ builderColItems.Add(builderItem); // Add item from another builder.
+ builderColItems.Add(binItem); // Add item in binary form.
+
+ binCol = builderCol.Build();
+
+ col = binCol.Deserialize<BuilderCollection>();
+
+ Assert.AreEqual(4, col.Col.Count);
+
+ var item0 = (BuilderCollectionItem) col.Col[0];
+ var item1 = (BuilderCollectionItem) col.Col[1];
+ var item2 = (BuilderCollectionItem) col.Col[2];
+ var item3 = (BuilderCollectionItem) col.Col[3];
+
+ Assert.AreEqual(2, item0.Val);
+
+ Assert.AreSame(item0, item1);
+ Assert.AreNotSame(item0, item2);
+ Assert.AreNotSame(item0, item3);
+
+ Assert.AreEqual(1, item2.Val);
+ Assert.AreEqual(1, item3.Val);
+
+ Assert.AreNotSame(item2, item3);
+
+ // Test handle update inside collection.
+ builderCol = _grid.GetBinary().GetBuilder(binCol);
+
+ builderColItems = builderCol.GetField<IList>("col");
+
+ ((BinaryObjectBuilder) builderColItems[1]).SetField("val", 3);
+
+ binCol = builderCol.Build();
+
+ col = binCol.Deserialize<BuilderCollection>();
+
+ item0 = (BuilderCollectionItem) col.Col[0];
+ item1 = (BuilderCollectionItem) col.Col[1];
+
+ Assert.AreEqual(3, item0.Val);
+ Assert.AreSame(item0, item1);
+ }
+
+ /// <summary>
+ /// Test build of an empty object.
+ /// </summary>
+ [Test]
+ public void TestEmptyDefined()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
+
+ Assert.IsNotNull(binObj);
+ Assert.AreEqual(0, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.IsNotNull(meta);
+ Assert.AreEqual(typeof(Empty).Name, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+
+ Empty obj = binObj.Deserialize<Empty>();
+
+ Assert.IsNotNull(obj);
+ }
+
+ /// <summary>
+ /// Test build of an empty undefined object.
+ /// </summary>
+ [Test]
+ public void TestEmptyUndefined()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(TypeEmpty).Build();
+
+ Assert.IsNotNull(binObj);
+ Assert.AreEqual(0, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.IsNotNull(meta);
+ Assert.AreEqual(TypeEmpty, meta.TypeName);
+ Assert.AreEqual(0, meta.Fields.Count);
+ }
+
+ /// <summary>
+ /// Test object rebuild with no changes.
+ /// </summary>
+ [Test]
+ public void TestEmptyRebuild()
+ {
+ var binObj = (BinaryObject) _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
+
+ BinaryObject newbinObj = (BinaryObject) _grid.GetBinary().GetBuilder(binObj).Build();
+
+ Assert.AreEqual(binObj.Data, newbinObj.Data);
+ }
+
+ /// <summary>
+ /// Test hash code alteration.
+ /// </summary>
+ [Test]
+ public void TestHashCodeChange()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Empty)).SetHashCode(100).Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+ }
+
+ /// <summary>
+ /// Test primitive fields setting.
+ /// </summary>
+ [Test]
+ public void TestPrimitiveFields()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
+ .SetField<byte>("fByte", 1)
+ .SetField("fBool", true)
+ .SetField<short>("fShort", 2)
+ .SetField("fChar", 'a')
+ .SetField("fInt", 3)
+ .SetField<long>("fLong", 4)
+ .SetField<float>("fFloat", 5)
+ .SetField<double>("fDouble", 6)
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(BinaryTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
+
+ Assert.AreEqual(1, binObj.GetField<byte>("fByte"));
+ Assert.AreEqual(true, binObj.GetField<bool>("fBool"));
+ Assert.AreEqual(2, binObj.GetField<short>("fShort"));
+ Assert.AreEqual('a', binObj.GetField<char>("fChar"));
+ Assert.AreEqual(3, binObj.GetField<int>("fInt"));
+ Assert.AreEqual(4, binObj.GetField<long>("fLong"));
+ Assert.AreEqual(5, binObj.GetField<float>("fFloat"));
+ Assert.AreEqual(6, binObj.GetField<double>("fDouble"));
+
+ Primitives obj = binObj.Deserialize<Primitives>();
+
+ Assert.AreEqual(1, obj.FByte);
+ Assert.AreEqual(true, obj.FBool);
+ Assert.AreEqual(2, obj.FShort);
+ Assert.AreEqual('a', obj.FChar);
+ Assert.AreEqual(3, obj.FInt);
+ Assert.AreEqual(4, obj.FLong);
+ Assert.AreEqual(5, obj.FFloat);
+ Assert.AreEqual(6, obj.FDouble);
+
+ // Overwrite.
+ binObj = _grid.GetBinary().GetBuilder(binObj)
+ .SetField<byte>("fByte", 7)
+ .SetField("fBool", false)
+ .SetField<short>("fShort", 8)
+ .SetField("fChar", 'b')
+ .SetField("fInt", 9)
+ .SetField<long>("fLong", 10)
+ .SetField<float>("fFloat", 11)
+ .SetField<double>("fDouble", 12)
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ Assert.AreEqual(7, binObj.GetField<byte>("fByte"));
+ Assert.AreEqual(false, binObj.GetField<bool>("fBool"));
+ Assert.AreEqual(8, binObj.GetField<short>("fShort"));
+ Assert.AreEqual('b', binObj.GetField<char>("fChar"));
+ Assert.AreEqual(9, binObj.GetField<int>("fInt"));
+ Assert.AreEqual(10, binObj.GetField<long>("fLong"));
+ Assert.AreEqual(11, binObj.GetField<float>("fFloat"));
+ Assert.AreEqual(12, binObj.GetField<double>("fDouble"));
+
+ obj = binObj.Deserialize<Primitives>();
+
+ Assert.AreEqual(7, obj.FByte);
+ Assert.AreEqual(false, obj.FBool);
+ Assert.AreEqual(8, obj.FShort);
+ Assert.AreEqual('b', obj.FChar);
+ Assert.AreEqual(9, obj.FInt);
+ Assert.AreEqual(10, obj.FLong);
+ Assert.AreEqual(11, obj.FFloat);
+ Assert.AreEqual(12, obj.FDouble);
+ }
+
+ /// <summary>
+ /// Test primitive array fields setting.
+ /// </summary>
+ [Test]
+ public void TestPrimitiveArrayFields()
+ {
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
+ .SetField("fByte", new byte[] { 1 })
+ .SetField("fBool", new[] { true })
+ .SetField("fShort", new short[] { 2 })
+ .SetField("fChar", new[] { 'a' })
+ .SetField("fInt", new[] { 3 })
+ .SetField("fLong", new long[] { 4 })
+ .SetField("fFloat", new float[] { 5 })
+ .SetField("fDouble", new double[] { 6 })
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
+
+ Assert.AreEqual(new byte[] { 1 }, binObj.GetField<byte[]>("fByte"));
+ Assert.AreEqual(new[] { true }, binObj.GetField<bool[]>("fBool"));
+ Assert.AreEqual(new short[] { 2 }, binObj.GetField<short[]>("fShort"));
+ Assert.AreEqual(new[] { 'a' }, binObj.GetField<char[]>("fChar"));
+ Assert.AreEqual(new[] { 3 }, binObj.GetField<int[]>("fInt"));
+ Assert.AreEqual(new long[] { 4 }, binObj.GetField<long[]>("fLong"));
+ Assert.AreEqual(new float[] { 5 }, binObj.GetField<float[]>("fFloat"));
+ Assert.AreEqual(new double[] { 6 }, binObj.GetField<double[]>("fDouble"));
+
+ PrimitiveArrays obj = binObj.Deserialize<PrimitiveArrays>();
+
+ Assert.AreEqual(new byte[] { 1 }, obj.FByte);
+ Assert.AreEqual(new[] { true }, obj.FBool);
+ Assert.AreEqual(new short[] { 2 }, obj.FShort);
+ Assert.AreEqual(new[] { 'a' }, obj.FChar);
+ Assert.AreEqual(new[] { 3 }, obj.FInt);
+ Assert.AreEqual(new long[] { 4 }, obj.FLong);
+ Assert.AreEqual(new float[] { 5 }, obj.FFloat);
+ Assert.AreEqual(new double[] { 6 }, obj.FDouble);
+
+ // Overwrite.
+ binObj = _grid.GetBinary().GetBuilder(binObj)
+ .SetField("fByte", new byte[] { 7 })
+ .SetField("fBool", new[] { false })
+ .SetField("fShort", new short[] { 8 })
+ .SetField("fChar", new[] { 'b' })
+ .SetField("fInt", new[] { 9 })
+ .SetField("fLong", new long[] { 10 })
+ .SetField("fFloat", new float[] { 11 })
+ .SetField("fDouble", new double[] { 12 })
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ Assert.AreEqual(new byte[] { 7 }, binObj.GetField<byte[]>("fByte"));
+ Assert.AreEqual(new[] { false }, binObj.GetField<bool[]>("fBool"));
+ Assert.AreEqual(new short[] { 8 }, binObj.GetField<short[]>("fShort"));
+ Assert.AreEqual(new[] { 'b' }, binObj.GetField<char[]>("fChar"));
+ Assert.AreEqual(new[] { 9 }, binObj.GetField<int[]>("fInt"));
+ Assert.AreEqual(new long[] { 10 }, binObj.GetField<long[]>("fLong"));
+ Assert.AreEqual(new float[] { 11 }, binObj.GetField<float[]>("fFloat"));
+ Assert.AreEqual(new double[] { 12 }, binObj.GetField<double[]>("fDouble"));
+
+ obj = binObj.Deserialize<PrimitiveArrays>();
+
+ Assert.AreEqual(new byte[] { 7 }, obj.FByte);
+ Assert.AreEqual(new[] { false }, obj.FBool);
+ Assert.AreEqual(new short[] { 8 }, obj.FShort);
+ Assert.AreEqual(new[] { 'b' }, obj.FChar);
+ Assert.AreEqual(new[] { 9 }, obj.FInt);
+ Assert.AreEqual(new long[] { 10 }, obj.FLong);
+ Assert.AreEqual(new float[] { 11 }, obj.FFloat);
+ Assert.AreEqual(new double[] { 12 }, obj.FDouble);
+ }
+
+ /// <summary>
+ /// Test non-primitive fields and their array counterparts.
+ /// </summary>
+ [Test]
+ public void TestStringDateGuidEnum()
+ {
+ DateTime? nDate = DateTime.Now;
+
+ Guid? nGuid = Guid.NewGuid();
+
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
+ .SetField("fStr", "str")
+ .SetField("fNDate", nDate)
+ .SetGuidField("fNGuid", nGuid)
+ .SetField("fEnum", TestEnum.One)
+ .SetField("fStrArr", new[] { "str" })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetGuidArrayField("fGuidArr", new[] { nGuid })
+ .SetField("fEnumArr", new[] { TestEnum.One })
+ .SetHashCode(100)
+ .Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
+
+ Assert.AreEqual(8, meta.Fields.Count);
+
+ Assert.AreEqual(BinaryTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
+
+ Assert.AreEqual("str", binObj.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, binObj.GetField<TestEnum[]>("fEnumArr"));
+
+ StringDateGuidEnum obj = binObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str", obj.FStr);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.One, obj.FEnum);
+ Assert.AreEqual(new[] { "str" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+
+ // Check builder field caching.
+ var builder = _grid.GetBinary().GetBuilder(binObj);
+
+ Assert.AreEqual("str", builder.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, builder.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, builder.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, builder.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, builder.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, builder.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, builder.GetField<TestEnum[]>("fEnumArr"));
+
+ // Check reassemble.
+ binObj = builder.Build();
+
+ Assert.AreEqual("str", binObj.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, binObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, binObj.GetField<TestEnum[]>("fEnumArr"));
+
+ obj = binObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str", obj.FStr);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.One, obj.FEnum);
+ Assert.AreEqual(new[] { "str" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+
+ // Overwrite.
+ nDate = DateTime.Now.ToUniversalTime();
+ nGuid = Guid.NewGuid();
+
+ binObj = builder
+ .SetField("fStr", "str2")
+ .SetTimestampField("fNDate", nDate)
+ .SetField("fNGuid", nGuid)
+ .SetField("fEnum", TestEnum.Two)
+ .SetField("fStrArr", new[] { "str2" })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetField("fGuidArr", new[] { nGuid })
+ .SetField("fEnumArr", new[] { TestEnum.Two })
+ .SetHashCode(200)
+ .Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ Assert.AreEqual("str2", binObj.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, binObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, binObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.Two, binObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str2" }, binObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, binObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, binObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.Two }, binObj.GetField<TestEnum[]>("fEnumArr"));
+
+ obj = binObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str2", obj.FStr);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.Two, obj.FEnum);
+ Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
+ }
+
+ /// <summary>
+ /// Test arrays.
+ /// </summary>
+ [Test]
+ public void TestCompositeArray()
+ {
+ // 1. Test simple array.
+ object[] inArr = { new CompositeInner(1) };
+
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("inArr", inArr).Build();
+
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ var binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(1, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+
+ CompositeArray arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(1, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
+
+ // 2. Test addition to array.
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+ .SetField("inArr", new object[] { binInArr[0], null }).Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+ Assert.IsNull(binInArr[1]);
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
+ Assert.IsNull(arr.InArr[1]);
+
+ binInArr[1] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(300)
+ .SetField("inArr", binInArr.OfType<object>().ToArray()).Build();
+
+ Assert.AreEqual(300, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+ Assert.AreEqual(2, binInArr[1].GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(2, ((CompositeInner)arr.InArr[1]).Val);
+
+ // 3. Test top-level handle inversion.
+ CompositeInner inner = new CompositeInner(1);
+
+ inArr = new object[] { inner, inner };
+
+ binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("inArr", inArr).Build();
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(1, binInArr[0].GetField<int>("val"));
+ Assert.AreEqual(1, binInArr[1].GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
+
+ binInArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+ .SetField("inArr", binInArr.ToArray<object>()).Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(2, binInArr[0].GetField<int>("val"));
+ Assert.AreEqual(1, binInArr[1].GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.OutArr);
+ Assert.AreEqual(2, arr.InArr.Length);
+ Assert.AreEqual(2, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
+
+ // 4. Test nested object handle inversion.
+ CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
+
+ binObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
+ .SetField("outArr", outArr.ToArray<object>()).Build();
+
+ meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
+
+ Assert.AreEqual(100, binObj.GetHashCode());
+
+ var binOutArr = binObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binOutArr.Length);
+ Assert.AreEqual(1, binOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
+ Assert.AreEqual(1, binOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.InArr);
+ Assert.AreEqual(2, arr.OutArr.Length);
+ Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
+ Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
+
+ binOutArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeOuter))
+ .SetField("inner", new CompositeInner(2)).Build();
+
+ binObj = _grid.GetBinary().GetBuilder(binObj).SetHashCode(200)
+ .SetField("outArr", binOutArr.ToArray<object>()).Build();
+
+ Assert.AreEqual(200, binObj.GetHashCode());
+
+ binInArr = binObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
+
+ Assert.AreEqual(2, binInArr.Length);
+ Assert.AreEqual(2, binOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
+ Assert.AreEqual(1, binOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
+
+ arr = binObj.Deserialize<CompositeArray>();
+
+ Assert.IsNull(arr.InArr);
+ Assert.AreEqual(2, arr.OutArr.Length);
+ Assert.AreEqual(2, ((CompositeOuter)arr.OutArr[0]).Inner.Val);
+ Assert.AreEqual(1, ((CompositeOuter)arr.OutArr[1]).Inner.Val);
+ }
+
+ /// <summary>
+ /// Test container types other than array.
+ /// </summary>
+ [Test]
+ public void TestCompositeContainer()
+ {
+ ArrayList col = new ArrayList();
+ IDictionary dict = new Hashtable();
+
+ col.Add(new CompositeInner(1));
+ dict[3] = new CompositeInner(3);
+
+ IBinaryObject binObj = _grid.GetBinary().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
+ .SetCollectionField("col", col)
+ .SetDictionaryField("dict", dict).Build();
+
+ // 1. Check meta.
+ IBinaryType meta = binObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
+
+ Assert.AreEqual(2, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
+ Assert.AreEqual(BinaryTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
+
+ // 2. Check in binary form.
+ Assert.AreEqual(1, binObj.GetField<ICollection>("col").Count);
+ Assert.AreEqual(1, binObj.GetField<ICollection>("col").OfType<IBinaryObject>().First()
+ .GetField<int>("val"));
+
+ Assert.AreEqual(1, binObj.GetField<IDictionary>("dict").Count);
+ Assert.AreEqual(3, ((IBinaryObject) binObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
+
+ // 3. Check in deserialized form.
+ CompositeContainer obj = binObj.Deserialize<CompositeContainer>();
+
+ Assert.AreEqual(1, obj.Col.Count);
+ Assert.AreEqual(1, obj.Col.OfType<CompositeInner>().First().Val);
+
+ Assert.AreEqual(1, obj.Dict.Count);
+ Assert.AreEqual(3, ((CompositeInner) obj.Dict[3]).Val);
+ }
+
+ /// <summary>
+ /// Ensure that raw data is not lost during build.
+ /// </summary>
+ [Test]
+ public void TestRawData()
+ {
+ var raw = new WithRaw
+ {
+ A = 1,
+ B = 2
+ };
+
+ var binObj = _marsh.Unmarshal<IBinaryObject>(_marsh.Marshal(raw), BinaryMode.ForceBinary);
+
+ raw = binObj.Deserialize<WithRaw>();
+
+ Assert.AreEqual(1, raw.A);
+ Assert.AreEqual(2, raw.B);
+
+ IBinaryObject newbinObj = _grid.GetBinary().GetBuilder(binObj).SetField("a", 3).Build();
+
+ raw = newbinObj.Deserialize<WithRaw>();
+
+ Assert.AreEqual(3, raw.A);
+ Assert.AreEqual(2, raw.B);
+ }
+
+ /// <summary>
+ /// Test nested objects.
+ /// </summary>
+ [Test]
+ public void TestNested()
+ {
+ // 1. Create from scratch.
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(NestedOuter));
+
+ NestedInner inner1 = new NestedInner {Val = 1};
+ builder.SetField("inner1", inner1);
+
+ IBinaryObject outerbinObj = builder.Build();
+
+ IBinaryType meta = outerbinObj.GetBinaryType();
+
+ Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName);
+ Assert.AreEqual(1, meta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
+
+ IBinaryObject innerbinObj1 = outerbinObj.GetField<IBinaryObject>("inner1");
+
+ IBinaryType innerMeta = innerbinObj1.GetBinaryType();
+
+ Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName);
+ Assert.AreEqual(1, innerMeta.Fields.Count);
+ Assert.AreEqual(BinaryTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
+
+ inner1 = innerbinObj1.Deserialize<NestedInner>();
+
+ Assert.AreEqual(1, inner1.Val);
+
+ NestedOuter outer = outerbinObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(outer.Inner1.Val, 1);
+ Assert.IsNull(outer.Inner2);
+
+ // 2. Add another field over existing binary object.
+ builder = _grid.GetBinary().GetBuilder(outerbinObj);
+
+ NestedInner inner2 = new NestedInner {Val = 2};
+ builder.SetField("inner2", inner2);
+
+ outerbinObj = builder.Build();
+
+ outer = outerbinObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(1, outer.Inner1.Val);
+ Assert.AreEqual(2, outer.Inner2.Val);
+
+ // 3. Try setting inner object in binary form.
+ innerbinObj1 = _grid.GetBinary().GetBuilder(innerbinObj1).SetField("val", 3).Build();
+
+ inner1 = innerbinObj1.Deserialize<NestedInner>();
+
+ Assert.AreEqual(3, inner1.Val);
+
+ outerbinObj = _grid.GetBinary().GetBuilder(outerbinObj).SetField<object>("inner1", innerbinObj1).Build();
+
+ outer = outerbinObj.Deserialize<NestedOuter>();
+ Assert.AreEqual(3, outer.Inner1.Val);
+ Assert.AreEqual(2, outer.Inner2.Val);
+ }
+
+ /// <summary>
+ /// Test handle migration.
+ /// </summary>
+ [Test]
+ public void TestHandleMigration()
+ {
+ // 1. Simple comparison of results.
+ MigrationInner inner = new MigrationInner {Val = 1};
+
+ MigrationOuter outer = new MigrationOuter
+ {
+ Inner1 = inner,
+ Inner2 = inner
+ };
+
+ byte[] outerBytes = _marsh.Marshal(outer);
+
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(MigrationOuter));
+
+ builder.SetHashCode(outer.GetHashCode());
+
+ builder.SetField<object>("inner1", inner);
+ builder.SetField<object>("inner2", inner);
+
+ BinaryObject portOuter = (BinaryObject) builder.Build();
+
+ byte[] portOuterBytes = new byte[outerBytes.Length];
+
+ Buffer.BlockCopy(portOuter.Data, 0, portOuterBytes, 0, portOuterBytes.Length);
+
+ Assert.AreEqual(outerBytes, portOuterBytes);
+
+ // 2. Change the first inner object so that the handle must migrate.
+ MigrationInner inner1 = new MigrationInner {Val = 2};
+
+ IBinaryObject portOuterMigrated =
+ _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
+
+ MigrationOuter outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
+
+ Assert.AreEqual(2, outerMigrated.Inner1.Val);
+ Assert.AreEqual(1, outerMigrated.Inner2.Val);
+
+ // 3. Change the first value using serialized form.
+ IBinaryObject inner1Port =
+ _grid.GetBinary().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
+
+ portOuterMigrated =
+ _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
+
+ outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
+
+ Assert.AreEqual(2, outerMigrated.Inner1.Val);
+ Assert.AreEqual(1, outerMigrated.Inner2.Val);
+ }
+
+ /// <summary>
+ /// Test handle inversion.
+ /// </summary>
+ [Test]
+ public void TestHandleInversion()
+ {
+ InversionInner inner = new InversionInner();
+ InversionOuter outer = new InversionOuter();
+
+ inner.Outer = outer;
+ outer.Inner = inner;
+
+ byte[] rawOuter = _marsh.Marshal(outer);
+
+ IBinaryObject portOuter = _marsh.Unmarshal<IBinaryObject>(rawOuter, BinaryMode.ForceBinary);
+ IBinaryObject portInner = portOuter.GetField<IBinaryObject>("inner");
+
+ // 1. Ensure that inner object can be deserialized after build.
+ IBinaryObject portInnerNew = _grid.GetBinary().GetBuilder(portInner).Build();
+
+ InversionInner innerNew = portInnerNew.Deserialize<InversionInner>();
+
+ Assert.AreSame(innerNew, innerNew.Outer.Inner);
+
+ // 2. Ensure that binary object with external dependencies could be added to builder.
+ IBinaryObject portOuterNew =
+ _grid.GetBinary().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
+
+ InversionOuter outerNew = portOuterNew.Deserialize<InversionOuter>();
+
+ Assert.AreNotSame(outerNew, outerNew.Inner.Outer);
+ Assert.AreSame(outerNew.Inner, outerNew.Inner.Outer.Inner);
+ }
+
+ /// <summary>
+ /// Test build multiple objects.
+ /// </summary>
+ [Test]
+ public void TestBuildMultiple()
+ {
+ IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(Primitives));
+
+ builder.SetField<byte>("fByte", 1).SetField("fBool", true);
+
+ IBinaryObject po1 = builder.Build();
+ IBinaryObject po2 = builder.Build();
+
+ Assert.AreEqual(1, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(1, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ builder.SetField<byte>("fByte", 2);
+
+ IBinaryObject po3 = builder.Build();
+
+ Assert.AreEqual(1, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(1, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ Assert.AreEqual(2, po3.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ builder = _grid.GetBinary().GetBuilder(po1);
+
+ builder.SetField<byte>("fByte", 10);
+
+ po1 = builder.Build();
+ po2 = builder.Build();
+
+ builder.SetField<byte>("fByte", 20);
+
+ po3 = builder.Build();
+
+ Assert.AreEqual(10, po1.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po1.GetField<bool>("fBool"));
+
+ Assert.AreEqual(10, po2.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po2.GetField<bool>("fBool"));
+
+ Assert.AreEqual(20, po3.GetField<byte>("fByte"));
+ Assert.AreEqual(true, po3.GetField<bool>("fBool"));
+ }
+
+ /// <summary>
+ /// Tests type id method.
+ /// </summary>
+ [Test]
+ public void TestTypeId()
+ {
+ Assert.Throws<ArgumentException>(() => _grid.GetBinary().GetTypeId(null));
+
+ Assert.AreEqual(IdMapper.TestTypeId, _grid.GetBinary().GetTypeId(IdMapper.TestTypeName));
+
+ Assert.AreEqual(BinaryUtils.GetStringHashCode("someTypeName"), _grid.GetBinary().GetTypeId("someTypeName"));
+ }
+
+ /// <summary>
+ /// Tests metadata methods.
+ /// </summary>
+ [Test]
+ public void TestMetadata()
+ {
+ // Populate metadata
+ var binary = _grid.GetBinary();
+
+ binary.ToBinary<IBinaryObject>(new DecimalHolder());
+
+ // All meta
+ var allMetas = binary.GetBinaryTypes();
+
+ var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder");
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type
+ decimalMeta = binary.GetBinaryType(typeof (DecimalHolder));
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type id
+ decimalMeta = binary.GetBinaryType(binary.GetTypeId("DecimalHolder"));
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+
+ // By type name
+ decimalMeta = binary.GetBinaryType("DecimalHolder");
+
+ Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
+ }
+ }
+
+ /// <summary>
+ /// Empty binary class.
+ /// </summary>
+ public class Empty
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// binary with primitive fields.
+ /// </summary>
+ public class Primitives
+ {
+ public byte FByte;
+ public bool FBool;
+ public short FShort;
+ public char FChar;
+ public int FInt;
+ public long FLong;
+ public float FFloat;
+ public double FDouble;
+ }
+
+ /// <summary>
+ /// binary with primitive array fields.
+ /// </summary>
+ public class PrimitiveArrays
+ {
+ public byte[] FByte;
+ public bool[] FBool;
+ public short[] FShort;
+ public char[] FChar;
+ public int[] FInt;
+ public long[] FLong;
+ public float[] FFloat;
+ public double[] FDouble;
+ }
+
+ /// <summary>
+ /// binary having strings, dates, Guids and enums.
+ /// </summary>
+ public class StringDateGuidEnum
+ {
+ public string FStr;
+ public DateTime? FnDate;
+ public Guid? FnGuid;
+ public TestEnum FEnum;
+
+ public string[] FStrArr;
+ public DateTime?[] FDateArr;
+ public Guid?[] FGuidArr;
+ public TestEnum[] FEnumArr;
+ }
+
+ /// <summary>
+ /// Enumeration.
+ /// </summary>
+ public enum TestEnum
+ {
+ One, Two
+ }
+
+ /// <summary>
+ /// binary with raw data.
+ /// </summary>
+ public class WithRaw : IBinarizable
+ {
+ public int A;
+ public int B;
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteInt("a", A);
+ writer.GetRawWriter().WriteInt(B);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ A = reader.ReadInt("a");
+ B = reader.GetRawReader().ReadInt();
+ }
+ }
+
+ /// <summary>
+ /// Empty class for metadata overwrite test.
+ /// </summary>
+ public class MetaOverwrite
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Nested outer object.
+ /// </summary>
+ public class NestedOuter
+ {
+ public NestedInner Inner1;
+ public NestedInner Inner2;
+ }
+
+ /// <summary>
+ /// Nested inner object.
+ /// </summary>
+ public class NestedInner
+ {
+ public int Val;
+ }
+
+ /// <summary>
+ /// Outer object for handle migration test.
+ /// </summary>
+ public class MigrationOuter
+ {
+ public MigrationInner Inner1;
+ public MigrationInner Inner2;
+ }
+
+ /// <summary>
+ /// Inner object for handle migration test.
+ /// </summary>
+ public class MigrationInner
+ {
+ public int Val;
+ }
+
+ /// <summary>
+ /// Outer object for handle inversion test.
+ /// </summary>
+ public class InversionOuter
+ {
+ public InversionInner Inner;
+ }
+
+ /// <summary>
+ /// Inner object for handle inversion test.
+ /// </summary>
+ public class InversionInner
+ {
+ public InversionOuter Outer;
+ }
+
+ /// <summary>
+ /// Object for composite array tests.
+ /// </summary>
+ public class CompositeArray
+ {
+ public object[] InArr;
+ public object[] OutArr;
+ }
+
+ /// <summary>
+ /// Object for composite collection/dictionary tests.
+ /// </summary>
+ public class CompositeContainer
+ {
+ public ICollection Col;
+ public IDictionary Dict;
+ }
+
+ /// <summary>
+ /// OUter object for composite structures test.
+ /// </summary>
+ public class CompositeOuter
+ {
+ public CompositeInner Inner;
+
+ public CompositeOuter()
+ {
+ // No-op.
+ }
+
+ public CompositeOuter(CompositeInner inner)
+ {
+ Inner = inner;
+ }
+ }
+
+ /// <summary>
+ /// Inner object for composite structures test.
+ /// </summary>
+ public class CompositeInner
+ {
+ public int Val;
+
+ public CompositeInner()
+ {
+ // No-op.
+ }
+
+ public CompositeInner(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ /// Type to test "ToBinary()" logic.
+ /// </summary>
+ public class ToBinary
+ {
+ public int Val;
+
+ public ToBinary(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ /// Type to test removal.
+ /// </summary>
+ public class Remove
+ {
+ public object Val;
+ public RemoveInner Val2;
+ }
+
+ /// <summary>
+ /// Inner type to test removal.
+ /// </summary>
+ public class RemoveInner
+ {
+ /** */
+ public int Val;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="val"></param>
+ public RemoveInner(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderInBuilderOuter
+ {
+ /** */
+ public BuilderInBuilderInner Inner;
+
+ /** */
+ public BuilderInBuilderInner Inner2;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderInBuilderInner
+ {
+ /** */
+ public BuilderInBuilderOuter Outer;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderCollection
+ {
+ /** */
+ public readonly ArrayList Col;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="col"></param>
+ public BuilderCollection(ArrayList col)
+ {
+ Col = col;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class BuilderCollectionItem
+ {
+ /** */
+ public int Val;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="val"></param>
+ public BuilderCollectionItem(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public class DecimalHolder
+ {
+ /** */
+ public decimal Val;
+
+ /** */
+ public decimal?[] ValArr;
+ }
+
+ /// <summary>
+ /// Test id mapper.
+ /// </summary>
+ public class IdMapper : IBinaryIdMapper
+ {
+ /** */
+ public const string TestTypeName = "IdMapperTestType";
+
+ /** */
+ public const int TestTypeId = -65537;
+
+ /** <inheritdoc /> */
+ public int GetTypeId(string typeName)
+ {
+ return typeName == TestTypeName ? TestTypeId : 0;
+ }
+
+ /** <inheritdoc /> */
+ public int GetFieldId(int typeId, string fieldName)
+ {
+ return 0;
+ }
+ }
+}
[15/55] [abbrv] ignite git commit: IGNITE-1816: Implemented compact
footers.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
deleted file mode 100644
index d0a5709..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ /dev/null
@@ -1,3760 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.InetSocketAddress;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListSet;
-import junit.framework.Assert;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawReader;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinarySerializer;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.jsr166.ConcurrentHashMap8;
-import sun.misc.Unsafe;
-
-import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
-import static org.junit.Assert.assertArrayEquals;
-
-/**
- * Portable marshaller tests.
- */
-@SuppressWarnings({"OverlyStrongTypeCast", "ArrayHashCode", "ConstantConditions"})
-public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
- /** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /**
- * @throws Exception If failed.
- */
- public void testNull() throws Exception {
- assertNull(marshalUnmarshal(null));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testByte() throws Exception {
- assertEquals((byte)100, marshalUnmarshal((byte)100).byteValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testShort() throws Exception {
- assertEquals((short)100, marshalUnmarshal((short)100).shortValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testInt() throws Exception {
- assertEquals(100, marshalUnmarshal(100).intValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLong() throws Exception {
- assertEquals(100L, marshalUnmarshal(100L).longValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testFloat() throws Exception {
- assertEquals(100.001f, marshalUnmarshal(100.001f).floatValue(), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDouble() throws Exception {
- assertEquals(100.001d, marshalUnmarshal(100.001d).doubleValue(), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testChar() throws Exception {
- assertEquals((char)100, marshalUnmarshal((char)100).charValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBoolean() throws Exception {
- assertEquals(true, marshalUnmarshal(true).booleanValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDecimal() throws Exception {
- BigDecimal val;
-
- assertEquals((val = BigDecimal.ZERO), marshalUnmarshal(val));
- assertEquals((val = BigDecimal.valueOf(Long.MAX_VALUE, 0)), marshalUnmarshal(val));
- assertEquals((val = BigDecimal.valueOf(Long.MIN_VALUE, 0)), marshalUnmarshal(val));
- assertEquals((val = BigDecimal.valueOf(Long.MAX_VALUE, 8)), marshalUnmarshal(val));
- assertEquals((val = BigDecimal.valueOf(Long.MIN_VALUE, 8)), marshalUnmarshal(val));
-
- assertEquals((val = new BigDecimal(new BigInteger("-79228162514264337593543950336"))), marshalUnmarshal(val));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testString() throws Exception {
- assertEquals("str", marshalUnmarshal("str"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUuid() throws Exception {
- UUID uuid = UUID.randomUUID();
-
- assertEquals(uuid, marshalUnmarshal(uuid));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDate() throws Exception {
- Date date = new Date();
-
- Date val = marshalUnmarshal(date);
-
- assertEquals(date, val);
- assertEquals(Date.class, val.getClass());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTimestamp() throws Exception {
- Timestamp ts = new Timestamp(System.currentTimeMillis());
-
- ts.setNanos(999999999);
-
- assertEquals(ts, marshalUnmarshal(ts));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testByteArray() throws Exception {
- byte[] arr = new byte[] {10, 20, 30};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testShortArray() throws Exception {
- short[] arr = new short[] {10, 20, 30};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testIntArray() throws Exception {
- int[] arr = new int[] {10, 20, 30};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLongArray() throws Exception {
- long[] arr = new long[] {10, 20, 30};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testFloatArray() throws Exception {
- float[] arr = new float[] {10.1f, 20.1f, 30.1f};
-
- assertArrayEquals(arr, marshalUnmarshal(arr), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDoubleArray() throws Exception {
- double[] arr = new double[] {10.1d, 20.1d, 30.1d};
-
- assertArrayEquals(arr, marshalUnmarshal(arr), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCharArray() throws Exception {
- char[] arr = new char[] {10, 20, 30};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBooleanArray() throws Exception {
- boolean[] arr = new boolean[] {true, false, true};
-
- assertBooleanArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDecimalArray() throws Exception {
- BigDecimal[] arr = new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN } ;
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testStringArray() throws Exception {
- String[] arr = new String[] {"str1", "str2", "str3"};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUuidArray() throws Exception {
- UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDateArray() throws Exception {
- Date[] arr = new Date[] {new Date(11111), new Date(22222), new Date(33333)};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testObjectArray() throws Exception {
- Object[] arr = new Object[] {1, 2, 3};
-
- assertArrayEquals(arr, marshalUnmarshal(arr));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCollection() throws Exception {
- testCollection(new ArrayList<Integer>(3));
- testCollection(new LinkedHashSet<Integer>());
- testCollection(new HashSet<Integer>());
- testCollection(new TreeSet<Integer>());
- testCollection(new ConcurrentSkipListSet<Integer>());
- }
-
- /**
- * @throws Exception If failed.
- */
- private void testCollection(Collection<Integer> col) throws Exception {
- col.add(1);
- col.add(2);
- col.add(3);
-
- assertEquals(col, marshalUnmarshal(col));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMap() throws Exception {
- testMap(new HashMap<Integer, String>());
- testMap(new LinkedHashMap());
- testMap(new TreeMap<Integer, String>());
- testMap(new ConcurrentHashMap8<Integer, String>());
- testMap(new ConcurrentHashMap<Integer, String>());
- }
-
- /**
- * @throws Exception If failed.
- */
- private void testMap(Map<Integer, String> map) throws Exception {
- map.put(1, "str1");
- map.put(2, "str2");
- map.put(3, "str3");
-
- assertEquals(map, marshalUnmarshal(map));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMapEntry() throws Exception {
- Map.Entry<Integer, String> e = new GridMapEntry<>(1, "str1");
-
- assertEquals(e, marshalUnmarshal(e));
-
- Map<Integer, String> map = new HashMap<>(1);
-
- map.put(2, "str2");
-
- e = F.firstEntry(map);
-
- Map.Entry<Integer, String> e0 = marshalUnmarshal(e);
-
- assertEquals(2, e0.getKey().intValue());
- assertEquals("str2", e0.getValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBinaryObject() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject po0 = marshalUnmarshal(po, marsh);
-
- assertTrue(po.hasField("b"));
- assertTrue(po.hasField("s"));
- assertTrue(po.hasField("i"));
- assertTrue(po.hasField("l"));
- assertTrue(po.hasField("f"));
- assertTrue(po.hasField("d"));
- assertTrue(po.hasField("c"));
- assertTrue(po.hasField("bool"));
-
- assertFalse(po.hasField("no_such_field"));
-
- assertEquals(obj, po.deserialize());
- assertEquals(obj, po0.deserialize());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testEnum() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setClassNames(Arrays.asList(TestEnum.class.getName()));
-
- assertEquals(TestEnum.B, marshalUnmarshal(TestEnum.B, marsh));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDateAndTimestampInSingleObject() throws Exception {
- BinaryTypeConfiguration cfg1 = new BinaryTypeConfiguration(DateClass1.class.getName());
-
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(cfg1));
-
- Date date = new Date();
- Timestamp ts = new Timestamp(System.currentTimeMillis());
-
- DateClass1 obj1 = new DateClass1();
- obj1.date = date;
- obj1.ts = ts;
-
- BinaryObject po1 = marshal(obj1, marsh);
-
- assertEquals(date, po1.field("date"));
- assertEquals(Date.class, po1.field("date").getClass());
- assertEquals(ts, po1.field("ts"));
- assertEquals(Timestamp.class, po1.field("ts").getClass());
-
- obj1 = po1.deserialize();
- assertEquals(date, obj1.date);
- assertEquals(ts, obj1.ts);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSimpleObject() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- assertEquals(obj.hashCode(), po.hashCode());
-
- assertEquals(obj, po.deserialize());
-
- assertEquals(obj.b, (byte)po.field("b"));
- assertEquals(obj.s, (short)po.field("s"));
- assertEquals(obj.i, (int)po.field("i"));
- assertEquals(obj.l, (long)po.field("l"));
- assertEquals(obj.f, (float)po.field("f"), 0);
- assertEquals(obj.d, (double)po.field("d"), 0);
- assertEquals(obj.c, (char)po.field("c"));
- assertEquals(obj.bool, (boolean)po.field("bool"));
- assertEquals(obj.str, po.field("str"));
- assertEquals(obj.uuid, po.field("uuid"));
- assertEquals(obj.date, po.field("date"));
- assertEquals(Date.class, obj.date.getClass());
- assertEquals(obj.ts, po.field("ts"));
- assertArrayEquals(obj.bArr, (byte[])po.field("bArr"));
- assertArrayEquals(obj.sArr, (short[])po.field("sArr"));
- assertArrayEquals(obj.iArr, (int[])po.field("iArr"));
- assertArrayEquals(obj.lArr, (long[])po.field("lArr"));
- assertArrayEquals(obj.fArr, (float[])po.field("fArr"), 0);
- assertArrayEquals(obj.dArr, (double[])po.field("dArr"), 0);
- assertArrayEquals(obj.cArr, (char[])po.field("cArr"));
- assertBooleanArrayEquals(obj.boolArr, (boolean[])po.field("boolArr"));
- assertArrayEquals(obj.strArr, (String[])po.field("strArr"));
- assertArrayEquals(obj.uuidArr, (UUID[])po.field("uuidArr"));
- assertArrayEquals(obj.dateArr, (Date[])po.field("dateArr"));
- assertArrayEquals(obj.objArr, (Object[])po.field("objArr"));
- assertEquals(obj.col, po.field("col"));
- assertEquals(obj.map, po.field("map"));
- assertEquals(new Integer(obj.enumVal.ordinal()), new Integer(((Enum<?>)po.field("enumVal")).ordinal()));
- assertArrayEquals(ordinals(obj.enumArr), ordinals((Enum<?>[])po.field("enumArr")));
- assertNull(po.field("unknown"));
-
- BinaryObject innerPo = po.field("inner");
-
- assertEquals(obj.inner, innerPo.deserialize());
-
- assertEquals(obj.inner.b, (byte)innerPo.field("b"));
- assertEquals(obj.inner.s, (short)innerPo.field("s"));
- assertEquals(obj.inner.i, (int)innerPo.field("i"));
- assertEquals(obj.inner.l, (long)innerPo.field("l"));
- assertEquals(obj.inner.f, (float)innerPo.field("f"), 0);
- assertEquals(obj.inner.d, (double)innerPo.field("d"), 0);
- assertEquals(obj.inner.c, (char)innerPo.field("c"));
- assertEquals(obj.inner.bool, (boolean)innerPo.field("bool"));
- assertEquals(obj.inner.str, innerPo.field("str"));
- assertEquals(obj.inner.uuid, innerPo.field("uuid"));
- assertEquals(obj.inner.date, innerPo.field("date"));
- assertEquals(Date.class, obj.inner.date.getClass());
- assertEquals(obj.inner.ts, innerPo.field("ts"));
- assertArrayEquals(obj.inner.bArr, (byte[])innerPo.field("bArr"));
- assertArrayEquals(obj.inner.sArr, (short[])innerPo.field("sArr"));
- assertArrayEquals(obj.inner.iArr, (int[])innerPo.field("iArr"));
- assertArrayEquals(obj.inner.lArr, (long[])innerPo.field("lArr"));
- assertArrayEquals(obj.inner.fArr, (float[])innerPo.field("fArr"), 0);
- assertArrayEquals(obj.inner.dArr, (double[])innerPo.field("dArr"), 0);
- assertArrayEquals(obj.inner.cArr, (char[])innerPo.field("cArr"));
- assertBooleanArrayEquals(obj.inner.boolArr, (boolean[])innerPo.field("boolArr"));
- assertArrayEquals(obj.inner.strArr, (String[])innerPo.field("strArr"));
- assertArrayEquals(obj.inner.uuidArr, (UUID[])innerPo.field("uuidArr"));
- assertArrayEquals(obj.inner.dateArr, (Date[])innerPo.field("dateArr"));
- assertArrayEquals(obj.inner.objArr, (Object[])innerPo.field("objArr"));
- assertEquals(obj.inner.col, innerPo.field("col"));
- assertEquals(obj.inner.map, innerPo.field("map"));
- assertEquals(new Integer(obj.inner.enumVal.ordinal()),
- new Integer(((Enum<?>)innerPo.field("enumVal")).ordinal()));
- assertArrayEquals(ordinals(obj.inner.enumArr), ordinals((Enum<?>[])innerPo.field("enumArr")));
- assertNull(innerPo.field("inner"));
- assertNull(innerPo.field("unknown"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortable() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName()),
- new BinaryTypeConfiguration(TestBinary.class.getName())
- ));
-
- TestBinary obj = BinaryObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- assertEquals(obj.hashCode(), po.hashCode());
-
- assertEquals(obj, po.deserialize());
-
- assertEquals(obj.b, (byte)po.field("_b"));
- assertEquals(obj.s, (short)po.field("_s"));
- assertEquals(obj.i, (int)po.field("_i"));
- assertEquals(obj.l, (long)po.field("_l"));
- assertEquals(obj.f, (float)po.field("_f"), 0);
- assertEquals(obj.d, (double)po.field("_d"), 0);
- assertEquals(obj.c, (char)po.field("_c"));
- assertEquals(obj.bool, (boolean)po.field("_bool"));
- assertEquals(obj.str, po.field("_str"));
- assertEquals(obj.uuid, po.field("_uuid"));
- assertEquals(obj.date, po.field("_date"));
- assertEquals(obj.ts, po.field("_ts"));
- assertArrayEquals(obj.bArr, (byte[])po.field("_bArr"));
- assertArrayEquals(obj.sArr, (short[])po.field("_sArr"));
- assertArrayEquals(obj.iArr, (int[])po.field("_iArr"));
- assertArrayEquals(obj.lArr, (long[])po.field("_lArr"));
- assertArrayEquals(obj.fArr, (float[])po.field("_fArr"), 0);
- assertArrayEquals(obj.dArr, (double[])po.field("_dArr"), 0);
- assertArrayEquals(obj.cArr, (char[])po.field("_cArr"));
- assertBooleanArrayEquals(obj.boolArr, (boolean[])po.field("_boolArr"));
- assertArrayEquals(obj.strArr, (String[])po.field("_strArr"));
- assertArrayEquals(obj.uuidArr, (UUID[])po.field("_uuidArr"));
- assertArrayEquals(obj.dateArr, (Date[])po.field("_dateArr"));
- assertArrayEquals(obj.objArr, (Object[])po.field("_objArr"));
- assertEquals(obj.col, po.field("_col"));
- assertEquals(obj.map, po.field("_map"));
- assertEquals(new Integer(obj.enumVal.ordinal()), new Integer(((Enum<?>)po.field("_enumVal")).ordinal()));
- assertArrayEquals(ordinals(obj.enumArr), ordinals((Enum<?>[])po.field("_enumArr")));
- assertNull(po.field("unknown"));
-
- BinaryObject simplePo = po.field("_simple");
-
- assertEquals(obj.simple, simplePo.deserialize());
-
- assertEquals(obj.simple.b, (byte)simplePo.field("b"));
- assertEquals(obj.simple.s, (short)simplePo.field("s"));
- assertEquals(obj.simple.i, (int)simplePo.field("i"));
- assertEquals(obj.simple.l, (long)simplePo.field("l"));
- assertEquals(obj.simple.f, (float)simplePo.field("f"), 0);
- assertEquals(obj.simple.d, (double)simplePo.field("d"), 0);
- assertEquals(obj.simple.c, (char)simplePo.field("c"));
- assertEquals(obj.simple.bool, (boolean)simplePo.field("bool"));
- assertEquals(obj.simple.str, simplePo.field("str"));
- assertEquals(obj.simple.uuid, simplePo.field("uuid"));
- assertEquals(obj.simple.date, simplePo.field("date"));
- assertEquals(Date.class, obj.simple.date.getClass());
- assertEquals(obj.simple.ts, simplePo.field("ts"));
- assertArrayEquals(obj.simple.bArr, (byte[])simplePo.field("bArr"));
- assertArrayEquals(obj.simple.sArr, (short[])simplePo.field("sArr"));
- assertArrayEquals(obj.simple.iArr, (int[])simplePo.field("iArr"));
- assertArrayEquals(obj.simple.lArr, (long[])simplePo.field("lArr"));
- assertArrayEquals(obj.simple.fArr, (float[])simplePo.field("fArr"), 0);
- assertArrayEquals(obj.simple.dArr, (double[])simplePo.field("dArr"), 0);
- assertArrayEquals(obj.simple.cArr, (char[])simplePo.field("cArr"));
- assertBooleanArrayEquals(obj.simple.boolArr, (boolean[])simplePo.field("boolArr"));
- assertArrayEquals(obj.simple.strArr, (String[])simplePo.field("strArr"));
- assertArrayEquals(obj.simple.uuidArr, (UUID[])simplePo.field("uuidArr"));
- assertArrayEquals(obj.simple.dateArr, (Date[])simplePo.field("dateArr"));
- assertArrayEquals(obj.simple.objArr, (Object[])simplePo.field("objArr"));
- assertEquals(obj.simple.col, simplePo.field("col"));
- assertEquals(obj.simple.map, simplePo.field("map"));
- assertEquals(new Integer(obj.simple.enumVal.ordinal()),
- new Integer(((Enum<?>)simplePo.field("enumVal")).ordinal()));
- assertArrayEquals(ordinals(obj.simple.enumArr), ordinals((Enum<?>[])simplePo.field("enumArr")));
- assertNull(simplePo.field("simple"));
- assertNull(simplePo.field("portable"));
- assertNull(simplePo.field("unknown"));
-
- BinaryObject portablePo = po.field("_portable");
-
- assertEquals(obj.portable, portablePo.deserialize());
-
- assertEquals(obj.portable.b, (byte)portablePo.field("_b"));
- assertEquals(obj.portable.s, (short)portablePo.field("_s"));
- assertEquals(obj.portable.i, (int)portablePo.field("_i"));
- assertEquals(obj.portable.l, (long)portablePo.field("_l"));
- assertEquals(obj.portable.f, (float)portablePo.field("_f"), 0);
- assertEquals(obj.portable.d, (double)portablePo.field("_d"), 0);
- assertEquals(obj.portable.c, (char)portablePo.field("_c"));
- assertEquals(obj.portable.bool, (boolean)portablePo.field("_bool"));
- assertEquals(obj.portable.str, portablePo.field("_str"));
- assertEquals(obj.portable.uuid, portablePo.field("_uuid"));
- assertEquals(obj.portable.date, portablePo.field("_date"));
- assertEquals(obj.portable.ts, portablePo.field("_ts"));
- assertArrayEquals(obj.portable.bArr, (byte[])portablePo.field("_bArr"));
- assertArrayEquals(obj.portable.sArr, (short[])portablePo.field("_sArr"));
- assertArrayEquals(obj.portable.iArr, (int[])portablePo.field("_iArr"));
- assertArrayEquals(obj.portable.lArr, (long[])portablePo.field("_lArr"));
- assertArrayEquals(obj.portable.fArr, (float[])portablePo.field("_fArr"), 0);
- assertArrayEquals(obj.portable.dArr, (double[])portablePo.field("_dArr"), 0);
- assertArrayEquals(obj.portable.cArr, (char[])portablePo.field("_cArr"));
- assertBooleanArrayEquals(obj.portable.boolArr, (boolean[])portablePo.field("_boolArr"));
- assertArrayEquals(obj.portable.strArr, (String[])portablePo.field("_strArr"));
- assertArrayEquals(obj.portable.uuidArr, (UUID[])portablePo.field("_uuidArr"));
- assertArrayEquals(obj.portable.dateArr, (Date[])portablePo.field("_dateArr"));
- assertArrayEquals(obj.portable.objArr, (Object[])portablePo.field("_objArr"));
- assertEquals(obj.portable.col, portablePo.field("_col"));
- assertEquals(obj.portable.map, portablePo.field("_map"));
- assertEquals(new Integer(obj.portable.enumVal.ordinal()),
- new Integer(((Enum<?>)portablePo.field("_enumVal")).ordinal()));
- assertArrayEquals(ordinals(obj.portable.enumArr), ordinals((Enum<?>[])portablePo.field("_enumArr")));
- assertNull(portablePo.field("_simple"));
- assertNull(portablePo.field("_portable"));
- assertNull(portablePo.field("unknown"));
- }
-
- /**
- * @param obj Simple object.
- * @param po Portable object.
- */
- private void checkSimpleObjectData(SimpleObject obj, BinaryObject po) {
- assertEquals(obj.b, (byte)po.field("b"));
- assertEquals(obj.s, (short)po.field("s"));
- assertEquals(obj.i, (int)po.field("i"));
- assertEquals(obj.l, (long)po.field("l"));
- assertEquals(obj.f, (float)po.field("f"), 0);
- assertEquals(obj.d, (double)po.field("d"), 0);
- assertEquals(obj.c, (char)po.field("c"));
- assertEquals(obj.bool, (boolean)po.field("bool"));
- assertEquals(obj.str, po.field("str"));
- assertEquals(obj.uuid, po.field("uuid"));
- assertEquals(obj.date, po.field("date"));
- assertEquals(Date.class, obj.date.getClass());
- assertEquals(obj.ts, po.field("ts"));
- assertArrayEquals(obj.bArr, (byte[])po.field("bArr"));
- assertArrayEquals(obj.sArr, (short[])po.field("sArr"));
- assertArrayEquals(obj.iArr, (int[])po.field("iArr"));
- assertArrayEquals(obj.lArr, (long[])po.field("lArr"));
- assertArrayEquals(obj.fArr, (float[])po.field("fArr"), 0);
- assertArrayEquals(obj.dArr, (double[])po.field("dArr"), 0);
- assertArrayEquals(obj.cArr, (char[])po.field("cArr"));
- assertBooleanArrayEquals(obj.boolArr, (boolean[])po.field("boolArr"));
- assertArrayEquals(obj.strArr, (String[])po.field("strArr"));
- assertArrayEquals(obj.uuidArr, (UUID[])po.field("uuidArr"));
- assertArrayEquals(obj.dateArr, (Date[])po.field("dateArr"));
- assertArrayEquals(obj.objArr, (Object[])po.field("objArr"));
- assertEquals(obj.col, po.field("col"));
- assertEquals(obj.map, po.field("map"));
- assertEquals(new Integer(obj.enumVal.ordinal()), new Integer(((Enum<?>)po.field("enumVal")).ordinal()));
- assertArrayEquals(ordinals(obj.enumArr), ordinals((Enum<?>[])po.field("enumArr")));
- assertNull(po.field("unknown"));
-
- assertEquals(obj, po.deserialize());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClassWithoutPublicConstructor() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
- new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
- new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
- );
-
- initPortableContext(marsh);
-
- NoPublicConstructor npc = new NoPublicConstructor();
- BinaryObject npc2 = marshal(npc, marsh);
-
- assertEquals("test", npc2.<NoPublicConstructor>deserialize().val);
-
- NoPublicDefaultConstructor npdc = new NoPublicDefaultConstructor(239);
- BinaryObject npdc2 = marshal(npdc, marsh);
-
- assertEquals(239, npdc2.<NoPublicDefaultConstructor>deserialize().val);
-
- ProtectedConstructor pc = new ProtectedConstructor();
- BinaryObject pc2 = marshal(pc, marsh);
-
- assertEquals(ProtectedConstructor.class, pc2.<ProtectedConstructor>deserialize().getClass());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCustomSerializer() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- BinaryTypeConfiguration type =
- new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
-
- type.setSerializer(new CustomSerializer1());
-
- marsh.setTypeConfigurations(Arrays.asList(type));
-
- CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
-
- BinaryObject po1 = marshal(obj1, marsh);
-
- assertEquals(20, po1.<CustomSerializedObject1>deserialize().val);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCustomSerializerWithGlobal() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setSerializer(new CustomSerializer1());
-
- BinaryTypeConfiguration type1 =
- new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
- BinaryTypeConfiguration type2 =
- new BinaryTypeConfiguration(CustomSerializedObject2.class.getName());
-
- type2.setSerializer(new CustomSerializer2());
-
- marsh.setTypeConfigurations(Arrays.asList(type1, type2));
-
- CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
-
- BinaryObject po1 = marshal(obj1, marsh);
-
- assertEquals(20, po1.<CustomSerializedObject1>deserialize().val);
-
- CustomSerializedObject2 obj2 = new CustomSerializedObject2(10);
-
- BinaryObject po2 = marshal(obj2, marsh);
-
- assertEquals(30, po2.<CustomSerializedObject2>deserialize().val);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCustomIdMapper() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- BinaryTypeConfiguration type =
- new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
-
- type.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 11111;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- assert typeId == 11111;
-
- if ("val1".equals(fieldName))
- return 22222;
- else if ("val2".equals(fieldName))
- return 33333;
-
- assert false : "Unknown field: " + fieldName;
-
- return 0;
- }
- });
-
- marsh.setTypeConfigurations(Arrays.asList(type));
-
- CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str");
-
- BinaryObjectEx po1 = marshal(obj1, marsh);
-
- assertEquals(11111, po1.typeId());
- assertEquals(10, po1.field(22222));
- assertEquals("str", po1.field(33333));
-
- assertEquals(10, po1.<CustomMappedObject1>deserialize().val1);
- assertEquals("str", po1.<CustomMappedObject1>deserialize().val2);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCustomIdMapperWithGlobal() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 11111;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- assert typeId == 11111;
-
- if ("val1".equals(fieldName)) return 22222;
- else if ("val2".equals(fieldName)) return 33333;
-
- assert false : "Unknown field: " + fieldName;
-
- return 0;
- }
- });
-
- BinaryTypeConfiguration type1 =
- new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
- BinaryTypeConfiguration type2 =
- new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
-
- type2.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 44444;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- assert typeId == 44444;
-
- if ("val1".equals(fieldName)) return 55555;
- else if ("val2".equals(fieldName)) return 66666;
-
- assert false : "Unknown field: " + fieldName;
-
- return 0;
- }
- });
-
- marsh.setTypeConfigurations(Arrays.asList(type1, type2));
-
- CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str1");
-
- BinaryObjectEx po1 = marshal(obj1, marsh);
-
- assertEquals(11111, po1.typeId());
- assertEquals(10, po1.field(22222));
- assertEquals("str1", po1.field(33333));
-
- assertEquals(10, po1.<CustomMappedObject1>deserialize().val1);
- assertEquals("str1", po1.<CustomMappedObject1>deserialize().val2);
-
- CustomMappedObject2 obj2 = new CustomMappedObject2(20, "str2");
-
- BinaryObjectEx po2 = marshal(obj2, marsh);
-
- assertEquals(44444, po2.typeId());
- assertEquals(20, po2.field(55555));
- assertEquals("str2", po2.field(66666));
-
- assertEquals(20, po2.<CustomMappedObject2>deserialize().val1);
- assertEquals("str2", po2.<CustomMappedObject2>deserialize().val2);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDynamicObject() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(DynamicObject.class.getName())
- ));
-
- BinaryObject po1 = marshal(new DynamicObject(0, 10, 20, 30), marsh);
-
- assertEquals(new Integer(10), po1.field("val1"));
- assertEquals(null, po1.field("val2"));
- assertEquals(null, po1.field("val3"));
-
- DynamicObject do1 = po1.deserialize();
-
- assertEquals(10, do1.val1);
- assertEquals(0, do1.val2);
- assertEquals(0, do1.val3);
-
- BinaryObject po2 = marshal(new DynamicObject(1, 10, 20, 30), marsh);
-
- assertEquals(new Integer(10), po2.field("val1"));
- assertEquals(new Integer(20), po2.field("val2"));
- assertEquals(null, po2.field("val3"));
-
- DynamicObject do2 = po2.deserialize();
-
- assertEquals(10, do2.val1);
- assertEquals(20, do2.val2);
- assertEquals(0, do2.val3);
-
- BinaryObject po3 = marshal(new DynamicObject(2, 10, 20, 30), marsh);
-
- assertEquals(new Integer(10), po3.field("val1"));
- assertEquals(new Integer(20), po3.field("val2"));
- assertEquals(new Integer(30), po3.field("val3"));
-
- DynamicObject do3 = po3.deserialize();
-
- assertEquals(10, do3.val1);
- assertEquals(20, do3.val2);
- assertEquals(30, do3.val3);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCycleLink() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(CycleLinkObject.class.getName())
- ));
-
- CycleLinkObject obj = new CycleLinkObject();
-
- obj.self = obj;
-
- BinaryObject po = marshal(obj, marsh);
-
- CycleLinkObject obj0 = po.deserialize();
-
- assert obj0.self == obj0;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDetached() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(DetachedTestObject.class.getName()),
- new BinaryTypeConfiguration(DetachedInnerTestObject.class.getName())
- ));
-
- UUID id = UUID.randomUUID();
-
- DetachedTestObject obj = marshal(new DetachedTestObject(
- new DetachedInnerTestObject(null, id)), marsh).deserialize();
-
- assertEquals(id, obj.inner1.id);
- assertEquals(id, obj.inner4.id);
-
- assert obj.inner1 == obj.inner4;
-
- BinaryObjectImpl innerPo = (BinaryObjectImpl)obj.inner2;
-
- assert innerPo.detached();
-
- DetachedInnerTestObject inner = innerPo.deserialize();
-
- assertEquals(id, inner.id);
-
- BinaryObjectImpl detachedPo = (BinaryObjectImpl)innerPo.detach();
-
- assert detachedPo.detached();
-
- inner = detachedPo.deserialize();
-
- assertEquals(id, inner.id);
-
- innerPo = (BinaryObjectImpl)obj.inner3;
-
- assert innerPo.detached();
-
- inner = innerPo.deserialize();
-
- assertEquals(id, inner.id);
- assertNotNull(inner.inner);
-
- detachedPo = (BinaryObjectImpl)innerPo.detach();
-
- assert detachedPo.detached();
-
- inner = innerPo.deserialize();
-
- assertEquals(id, inner.id);
- assertNotNull(inner.inner);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCollectionFields() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(CollectionFieldsObject.class.getName()),
- new BinaryTypeConfiguration(Key.class.getName()),
- new BinaryTypeConfiguration(Value.class.getName())
- ));
-
- Object[] arr = new Object[] {new Value(1), new Value(2), new Value(3)};
- Collection<Value> col = Arrays.asList(new Value(4), new Value(5), new Value(6));
- Map<Key, Value> map = F.asMap(new Key(10), new Value(10), new Key(20), new Value(20), new Key(30), new Value(30));
-
- CollectionFieldsObject obj = new CollectionFieldsObject(arr, col, map);
-
- BinaryObject po = marshal(obj, marsh);
-
- Object[] arr0 = po.field("arr");
-
- assertEquals(3, arr0.length);
-
- int i = 1;
-
- for (Object valPo : arr0)
- assertEquals(i++, ((BinaryObject)valPo).<Value>deserialize().val);
-
- Collection<BinaryObject> col0 = po.field("col");
-
- i = 4;
-
- for (BinaryObject valPo : col0)
- assertEquals(i++, valPo.<Value>deserialize().val);
-
- Map<BinaryObject, BinaryObject> map0 = po.field("map");
-
- for (Map.Entry<BinaryObject, BinaryObject> e : map0.entrySet())
- assertEquals(e.getKey().<Key>deserialize().key, e.getValue().<Value>deserialize().val);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDefaultMapping() throws Exception {
- PortableMarshaller marsh1 = new PortableMarshaller();
-
- BinaryTypeConfiguration customMappingType =
- new BinaryTypeConfiguration(TestBinary.class.getName());
-
- customMappingType.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- String typeName;
-
- try {
- Method mtd = PortableContext.class.getDeclaredMethod("typeName", String.class);
-
- mtd.setAccessible(true);
-
- typeName = (String)mtd.invoke(null, clsName);
- }
- catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
-
- return typeName.toLowerCase().hashCode();
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return fieldName.toLowerCase().hashCode();
- }
- });
-
- marsh1.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName()),
- customMappingType
- ));
-
- TestBinary obj = BinaryObject();
-
- BinaryObjectImpl po = marshal(obj, marsh1);
-
- PortableMarshaller marsh2 = new PortableMarshaller();
-
- marsh2.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName()),
- new BinaryTypeConfiguration(TestBinary.class.getName())
- ));
-
- PortableContext ctx = initPortableContext(marsh2);
-
- po.context(ctx);
-
- assertEquals(obj, po.deserialize());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTypeNames() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
-
- customType1.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 300;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return 0;
- }
- });
-
- BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
-
- customType2.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 400;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return 0;
- }
- });
-
- BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
-
- customType3.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 500;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return 0;
- }
- });
-
- BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass5");
-
- customType4.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 0;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return 0;
- }
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(Key.class.getName()),
- new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
- new BinaryTypeConfiguration("NonExistentClass4"),
- customType1,
- customType2,
- customType3,
- customType4
- ));
-
- PortableContext ctx = initPortableContext(marsh);
-
- assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
- assertEquals("key".hashCode(), ctx.typeId("Key"));
- assertEquals("nonexistentclass3".hashCode(), ctx.typeId("NonExistentClass3"));
- assertEquals("nonexistentclass4".hashCode(), ctx.typeId("NonExistentClass4"));
- assertEquals(300, ctx.typeId(getClass().getSimpleName() + "$Value"));
- assertEquals(400, ctx.typeId("NonExistentClass1"));
- assertEquals(500, ctx.typeId("NonExistentClass2"));
- assertEquals("nonexistentclass5".hashCode(), ctx.typeId("NonExistentClass5"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testFieldIdMapping() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
-
- customType1.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 300;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- switch (fieldName) {
- case "val1":
- return 301;
-
- case "val2":
- return 302;
-
- default:
- return 0;
- }
- }
- });
-
- BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("NonExistentClass1");
-
- customType2.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 400;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- switch (fieldName) {
- case "val1":
- return 401;
-
- case "val2":
- return 402;
-
- default:
- return 0;
- }
- }
- });
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(Key.class.getName()),
- new BinaryTypeConfiguration("NonExistentClass2"),
- customType1,
- customType2));
-
- PortableContext ctx = initPortableContext(marsh);
-
- assertEquals("val".hashCode(), ctx.fieldId("key".hashCode(), "val"));
- assertEquals("val".hashCode(), ctx.fieldId("nonexistentclass2".hashCode(), "val"));
- assertEquals("val".hashCode(), ctx.fieldId("notconfiguredclass".hashCode(), "val"));
- assertEquals(301, ctx.fieldId(300, "val1"));
- assertEquals(302, ctx.fieldId(300, "val2"));
- assertEquals("val3".hashCode(), ctx.fieldId(300, "val3"));
- assertEquals(401, ctx.fieldId(400, "val1"));
- assertEquals(402, ctx.fieldId(400, "val2"));
- assertEquals("val3".hashCode(), ctx.fieldId(400, "val3"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDuplicateTypeId() throws Exception {
- final PortableMarshaller marsh = new PortableMarshaller();
-
- BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration("org.gridgain.Class1");
-
- customType1.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 100;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return 0;
- }
- });
-
- BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.Class2");
-
- customType2.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return 100;
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return 0;
- }
- });
-
- marsh.setTypeConfigurations(Arrays.asList(customType1, customType2));
-
- try {
- initPortableContext(marsh);
- }
- catch (IgniteCheckedException e) {
- assertEquals("Duplicate type ID [clsName=org.gridgain.Class1, id=100]",
- e.getCause().getCause().getMessage());
-
- return;
- }
-
- assert false;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopy() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- final BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, null);
-
- assertEquals(obj, copy.deserialize());
-
- copy = copy(po, new HashMap<String, Object>());
-
- assertEquals(obj, copy.deserialize());
-
- Map<String, Object> map = new HashMap<>(1, 1.0f);
-
- map.put("i", 3);
-
- copy = copy(po, map);
-
- assertEquals((byte)2, copy.<Byte>field("b").byteValue());
- assertEquals((short)2, copy.<Short>field("s").shortValue());
- assertEquals(3, copy.<Integer>field("i").intValue());
- assertEquals(2L, copy.<Long>field("l").longValue());
- assertEquals(2.2f, copy.<Float>field("f").floatValue(), 0);
- assertEquals(2.2d, copy.<Double>field("d").doubleValue(), 0);
- assertEquals((char)2, copy.<Character>field("c").charValue());
- assertEquals(false, copy.<Boolean>field("bool").booleanValue());
-
- SimpleObject obj0 = copy.deserialize();
-
- assertEquals((byte)2, obj0.b);
- assertEquals((short)2, obj0.s);
- assertEquals(3, obj0.i);
- assertEquals(2L, obj0.l);
- assertEquals(2.2f, obj0.f, 0);
- assertEquals(2.2d, obj0.d, 0);
- assertEquals((char)2, obj0.c);
- assertEquals(false, obj0.bool);
-
- map = new HashMap<>(3, 1.0f);
-
- map.put("b", (byte)3);
- map.put("l", 3L);
- map.put("bool", true);
-
- copy = copy(po, map);
-
- assertEquals((byte)3, copy.<Byte>field("b").byteValue());
- assertEquals((short)2, copy.<Short>field("s").shortValue());
- assertEquals(2, copy.<Integer>field("i").intValue());
- assertEquals(3L, copy.<Long>field("l").longValue());
- assertEquals(2.2f, copy.<Float>field("f").floatValue(), 0);
- assertEquals(2.2d, copy.<Double>field("d").doubleValue(), 0);
- assertEquals((char)2, copy.<Character>field("c").charValue());
- assertEquals(true, copy.<Boolean>field("bool").booleanValue());
-
- obj0 = copy.deserialize();
-
- assertEquals((byte)3, obj0.b);
- assertEquals((short)2, obj0.s);
- assertEquals(2, obj0.i);
- assertEquals(3L, obj0.l);
- assertEquals(2.2f, obj0.f, 0);
- assertEquals(2.2d, obj0.d, 0);
- assertEquals((char)2, obj0.c);
- assertEquals(true, obj0.bool);
-
- map = new HashMap<>(8, 1.0f);
-
- map.put("b", (byte)3);
- map.put("s", (short)3);
- map.put("i", 3);
- map.put("l", 3L);
- map.put("f", 3.3f);
- map.put("d", 3.3d);
- map.put("c", (char)3);
- map.put("bool", true);
-
- copy = copy(po, map);
-
- assertEquals((byte)3, copy.<Byte>field("b").byteValue());
- assertEquals((short)3, copy.<Short>field("s").shortValue());
- assertEquals(3, copy.<Integer>field("i").intValue());
- assertEquals(3L, copy.<Long>field("l").longValue());
- assertEquals(3.3f, copy.<Float>field("f").floatValue(), 0);
- assertEquals(3.3d, copy.<Double>field("d").doubleValue(), 0);
- assertEquals((char)3, copy.<Character>field("c").charValue());
- assertEquals(true, copy.<Boolean>field("bool").booleanValue());
-
- obj0 = copy.deserialize();
-
- assertEquals((byte)3, obj0.b);
- assertEquals((short)3, obj0.s);
- assertEquals(3, obj0.i);
- assertEquals(3L, obj0.l);
- assertEquals(3.3f, obj0.f, 0);
- assertEquals(3.3d, obj0.d, 0);
- assertEquals((char)3, obj0.c);
- assertEquals(true, obj0.bool);
-
-// GridTestUtils.assertThrows(
-// log,
-// new Callable<Object>() {
-// @Override public Object call() throws Exception {
-// po.copy(F.<String, Object>asMap("i", false));
-//
-// return null;
-// }
-// },
-// PortableException.class,
-// "Invalid value type for field: i"
-// );
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyString() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("str", "str3"));
-
- assertEquals("str3", copy.<String>field("str"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertEquals("str3", obj0.str);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyUuid() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- UUID uuid = UUID.randomUUID();
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("uuid", uuid));
-
- assertEquals(uuid, copy.<UUID>field("uuid"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertEquals(uuid, obj0.uuid);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyByteArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1, 2, 3}));
-
- assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new byte[] {1, 2, 3}, obj0.bArr);
- }
-
- /**
- * @param po Portable object.
- * @param fields Fields.
- * @return Copy.
- */
- private BinaryObject copy(BinaryObject po, Map<String, Object> fields) {
- BinaryObjectBuilder builder = BinaryObjectBuilderImpl.wrap(po);
-
- if (fields != null) {
- for (Map.Entry<String, Object> e : fields.entrySet())
- builder.setField(e.getKey(), e.getValue());
- }
-
- return builder.build();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyShortArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("sArr", new short[]{1, 2, 3}));
-
- assertArrayEquals(new short[] {1, 2, 3}, copy.<short[]>field("sArr"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new short[] {1, 2, 3}, obj0.sArr);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyIntArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("iArr", new int[]{1, 2, 3}));
-
- assertArrayEquals(new int[] {1, 2, 3}, copy.<int[]>field("iArr"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new int[] {1, 2, 3}, obj0.iArr);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyLongArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("lArr", new long[]{1, 2, 3}));
-
- assertArrayEquals(new long[] {1, 2, 3}, copy.<long[]>field("lArr"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new long[] {1, 2, 3}, obj0.lArr);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyFloatArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("fArr", new float[]{1, 2, 3}));
-
- assertArrayEquals(new float[] {1, 2, 3}, copy.<float[]>field("fArr"), 0);
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new float[] {1, 2, 3}, obj0.fArr, 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyDoubleArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("dArr", new double[]{1, 2, 3}));
-
- assertArrayEquals(new double[] {1, 2, 3}, copy.<double[]>field("dArr"), 0);
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new double[] {1, 2, 3}, obj0.dArr, 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyCharArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[]{1, 2, 3}));
-
- assertArrayEquals(new char[]{1, 2, 3}, copy.<char[]>field("cArr"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new char[]{1, 2, 3}, obj0.cArr);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyStringArray() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[]{"str1", "str2"}));
-
- assertArrayEquals(new String[]{"str1", "str2"}, copy.<String[]>field("strArr"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertArrayEquals(new String[]{"str1", "str2"}, obj0.strArr);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyObject() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- SimpleObject newObj = new SimpleObject();
-
- newObj.i = 12345;
- newObj.fArr = new float[] {5, 8, 0};
- newObj.str = "newStr";
-
- BinaryObject copy = copy(po, F.<String, Object>asMap("inner", newObj));
-
- assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
-
- SimpleObject obj0 = copy.deserialize();
-
- assertEquals(newObj, obj0.inner);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyNonPrimitives() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())
- ));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- Map<String, Object> map = new HashMap<>(3, 1.0f);
-
- SimpleObject newObj = new SimpleObject();
-
- newObj.i = 12345;
- newObj.fArr = new float[] {5, 8, 0};
- newObj.str = "newStr";
-
- map.put("str", "str555");
- map.put("inner", newObj);
- map.put("bArr", new byte[]{6, 7, 9});
-
- BinaryObject copy = copy(po, map);
-
- assertEquals("str555", copy.<String>field("str"));
- assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
- assertArrayEquals(new byte[]{6, 7, 9}, copy.<byte[]>field("bArr"));
-
- SimpleObject obj0 = copy.deserialize();
-
- assertEquals("str555", obj0.str);
- assertEquals(newObj, obj0.inner);
- assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPortableCopyMixed() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- SimpleObject obj = simpleObject();
-
- BinaryObject po = marshal(obj, marsh);
-
- Map<String, Object> map = new HashMap<>(3, 1.0f);
-
- SimpleObject newObj = new SimpleObject();
-
- newObj.i = 12345;
- newObj.fArr = new float[] {5, 8, 0};
- newObj.str = "newStr";
-
- map.put("i", 1234);
- map.put("str", "str555");
- map.put("inner", newObj);
- map.put("s", (short)2323);
- map.put("bArr", new byte[]{6, 7, 9});
- map.put("b", (byte)111);
-
- BinaryObject copy = copy(po, map);
-
- assertEquals(1234, copy.<Integer>field("i").intValue());
- assertEquals("str555", copy.<String>field("str"));
- assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
- assertEquals((short)2323, copy.<Short>field("s").shortValue());
- assertArrayEquals(new byte[] {6, 7, 9}, copy.<byte[]>field("bArr"));
- assertEquals((byte)111, copy.<Byte>field("b").byteValue());
-
- SimpleObject obj0 = copy.deserialize();
-
- assertEquals(1234, obj0.i);
- assertEquals("str555", obj0.str);
- assertEquals(newObj, obj0.inner);
- assertEquals((short)2323, obj0.s);
- assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
- assertEquals((byte)111, obj0.b);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testKeepDeserialized() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
- marsh.setKeepDeserialized(true);
-
- BinaryObject po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() == po.deserialize();
-
- marsh = new PortableMarshaller();
-
- marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
- marsh.setKeepDeserialized(false);
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() != po.deserialize();
-
- marsh = new PortableMarshaller();
-
- marsh.setKeepDeserialized(true);
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() == po.deserialize();
-
- marsh = new PortableMarshaller();
-
- marsh.setKeepDeserialized(false);
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() != po.deserialize();
-
- marsh = new PortableMarshaller();
-
- marsh.setKeepDeserialized(true);
-
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
-
- typeCfg.setKeepDeserialized(false);
-
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() != po.deserialize();
-
- marsh = new PortableMarshaller();
-
- marsh.setKeepDeserialized(false);
-
- typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
-
- typeCfg.setKeepDeserialized(true);
-
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() == po.deserialize();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testOffheapPortable() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- PortableContext ctx = initPortableContext(marsh);
-
- SimpleObject simpleObj = simpleObject();
-
- BinaryObjectImpl obj = marshal(simpleObj, marsh);
-
- long ptr = 0;
-
- long ptr1 = 0;
-
- long ptr2 = 0;
-
- try {
- ptr = copyOffheap(obj);
-
- BinaryObjectOffheapImpl offheapObj = new BinaryObjectOffheapImpl(ctx,
- ptr,
- 0,
- obj.array().length);
-
- assertTrue(offheapObj.equals(offheapObj));
- assertFalse(offheapObj.equals(null));
- assertFalse(offheapObj.equals("str"));
- assertTrue(offheapObj.equals(obj));
- assertTrue(obj.equals(offheapObj));
-
- ptr1 = copyOffheap(obj);
-
- BinaryObjectOffheapImpl offheapObj1 = new BinaryObjectOffheapImpl(ctx,
- ptr1,
- 0,
- obj.array().length);
-
- assertTrue(offheapObj.equals(offheapObj1));
- assertTrue(offheapObj1.equals(offheapObj));
-
- assertEquals(obj.typeId(), offheapObj.typeId());
- assertEquals(obj.hashCode(), offheapObj.hashCode());
-
- checkSimpleObjectData(simpleObj, offheapObj);
-
- BinaryObjectOffheapImpl innerOffheapObj = offheapObj.field("inner");
-
- assertNotNull(innerOffheapObj);
-
- checkSimpleObjectData(simpleObj.inner, innerOffheapObj);
-
- obj = (BinaryObjectImpl)offheapObj.heapCopy();
-
- assertEquals(obj.typeId(), offheapObj.typeId());
- assertEquals(obj.hashCode(), offheapObj.hashCode());
-
- checkSimpleObjectData(simpleObj, obj);
-
- BinaryObjectImpl innerObj = obj.field("inner");
-
- assertNotNull(innerObj);
-
- checkSimpleObjectData(simpleObj.inner, innerObj);
-
- simpleObj.d = 0;
-
- obj = marshal(simpleObj, marsh);
-
- assertFalse(offheapObj.equals(obj));
- assertFalse(obj.equals(offheapObj));
-
- ptr2 = copyOffheap(obj);
-
- BinaryObjectOffheapImpl offheapObj2 = new BinaryObjectOffheapImpl(ctx,
- ptr2,
- 0,
- obj.array().length);
-
- assertFalse(offheapObj.equals(offheapObj2));
- assertFalse(offheapObj2.equals(offheapObj));
- }
- finally {
- UNSAFE.freeMemory(ptr);
-
- if (ptr1 > 0)
- UNSAFE.freeMemory(ptr1);
-
- if (ptr2 > 0)
- UNSAFE.freeMemory(ptr2);
- }
- }
-
- /**
- *
- */
- public void testReadResolve() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setClassNames(
- Arrays.asList(MySingleton.class.getName(), SingletonMarker.class.getName()));
-
- BinaryObjectImpl portableObj = marshal(MySingleton.INSTANCE, marsh);
-
- assertTrue(portableObj.array().length <= 1024); // Check that big string was not serialized.
-
- MySingleton singleton = portableObj.deserialize();
-
- assertSame(MySingleton.INSTANCE, singleton);
- }
-
- /**
- *
- */
- public void testReadResolveOnPortableAware() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setClassNames(Collections.singletonList(MyTestClass.class.getName()));
-
- BinaryObjectImpl portableObj = marshal(new MyTestClass(), marsh);
-
- MyTestClass obj = portableObj.deserialize();
-
- assertEquals("readResolve", obj.s);
- }
-
- /**
- * @throws Exception If ecxeption thrown.
- */
- public void testDeclareReadResolveInParent() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setClassNames(Arrays.asList(ChildPortable.class.getName()));
-
- BinaryObjectImpl portableObj = marshal(new ChildPortable(), marsh);
-
- ChildPortable singleton = portableObj.deserialize();
-
- assertNotNull(singleton.s);
- }
-
- /**
- *
- */
- public void testDecimalFields() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- Collection<String> clsNames = new ArrayList<>();
-
- clsNames.add(DecimalReflective.class.getName());
- clsNames.add(DecimalMarshalAware.class.getName());
-
- marsh.setClassNames(clsNames);
-
- // 1. Test reflective stuff.
- DecimalReflective obj1 = new DecimalReflective();
-
- obj1.val = BigDecimal.ZERO;
- obj1.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN };
-
- BinaryObjectImpl portObj = marshal(obj1, marsh);
-
- assertEquals(obj1.val, portObj.field("val"));
- assertArrayEquals(obj1.valArr, portObj.<BigDecimal[]>field("valArr"));
-
- assertEquals(obj1.val, portObj.<DecimalReflective>deserialize().val);
- assertArrayEquals(obj1.valArr, portObj.<DecimalReflective>deserialize().valArr);
-
- // 2. Test marshal aware stuff.
- DecimalMarshalAware obj2 = new DecimalMarshalAware();
-
- obj2.val = BigDecimal.ZERO;
- obj2.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN.negate() };
- obj2.rawVal = BigDecimal.TEN;
- obj2.rawValArr = new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ONE };
-
- portObj = marshal(obj2, marsh);
-
- assertEquals(obj2.val, portObj.field("val"));
- assertArrayEquals(obj2.valArr, portObj.<BigDecimal[]>field("valArr"));
-
- assertEquals(obj2.val, portObj.<DecimalMarshalAware>deserialize().val);
- assertArrayEquals(obj2.valArr, portObj.<DecimalMarshalAware>deserialize().valArr);
- assertEquals(obj2.rawVal, portObj.<DecimalMarshalAware>deserialize().rawVal);
- assertArrayEquals(obj2.rawValArr, portObj.<DecimalMarshalAware>deserialize().rawValArr);
- }
-
- /**
- * @throws IgniteCheckedException If failed.
- */
- public void testFinalField() throws IgniteCheckedException {
- PortableMarshaller marsh = new PortableMarshaller();
-
- SimpleObjectWithFinal obj = new SimpleObjectWithFinal();
-
- SimpleObjectWithFinal po0 = marshalUnmarshal(obj, marsh);
-
- assertEquals(obj.time, po0.time);
- }
-
- /**
- * @throws IgniteCheckedException If failed.
- */
- public void testThreadLocalArrayReleased() throws IgniteCheckedException {
- // Checking the writer directly.
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
-
- try (BinaryWriterExImpl writer = new BinaryWriterExImpl(initPortableContext(new PortableMarshaller()))) {
- assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
-
- writer.writeString("Thread local test");
-
- writer.array();
-
- assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
- }
-
- // Checking the portable marshaller.
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
-
- PortableMarshaller marsh = new PortableMarshaller();
-
- initPortableContext(marsh);
-
- marsh.marshal(new SimpleObject());
-
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
-
- // Checking the builder.
- BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(initPortableContext(new PortableMarshaller()),
- "org.gridgain.foo.bar.TestClass");
-
- builder.setField("a", "1");
-
- BinaryObject portableObj = builder.build();
-
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDuplicateName() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- initPortableContext(marsh);
-
- Test1.Job job1 = new Test1().new Job();
- Test2.Job job2 = new Test2().new Job();
-
- marsh.marshal(job1);
-
- try {
- marsh.marshal(job2);
- } catch (BinaryObjectException e) {
- assertEquals(true, e.getMessage().contains("Failed to register class"));
- return;
- }
-
- assert false;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClass() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- initPortableContext(marsh);
-
- Class cls = GridPortableMarshallerSelfTest.class;
-
- Class unmarshalledCls = marshalUnmarshal(cls, marsh);
-
- Assert.assertEquals(cls, unmarshalledCls);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testClassFieldsMarshalling() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- initPortableContext(marsh);
-
- ObjectWithClassFields obj = new ObjectWithClassFields();
- obj.cls1 = GridPortableMarshallerSelfTest.class;
-
- byte[] marshal = marsh.marshal(obj);
-
- ObjectWithClassFields obj2 = marsh.unmarshal(marshal, null);
-
- assertEquals(obj.cls1, obj2.cls1);
- assertNull(obj2.cls2);
-
- BinaryObject portObj = marshal(obj, marsh);
-
- Class cls1 = portObj.field("cls1");
-
- assertEquals(obj.cls1, cls1);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMarshallingThroughJdk() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- initPortableContext(marsh);
-
- InetSocketAddress addr = new InetSocketAddress("192.168.0.2", 4545);
-
- byte[] arr = marsh.marshal(addr);
-
- InetSocketAddress addr2 = marsh.unmarshal(arr, null);
-
- assertEquals(addr.getHostString(), addr2.getHostString());
- assertEquals(addr.getPort(), addr2.getPort());
-
- TestAddress testAddr = new TestAddress();
- testAddr.addr = addr;
- testAddr.str1 = "Hello World";
-
- SimpleObject simpleObj = new SimpleObject();
- simpleObj.c = 'g';
- simpleObj.date = new Date();
-
- testAddr.obj = simpleObj;
-
- arr = marsh.marshal(testAddr);
-
- TestAddress testAddr2 = marsh.unmarshal(arr, null);
-
- assertEquals(testAddr.addr.getHostString(), testAddr2.addr.getHostString());
- assertEquals(testAddr.addr.getPort(), testAddr2.addr.getPort());
- assertEquals(testAddr.str1, testAddr2.str1);
- assertEquals(testAddr.obj.c, testAddr2.obj.c);
- assertEquals(testAddr.obj.date, testAddr2.obj.date);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPredefinedTypeIds() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- PortableContext pCtx = initPortableContext(marsh);
-
- Field field = pCtx.getClass().getDeclaredField("predefinedTypeNames");
-
- field.setAccessible(true);
-
- Map<String, Integer> map = (Map<String, Integer>)field.get(pCtx);
-
- assertTrue(map.size() > 0);
-
- for (Map.Entry<String, Integer> entry : map.entrySet()) {
- int id = entry.getValue();
-
- if (id == GridPortableMarshaller.UNREGISTERED_TYPE_ID)
- continue;
-
- PortableClassDescriptor desc = pCtx.descriptorForTypeId(false, entry.getValue(), null);
-
- assertEquals(desc.typeId(), pCtx.typeId(desc.describedClass().getName()));
- assertEquals(desc.typeId(), pCtx.typeId(pCtx.typeName(desc.describedClass().getName())));
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCyclicReferencesMarshalling() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- SimpleObject obj = simpleObject();
-
- obj.bArr = obj.inner.bArr;
- obj.cArr = obj.inner.cArr;
- obj.boolArr = obj.inner.boolArr;
- obj.sArr = obj.inner.sArr;
- obj.strArr = obj.inner.strArr;
- obj.iArr = obj.inner.iArr;
- obj.lArr = obj.inner.lArr;
- obj.fArr = obj.inner.fArr;
- obj.dArr = obj.inner.dArr;
- obj.dateArr = obj.inner.dateArr;
- obj.uuidArr = obj.inner.uuidArr;
- obj.objArr = obj.inner.objArr;
- obj.bdArr = obj.inner.bdArr;
- obj.map = obj.inner.map;
- obj.col = obj.inner.col;
- obj.mEntry = obj.inner.mEntry;
-
- SimpleObject res = (SimpleObject)marshalUnmarshal(obj, marsh);
-
- assertEquals(obj, res);
-
- assertTrue(res.bArr == res.inner.bArr);
- assertTrue(res.cArr == res.inner.cArr);
- assertTrue(res.boolArr == res.inner.boolArr);
- assertTrue(res.sArr == res.inner.sArr);
- assertTrue(res.strArr == res.inner.strArr);
- assertTrue(res.iArr == res.inner.iArr);
- assertTrue(res.lArr == res.inner.lArr);
- assertTrue(res.fArr == res.inner.fArr);
- assertTrue(res.dArr == res.inner.dArr);
- assertTrue(res.dateArr == res.inner.dateArr);
- assertTrue(res.uuidArr == res.inner.uuidArr);
- assertTrue(res.objArr == res.inner.objArr);
- assertTrue(res.bdArr == res.inner.bdArr);
- assertTrue(res.map == res.inner.map);
- assertTrue(res.col == res.inner.col);
- assertTrue(res.mEntry == res.inner.mEntry);
- }
-
- /**
- * Object with class fields.
- */
- private static class ObjectWithClassFields {
- /** */
- private Class<?> cls1;
-
- /** */
- private Class<?> cls2;
- }
-
- /**
- *
- */
- private static class TestAddress {
- /** */
- private SimpleObject obj;
-
- /** */
- private InetSocketAddress addr;
-
- /** */
- private String str1;
- }
-
- /**
- *
- */
- private static class Test1 {
- /**
- *
- */
- private class Job {
-
- }
- }
-
- /**
- *
- */
- private static class Test2 {
- /**
- *
- */
- private class Job {
-
- }
- }
-
- /**
- * @param obj Object.
- * @return Offheap address.
- */
- private long copyOffheap(BinaryObjectImpl obj) {
- byte[] arr = obj.array();
-
- long ptr = UNSAFE.allocateMemory(arr.length);
-
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
-
- return ptr;
- }
-
- /**
- * @param enumArr Enum array.
- * @return Ordinals.
- */
- private <T extends Enum<?>> Integer[] ordinals(T[] enumArr) {
- Integer[] ords = new Integer[enumArr.length];
-
- for (int i = 0; i < enumArr.length; i++)
- ords[i] = enumArr[i].ordinal();
-
- return ords;
- }
-
- /**
- * @param po Portable object.
- * @param off Offset.
- * @return Value.
- */
- private int intFromPortable(BinaryObject po, int off) {
- byte[] arr = U.field(po, "arr");
-
- return Integer.reverseBytes(U.bytesToInt(arr, off));
- }
-
- /**
- * @param obj Original object.
- * @return Result object.
- */
- private <T> T marshalUnmarshal(T obj) throws IgniteCheckedException {
- return marshalUnmarshal(obj, new PortableMarshaller());
- }
-
- /**
- * @param obj Original object.
- * @param marsh Marshaller.
- * @return Result object.
- */
- private <T> T marshalUnmarshal(Object obj, PortableMarshaller marsh) throws IgniteCheckedException {
- initPortableContext(marsh);
-
- byte[] bytes = marsh.marshal(obj);
-
- return marsh.unmarshal(bytes, null);
- }
-
- /**
- * @param obj Object.
- * @param marsh Marshaller.
- * @return Portable object.
- */
- private <T> BinaryObjectImpl marshal(T obj, PortableMarshaller marsh) throws IgniteCheckedException {
- initPortableContext(marsh);
-
- byte[] bytes = marsh.marshal(obj);
-
- return new BinaryObjectImpl(U.<GridPortableMarshaller>field(marsh, "impl").context(),
- bytes, 0);
- }
-
- /**
- * @return Portable context.
- */
- protected PortableContext initPortableContext(PortableMarshaller marsh) throws IgniteCheckedException {
- IgniteConfiguration iCfg = new IgniteConfiguration();
-
- PortableContext ctx = new PortableContext(BinaryNoopMetadataHandler.instance(), iCfg);
-
- marsh.setContext(new MarshallerContextTestImpl(null));
-
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
-
- return ctx;
- }
-
- /**
- * @param exp Expected.
- * @param act Actual.
- */
- private void assertBooleanArrayEquals(boolean[] exp, boolean[] act) {
- assertEquals(exp.length, act.length);
-
- for (int i = 0; i < act.length; i++)
- assertEquals(exp[i], act[i]);
- }
-
- /**
- *
- */
- private static class SimpleObjectWithFinal {
- /** */
- private final long time = System.currentTimeMillis();
- }
-
- /**
- * @return Simple object.
- */
- private SimpleObject simpleObject() {
- SimpleObject inner = new SimpleObject();
-
- inner.b = 1;
- inner.s = 1;
- inner.i = 1;
- inner.l = 1;
- inner.f = 1.1f;
- inner.d = 1.1d;
- inner.c = 1;
- inner.bool = true;
- inner.str = "str1";
- inner.uuid = UUID.randomUUID();
- inner.date = new Date();
- inner.ts = new Timestamp(System.currentTimeMillis());
- inner.bArr = new byte[] {1, 2, 3};
- inner.sArr = new short[] {1, 2, 3};
- inner.iArr = new int[] {1, 2, 3};
- inner.lArr = new long[] {1, 2, 3};
- inner.fArr = new float[] {1.1f, 2.2f, 3.3f};
- inner.dArr = new double[] {1.1d, 2.2d, 3.3d};
- inner.cArr = new char[] {1, 2, 3};
- inner.boolArr = new boolean[] {true, false, true};
- inner.strArr = new String[] {"str1", "str2", "str3"};
- inner.uuidArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
- inner.dateArr = new Date[] {new Date(11111), new Date(22222), new Date(33333)};
- inner.objArr = new Object[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
- inner.col = new ArrayList<>();
- inner.map = new HashMap<>();
- inner.enumVal = TestEnum.A;
- inner.enumArr = new TestEnum[] {TestEnum.A, TestEnum.B};
- inner.bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.ONE};
-
- inner.col.add("str1");
- inner.col.add("str2");
- inner.col.add("str3");
-
- inner.map.put(1, "str1");
- inner.map.put(2, "str2");
- inner.map.put(3, "str3");
-
- inner.mEntry = inner.map.entrySet().iterator().next();
-
- SimpleObject outer = new SimpleObject();
-
- outer.b = 2;
- outer.s = 2;
- outer.i = 2;
- outer.l = 2;
- outer.f = 2.2f;
- outer.d = 2.2d;
- outer.c = 2;
- outer.bool = false;
- outer.str = "str2";
- outer.uuid = UUID.randomUUID();
- outer.date = new Date();
- outer.ts = new Timestamp(System.currentTimeMillis());
- outer.bArr = new byte[] {10, 20, 30};
- outer.sArr = new short[] {10, 20, 30};
- outer.iArr = new int[] {10, 20, 30};
- outer.lArr = new long[] {10, 20, 30};
- outer.fArr = new float[] {10.01f, 20.02f, 30.03f};
- outer.dArr = new double[] {10.01d, 20.02d, 30.03d};
- outer.cArr = new char[] {10, 20, 30};
- outer.boolArr = new boolean[] {false, true, false};
- outer.strArr = new String[] {"str10", "str20", "str30"};
- outer.uuidArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
- outer.dateArr = new Date[] {new Date(44444), new Date(55555), new Date(66666)};
- outer.objArr = new Object[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
- outer.col = new ArrayList<>();
- outer.map = new HashMap<>();
- outer.enumVal = TestEnum.B;
- outer.enumArr = new TestEnum[] {TestEnum.B, TestEnum.C};
- outer.inner = inner;
- outer.bdArr = new BigDecimal[] {new BigDecimal(5000), BigDecimal.TEN};
-
-
- outer.col.add("str4");
- outer.col.add("str5");
- outer.col.add("str6");
-
- outer.map.put(4, "str4");
- outer.map.put(5, "str5");
- outer.map.put(6, "str6");
-
- outer.mEntry = outer.map.entrySet().iterator().next();
-
- return outer;
- }
-
- /**
- * @return Portable object.
- */
- private TestBinary BinaryObject() {
- SimpleObject innerSimple = new SimpleObject();
-
- innerSimple.b = 1;
- innerSimple.s = 1;
- innerSimple.i = 1;
- innerSimple.l = 1;
- innerSimple.f = 1.1f;
- innerSimple.d = 1.1d;
- innerSimple.c = 1;
- innerSimple.bool = true;
- innerSimple.str = "str1";
- innerSimple.uuid = UUID.randomUUID();
- innerSimple.date = new Date();
- innerSimple.ts = new Timestamp(System.currentTimeMillis());
- innerSimple.bArr = new byte[] {1, 2, 3};
- innerSimple.sArr = new short[] {1, 2, 3};
- innerSimple.iArr = new int[] {1, 2, 3};
- innerSimple.lArr = new long[] {1, 2, 3};
- innerSimple.fArr = new float[] {1.1f, 2.2f, 3.3f};
- innerSimple.dArr = new double[] {1.1d, 2.2d, 3.3d};
- innerSimple.cArr = new char[] {1, 2, 3};
- innerSimple.boolArr = new boolean[] {true, false, true};
- innerSimple.strArr = new String[] {"str1", "str2", "str3"};
- innerSimple.uuidArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
- innerSimple.dateArr = new Date[] {new Date(11111), new Date(22222), new Date(33333)};
- innerSimple.objArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
- innerSimple.col = new ArrayList<>();
- innerSimple.map = new HashMap<>();
- innerSimple.enumVal = TestEnum.A;
- innerSimple.enumArr = new TestEnum[] {TestEnum.A, TestEnum.B};
-
- innerSimple.col.add("str1");
- innerSimple.col.add("str2");
- innerSimple.col.add("str3");
-
- innerSimple.map.put(1, "str1");
- innerSimple.map.put(2, "str2");
- innerSimple.map.put(3, "str3");
-
- TestBinary innerPortable = new TestBinary();
-
- innerPortable.b = 2;
- innerPortable.s = 2;
-
<TRUNCATED>
[36/55] [abbrv] ignite git commit: Merged ignite-1945 into ignite-1282
Posted by ag...@apache.org.
Merged ignite-1945 into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c505f48a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c505f48a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c505f48a
Branch: refs/heads/ignite-1.5
Commit: c505f48a882e7fb702918d903a210fc0a7e65f5a
Parents: b876f76
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 12:07:27 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 12:07:27 2015 +0300
----------------------------------------------------------------------
.../config/binary/example-ignite-binary.xml | 2 +-
.../java/org/apache/ignite/IgniteBinary.java | 9 +-
.../java/org/apache/ignite/IgniteCache.java | 3 +-
.../apache/ignite/binary/BinaryIdMapper.java | 4 +-
.../org/apache/ignite/binary/BinaryObject.java | 5 +-
.../apache/ignite/binary/BinarySerializer.java | 4 +-
.../ignite/binary/BinaryTypeConfiguration.java | 47 +--
.../configuration/BinaryConfiguration.java | 139 +++++++
.../configuration/IgniteConfiguration.java | 29 +-
.../apache/ignite/internal/IgniteKernal.java | 7 +-
.../internal/portable/BinaryObjectImpl.java | 11 +-
.../portable/PortableClassDescriptor.java | 16 +-
.../internal/portable/PortableContext.java | 85 ++--
.../processors/cache/GridCacheProcessor.java | 4 +-
.../CacheObjectBinaryProcessorImpl.java | 17 +-
.../cache/store/CacheOsStoreManager.java | 4 +-
.../cpp/PlatformCppConfigurationClosure.java | 30 +-
.../PlatformDotNetConfigurationClosure.java | 34 +-
.../marshaller/portable/BinaryMarshaller.java | 146 +++++++
.../marshaller/portable/PortableMarshaller.java | 299 --------------
.../resources/META-INF/classnames.properties | 31 +-
.../portable/BinaryFieldsAbstractSelfTest.java | 33 +-
.../portable/BinaryFieldsHeapSelfTest.java | 4 +-
.../portable/BinaryFieldsOffheapSelfTest.java | 4 +-
.../BinaryFooterOffsetsAbstractSelfTest.java | 27 +-
.../BinaryFooterOffsetsHeapSelfTest.java | 4 +-
.../BinaryFooterOffsetsOffheapSelfTest.java | 4 +-
.../portable/BinaryMarshallerSelfTest.java | 402 +++++++------------
.../BinaryObjectBuilderAdditionalSelfTest.java | 13 +-
.../portable/BinaryObjectBuilderSelfTest.java | 43 +-
.../GridPortableAffinityKeySelfTest.java | 13 +-
...idPortableMarshallerCtxDisabledSelfTest.java | 10 +-
.../portable/GridPortableMetaDataSelfTest.java | 13 +-
.../portable/GridPortableWildcardsSelfTest.java | 243 ++++++-----
.../BinaryFieldsHeapNonCompactSelfTest.java | 4 -
...IgniteCacheAbstractExecutionContextTest.java | 4 +-
.../IgniteCacheTxExecutionContextTest.java | 2 -
...naryObjectsAbstractDataStreamerSelfTest.java | 10 +-
...aryObjectsAbstractMultiThreadedSelfTest.java | 10 +-
.../GridCacheBinaryObjectsAbstractSelfTest.java | 4 +-
...ntNodeBinaryObjectMetadataMultinodeTest.java | 4 +-
...CacheClientNodeBinaryObjectMetadataTest.java | 19 +-
.../GridCachePortableStoreAbstractSelfTest.java | 11 +-
...ridPortableCacheEntryMemorySizeSelfTest.java | 10 +-
...leDuplicateIndexObjectsAbstractSelfTest.java | 11 +-
.../DataStreamProcessorPortableSelfTest.java | 4 +-
.../GridDataStreamerImplSelfTest.java | 4 +-
...ridCacheAffinityRoutingPortableSelfTest.java | 13 +-
.../GridCacheMemoryModePortableSelfTest.java | 4 +-
...acheOffHeapTieredAtomicPortableSelfTest.java | 9 +-
...eapTieredEvictionAtomicPortableSelfTest.java | 9 +-
...heOffHeapTieredEvictionPortableSelfTest.java | 9 +-
.../GridCacheOffHeapTieredPortableSelfTest.java | 9 +-
...sNearPartitionedByteArrayValuesSelfTest.java | 4 +-
...sPartitionedOnlyByteArrayValuesSelfTest.java | 4 +-
.../IgnitePortableCacheFullApiTestSuite.java | 4 +-
.../IgnitePortableCacheTestSuite.java | 4 +-
.../IgnitePortableObjectsTestSuite.java | 2 +-
...niteCacheP2pUnmarshallingQueryErrorTest.java | 6 +-
.../IgnitePortableCacheQueryTestSuite.java | 4 +-
.../Config/Compute/compute-grid1.xml | 46 ++-
.../Config/marshaller-explicit.xml | 8 +-
62 files changed, 925 insertions(+), 1046 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/examples/config/binary/example-ignite-binary.xml
----------------------------------------------------------------------
diff --git a/examples/config/binary/example-ignite-binary.xml b/examples/config/binary/example-ignite-binary.xml
index cde15ea..dbec5e9 100644
--- a/examples/config/binary/example-ignite-binary.xml
+++ b/examples/config/binary/example-ignite-binary.xml
@@ -38,7 +38,7 @@
<bean parent="ignite.cfg">
<!-- Enables portable marshaller -->
<property name="marshaller">
- <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"/>
+ <bean class="org.apache.ignite.marshaller.portable.BinaryMarshaller"/>
</property>
</bean>
</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
index 364bf4b..5eb2670 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteBinary.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.TreeMap;
import java.util.UUID;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
@@ -69,7 +68,7 @@ import org.jetbrains.annotations.Nullable;
* </pre>
* Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized
* typed objects at all times. In this case we do incur the deserialization cost. However, if
- * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access
+ * {@link org.apache.ignite.marshaller.portable.BinaryMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access
* and will cache the deserialized object, so it does not have to be deserialized again:
* <pre name=code class=java>
* IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
@@ -152,7 +151,7 @@ import org.jetbrains.annotations.Nullable;
* <h1 class="header">Configuration</h1>
* By default all your objects are considered as binary and no specific configuration is needed.
* However, in some cases, like when an object is used by both Java and .Net, you may need to specify portable objects
- * explicitly by calling {@link PortableMarshaller#setClassNames(Collection)}.
+ * explicitly by calling {@link org.apache.ignite.marshaller.portable.BinaryMarshaller#setClassNames(Collection)}.
* The only requirement Ignite imposes is that your object has an empty
* constructor. Note, that since server side does not have to know the class definition,
* you only need to list portable objects in configuration on the client side. However, if you
@@ -236,7 +235,7 @@ import org.jetbrains.annotations.Nullable;
* }
* </pre>
* Alternatively, if you cannot change class definitions, you can provide custom serialization
- * logic in {@link org.apache.ignite.binary.BinarySerializer} either globally in {@link PortableMarshaller} or
+ * logic in {@link org.apache.ignite.binary.BinarySerializer} either globally in {@link org.apache.ignite.marshaller.portable.BinaryMarshaller} or
* for a specific type via {@link org.apache.ignite.binary.BinaryTypeConfiguration} instance.
* <p>
* Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods.
@@ -256,7 +255,7 @@ import org.jetbrains.annotations.Nullable;
* internally. However, in cases when you want to provide your own ID mapping schema,
* you can provide your own {@link org.apache.ignite.binary.BinaryIdMapper} implementation.
* <p>
- * ID-mapper may be provided either globally in {@link PortableMarshaller},
+ * ID-mapper may be provided either globally in {@link org.apache.ignite.marshaller.portable.BinaryMarshaller},
* or for a specific type via {@link org.apache.ignite.binary.BinaryTypeConfiguration} instance.
* <h1 class="header">Query Indexing</h1>
* Portable objects can be indexed for querying by specifying index fields in
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 4cb82da..5fcf8a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -55,7 +55,6 @@ import org.apache.ignite.lang.IgniteAsyncSupported;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
import org.jetbrains.annotations.Nullable;
@@ -163,7 +162,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* BinaryObject po = prj.get(1);
* </pre>
* <p>
- * Note that this method makes sense only if cache is working in binary mode ({@link PortableMarshaller} is used).
+ * Note that this method makes sense only if cache is working in binary mode ({@link org.apache.ignite.marshaller.portable.BinaryMarshaller} is used).
* If not, this method is no-op and will return current cache.
*
* @return New cache instance for portable objects.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
index 363b34d..a4a18f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
@@ -17,8 +17,6 @@
package org.apache.ignite.binary;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-
/**
* Type and field ID mapper for binary objects. Ignite never writes full
* strings for field or type names. Instead, for performance reasons, Ignite
@@ -29,7 +27,7 @@ import org.apache.ignite.marshaller.portable.PortableMarshaller;
* actually do collide {@code BinaryIdMapper} allows to override the automatically
* generated hash code IDs for the type and field names.
* <p>
- * Binary ID mapper can be configured for all binary objects via {@link PortableMarshaller#getIdMapper()} method,
+ * Binary ID mapper can be configured for all binary objects via {@link org.apache.ignite.marshaller.portable.BinaryMarshaller#getIdMapper()} method,
* or for a specific binary type via {@link BinaryTypeConfiguration#getIdMapper()} method.
*/
public interface BinaryIdMapper {
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
index f098c16..2691c7b 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.TreeMap;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
/**
* Wrapper for binary object in binary format. Once an object is defined as binary,
@@ -46,9 +45,7 @@ import org.apache.ignite.marshaller.portable.PortableMarshaller;
* String field = val.field("myFieldName");
* </pre>
* Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized
- * typed objects at all times. In this case we do incur the deserialization cost. However, if
- * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access
- * and will cache the deserialized object, so it does not have to be deserialized again:
+ * typed objects at all times. In this case we do incur the deserialization cost.
* <pre name=code class=java>
* IgniteCache<MyKey.class, MyValue.class> cache = grid.cache(null);
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/binary/BinarySerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinarySerializer.java b/modules/core/src/main/java/org/apache/ignite/binary/BinarySerializer.java
index 6fa4237..31b3d30 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinarySerializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinarySerializer.java
@@ -17,15 +17,13 @@
package org.apache.ignite.binary;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-
/**
* Interface that allows to implement custom serialization logic for binary objects.
* Can be used instead of {@link Binarylizable} in case if the class
* cannot be changed directly.
* <p>
* Binary serializer can be configured for all binary objects via
- * {@link PortableMarshaller#getSerializer()} method, or for a specific
+ * {@link org.apache.ignite.marshaller.portable.BinaryMarshaller#getSerializer()} method, or for a specific
* binary type via {@link BinaryTypeConfiguration#getSerializer()} method.
*/
public interface BinarySerializer {
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/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 c737ee2..d216866 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
@@ -17,22 +17,20 @@
package org.apache.ignite.binary;
-import java.util.Collection;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
/**
* Defines configuration properties for a specific binary type. Providing per-type
* configuration is optional, as it is generally enough, and also optional, to provide global binary
- * configuration using {@link PortableMarshaller#setClassNames(Collection)}.
+ * configuration using {@link IgniteConfiguration#setBinaryConfiguration(BinaryConfiguration)}.
* However, this class allows you to change configuration properties for a specific
* binary type without affecting configuration for other binary types.
- * <p>
- * Per-type binary configuration can be specified in {@link PortableMarshaller#getTypeConfigurations()} method.
*/
public class BinaryTypeConfiguration {
/** Class name. */
- private String clsName;
+ private String typeName;
/** ID mapper. */
private BinaryIdMapper idMapper;
@@ -40,9 +38,6 @@ public class BinaryTypeConfiguration {
/** Serializer. */
private BinarySerializer serializer;
- /** Keep deserialized flag. */
- private Boolean keepDeserialized;
-
/**
*/
public BinaryTypeConfiguration() {
@@ -50,10 +45,10 @@ public class BinaryTypeConfiguration {
}
/**
- * @param clsName Class name.
+ * @param typeName Class name.
*/
- public BinaryTypeConfiguration(String clsName) {
- this.clsName = clsName;
+ public BinaryTypeConfiguration(String typeName) {
+ this.typeName = typeName;
}
/**
@@ -61,17 +56,17 @@ public class BinaryTypeConfiguration {
*
* @return Type name.
*/
- public String getClassName() {
- return clsName;
+ public String getTypeName() {
+ return typeName;
}
/**
* Sets type name.
*
- * @param clsName Type name.
+ * @param typeName Type name.
*/
- public void setClassName(String clsName) {
- this.clsName = clsName;
+ public void setTypeName(String typeName) {
+ this.typeName = typeName;
}
/**
@@ -110,24 +105,6 @@ public class BinaryTypeConfiguration {
this.serializer = serializer;
}
- /**
- * Defines whether {@link BinaryObject} should cache deserialized instance. If provided,
- * this value will override {@link PortableMarshaller#isKeepDeserialized()}
- * property.
- *
- * @return Whether deserialized value is kept.
- */
- public Boolean isKeepDeserialized() {
- return keepDeserialized;
- }
-
- /**
- * @param keepDeserialized Whether deserialized value is kept.
- */
- public void setKeepDeserialized(Boolean keepDeserialized) {
- this.keepDeserialized = keepDeserialized;
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(BinaryTypeConfiguration.class, this, super.toString());
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
new file mode 100644
index 0000000..6d8f918
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
@@ -0,0 +1,139 @@
+/*
+ * 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.configuration;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+
+/**
+ * Configuration object for Ignite Binary Objects.
+ * @see org.apache.ignite.IgniteBinary
+ */
+public class BinaryConfiguration {
+ /** Default compact footer flag setting. */
+ public static final boolean DFLT_COMPACT_FOOTER = true;
+
+ /** ID mapper. */
+ private BinaryIdMapper idMapper;
+
+ /** Serializer. */
+ private BinarySerializer serializer;
+
+ /** Types. */
+ private Collection<BinaryTypeConfiguration> typeCfgs;
+
+ /** Compact footer flag. */
+ private boolean compactFooter = DFLT_COMPACT_FOOTER;
+
+ /**
+ * Sets class names of portable objects explicitly.
+ *
+ * @param clsNames Class names.
+ */
+ public void setClassNames(Collection<String> clsNames) {
+ if (typeCfgs == null)
+ typeCfgs = new ArrayList<>(clsNames.size());
+
+ for (String clsName : clsNames)
+ typeCfgs.add(new BinaryTypeConfiguration(clsName));
+ }
+
+ /**
+ * Gets ID mapper.
+ *
+ * @return ID mapper.
+ */
+ public BinaryIdMapper getIdMapper() {
+ return idMapper;
+ }
+
+ /**
+ * Sets ID mapper.
+ *
+ * @param idMapper ID mapper.
+ */
+ public void setIdMapper(BinaryIdMapper idMapper) {
+ this.idMapper = idMapper;
+ }
+
+ /**
+ * Gets serializer.
+ *
+ * @return Serializer.
+ */
+ public BinarySerializer getSerializer() {
+ return serializer;
+ }
+
+ /**
+ * Sets serializer.
+ *
+ * @param serializer Serializer.
+ */
+ public void setSerializer(BinarySerializer serializer) {
+ this.serializer = serializer;
+ }
+
+ /**
+ * Gets types configuration.
+ *
+ * @return Types configuration.
+ */
+ public Collection<BinaryTypeConfiguration> getTypeConfigurations() {
+ return typeCfgs;
+ }
+
+ /**
+ * Sets type configurations.
+ *
+ * @param typeCfgs Type configurations.
+ */
+ public void setTypeConfigurations(Collection<BinaryTypeConfiguration> typeCfgs) {
+ this.typeCfgs = typeCfgs;
+ }
+
+ /**
+ * Get whether to write footers in compact form. When enabled, Ignite will not write fields metadata
+ * when serializing objects, because internally {@code PortableMarshaller} already distribute metadata inside
+ * cluster. This increases serialization performance.
+ * <p>
+ * <b>WARNING!</b> This mode should be disabled when already serialized data can be taken from some external
+ * sources (e.g. cache store which stores data in binary form, data center replication, etc.). Otherwise binary
+ * objects without any associated metadata could appear in the cluster and Ignite will not be able to deserialize
+ * it.
+ * <p>
+ * Defaults to {@link #DFLT_COMPACT_FOOTER}.
+ *
+ * @return Whether to write footers in compact form.
+ */
+ public boolean isCompactFooter() {
+ return compactFooter;
+ }
+
+ /**
+ * Set whether to write footers in compact form. See {@link #isCompactFooter()} for more info.
+ *
+ * @param compactFooter Whether to write footers in compact form.
+ */
+ public void setCompactFooter(boolean compactFooter) {
+ this.compactFooter = compactFooter;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 2069a90..ee9f92a 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -437,6 +437,9 @@ public class IgniteConfiguration {
/** Cache key configuration. */
private CacheKeyConfiguration[] cacheKeyCfg;
+ /** */
+ private BinaryConfiguration binaryCfg;
+
/**
* Creates valid grid configuration with all default values.
*/
@@ -471,6 +474,7 @@ public class IgniteConfiguration {
addrRslvr = cfg.getAddressResolver();
allResolversPassReq = cfg.isAllSegmentationResolversPassRequired();
atomicCfg = cfg.getAtomicConfiguration();
+ binaryCfg = cfg.getBinaryConfiguration();
daemon = cfg.isDaemon();
cacheCfg = cfg.getCacheConfiguration();
cacheKeyCfg = cfg.getCacheKeyConfiguration();
@@ -1360,11 +1364,12 @@ public class IgniteConfiguration {
*
* Default is {@code 1} which has minimal impact on the operation of the grid.
*
- * @param size Size.
+ * @param rebalanceThreadPoolSize Number of system threads that will be assigned for partition transfer during
+ * rebalancing.
* @return {@code this} for chaining.
*/
- public IgniteConfiguration setRebalanceThreadPoolSize(int size) {
- this.rebalanceThreadPoolSize = size;
+ public IgniteConfiguration setRebalanceThreadPoolSize(int rebalanceThreadPoolSize) {
+ this.rebalanceThreadPoolSize = rebalanceThreadPoolSize;
return this;
}
@@ -2004,6 +2009,24 @@ public class IgniteConfiguration {
}
/**
+ * Gets configuration for Ignite Binary objects.
+ *
+ * @return Binary configuration object.
+ */
+ public BinaryConfiguration getBinaryConfiguration() {
+ return binaryCfg;
+ }
+
+ /**
+ * Sets configuration for Ignite Binary objects.
+ *
+ * @param binaryCfg Binary configuration object.
+ */
+ public void setBinaryConfiguration(BinaryConfiguration binaryCfg) {
+ this.binaryCfg = binaryCfg;
+ }
+
+ /**
* Gets flag indicating whether cache sanity check is enabled. If enabled, then Ignite
* will perform the following checks and throw an exception if check fails:
* <ul>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 2e8520e..1779ff0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -76,6 +76,7 @@ import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.cluster.ClusterMetrics;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.CollectionConfiguration;
import org.apache.ignite.configuration.ConnectorConfiguration;
@@ -156,7 +157,6 @@ import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.lifecycle.LifecycleEventType;
import org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
import org.apache.ignite.mxbean.ClusterLocalNodeMetricsMXBean;
import org.apache.ignite.mxbean.IgniteMXBean;
import org.apache.ignite.mxbean.ThreadPoolMXBean;
@@ -1274,8 +1274,9 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
add(ATTR_MARSHALLER_USE_DFLT_SUID,
getBoolean(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, OptimizedMarshaller.USE_DFLT_SUID));
- if (cfg.getMarshaller() instanceof PortableMarshaller)
- add(ATTR_MARSHALLER_COMPACT_FOOTER, ((PortableMarshaller)cfg.getMarshaller()).isCompactFooter());
+ add(ATTR_MARSHALLER_COMPACT_FOOTER, cfg.getBinaryConfiguration() == null ?
+ BinaryConfiguration.DFLT_COMPACT_FOOTER :
+ cfg.getBinaryConfiguration().isCompactFooter());
add(ATTR_USER_NAME, System.getProperty("user.name"));
add(ATTR_GRID_NAME, gridName);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
index 37c88e2..65272b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
@@ -65,8 +65,7 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
* Portable object implementation.
*/
@IgniteCodeGeneratingFail // Fields arr and start should not be generated by MessageCodeGenerator.
-public final class BinaryObjectImpl extends BinaryObjectEx implements Externalizable,
- Message, CacheObject, KeyCacheObject {
+public final class BinaryObjectImpl extends BinaryObjectEx implements Externalizable, KeyCacheObject {
/** */
public static final byte TYPE_BINARY = 100;
@@ -133,7 +132,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
Object obj0 = obj;
if (obj0 == null || cpy)
- obj0 = deserializeValue();
+ obj0 = deserializeValue(ctx);
return (T)obj0;
}
@@ -425,7 +424,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
Object obj0 = obj;
if (obj0 == null)
- obj0 = deserializeValue();
+ obj0 = deserializeValue(null);
return (T)obj0;
@@ -555,7 +554,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
* Runs value deserialization regardless of whether obj already has the deserialized value.
* Will set obj if descriptor is configured to keep deserialized values.
*/
- private Object deserializeValue() {
+ private Object deserializeValue(@Nullable CacheObjectContext coCtx) {
// TODO: IGNITE-1272 - Deserialize with proper class loader.
BinaryReaderExImpl reader = newReader();
@@ -565,7 +564,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
assert desc != null;
- if (desc.keepDeserialized())
+ if (coCtx != null && coCtx.storeValue())
obj = obj0;
return obj0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index c233267..a1720f9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -22,7 +22,6 @@ import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
import org.jetbrains.annotations.Nullable;
import java.io.Externalizable;
@@ -105,9 +104,6 @@ public class PortableClassDescriptor {
private final PortableSchemaRegistry schemaReg;
/** */
- private final boolean keepDeserialized;
-
- /** */
private final boolean registered;
/** */
@@ -126,7 +122,6 @@ public class PortableClassDescriptor {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param metaDataEnabled Metadata enabled flag.
- * @param keepDeserialized Keep deserialized flag.
* @param registered Whether typeId has been successfully registered by MarshallerContext or not.
* @param predefined Whether the class is predefined or not.
* @throws BinaryObjectException In case of error.
@@ -141,7 +136,6 @@ public class PortableClassDescriptor {
@Nullable BinaryIdMapper idMapper,
@Nullable BinarySerializer serializer,
boolean metaDataEnabled,
- boolean keepDeserialized,
boolean registered,
boolean predefined
) throws BinaryObjectException {
@@ -157,7 +151,6 @@ public class PortableClassDescriptor {
this.affKeyFieldName = affKeyFieldName;
this.serializer = serializer;
this.idMapper = idMapper;
- this.keepDeserialized = keepDeserialized;
this.registered = registered;
schemaReg = ctx.schemaRegistry(typeId);
@@ -320,13 +313,6 @@ public class PortableClassDescriptor {
}
/**
- * @return Keep deserialized flag.
- */
- boolean keepDeserialized() {
- return keepDeserialized;
- }
-
- /**
* @return Whether typeId has been successfully registered by MarshallerContext or not.
*/
public boolean registered() {
@@ -334,7 +320,7 @@ public class PortableClassDescriptor {
}
/**
- * @return {@code true} if {@link OptimizedMarshaller} must be used instead of {@link PortableMarshaller}
+ * @return {@code true} if {@link OptimizedMarshaller} must be used instead of {@link org.apache.ignite.marshaller.portable.BinaryMarshaller}
* for object serialization and deserialization.
*/
public boolean useOptimizedMarshaller() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index a88498a..01bc9d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -52,6 +52,7 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.CacheKeyConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.binary.BinaryObjectException;
@@ -70,7 +71,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.marshaller.MarshallerContext;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -126,9 +127,6 @@ public class PortableContext implements Externalizable {
/** */
private final OptimizedMarshaller optmMarsh = new OptimizedMarshaller();
- /** */
- private boolean keepDeserialized;
-
/** Compact footer flag. */
private boolean compactFooter;
@@ -224,61 +222,43 @@ public class PortableContext implements Externalizable {
* @param marsh Portable marshaller.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
- public void configure(PortableMarshaller marsh) throws BinaryObjectException {
+ public void configure(BinaryMarshaller marsh, IgniteConfiguration cfg) throws BinaryObjectException {
if (marsh == null)
return;
- keepDeserialized = marsh.isKeepDeserialized();
-
marshCtx = marsh.getContext();
+ BinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
+
+ if (binaryCfg == null)
+ binaryCfg = new BinaryConfiguration();
+
assert marshCtx != null;
optmMarsh.setContext(marshCtx);
configure(
- marsh.getIdMapper(),
- marsh.getSerializer(),
- marsh.isKeepDeserialized(),
- marsh.getClassNames(),
- marsh.getTypeConfigurations()
+ binaryCfg.getIdMapper(),
+ binaryCfg.getSerializer(),
+ binaryCfg.getTypeConfigurations()
);
- compactFooter = marsh.isCompactFooter();
+ compactFooter = binaryCfg.isCompactFooter();
}
/**
* @param globalIdMapper ID mapper.
* @param globalSerializer Serializer.
- * @param globalKeepDeserialized Keep deserialized flag.
- * @param clsNames Class names.
* @param typeCfgs Type configurations.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
private void configure(
BinaryIdMapper globalIdMapper,
BinarySerializer globalSerializer,
- boolean globalKeepDeserialized,
- Collection<String> clsNames,
Collection<BinaryTypeConfiguration> typeCfgs
) throws BinaryObjectException {
TypeDescriptors descs = new TypeDescriptors();
- if (clsNames != null) {
- BinaryIdMapper idMapper = BinaryInternalIdMapper.create(globalIdMapper);
-
- for (String clsName : clsNames) {
- if (clsName.endsWith(".*")) { // Package wildcard
- String pkgName = clsName.substring(0, clsName.length() - 2);
-
- for (String clsName0 : classesInPackage(pkgName))
- descs.add(clsName0, idMapper, null, null, globalKeepDeserialized, true);
- }
- else // Regular single class
- descs.add(clsName, idMapper, null, null, globalKeepDeserialized, true);
- }
- }
-
Map<String, String> affFields = new HashMap<>();
if (!F.isEmpty(igniteCfg.getCacheKeyConfiguration())) {
@@ -288,7 +268,7 @@ public class PortableContext implements Externalizable {
if (typeCfgs != null) {
for (BinaryTypeConfiguration typeCfg : typeCfgs) {
- String clsName = typeCfg.getClassName();
+ String clsName = typeCfg.getTypeName();
if (clsName == null)
throw new BinaryObjectException("Class name is required for portable type configuration.");
@@ -305,25 +285,21 @@ public class PortableContext implements Externalizable {
if (typeCfg.getSerializer() != null)
serializer = typeCfg.getSerializer();
- boolean keepDeserialized = typeCfg.isKeepDeserialized() != null ? typeCfg.isKeepDeserialized() :
- globalKeepDeserialized;
-
if (clsName.endsWith(".*")) {
String pkgName = clsName.substring(0, clsName.length() - 2);
for (String clsName0 : classesInPackage(pkgName))
descs.add(clsName0, idMapper, serializer, affFields.get(clsName0),
- keepDeserialized, true);
+ true);
}
else
descs.add(clsName, idMapper, serializer, affFields.get(clsName),
- keepDeserialized, false);
+ false);
}
}
for (TypeDescriptor desc : descs.descriptors()) {
- registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName,
- desc.keepDeserialized);
+ registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName);
}
}
@@ -491,7 +467,6 @@ public class PortableContext implements Externalizable {
BinaryInternalIdMapper.defaultInstance(),
null,
false,
- keepDeserialized,
true, /* registered */
false /* predefined */
);
@@ -538,11 +513,14 @@ public class PortableContext implements Externalizable {
idMapper,
null,
true,
- keepDeserialized,
registered,
false /* predefined */
);
+ Collection<PortableSchema> schemas = desc.schema() != null ? Collections.singleton(desc.schema()) : null;
+
+ metaHnd.addMeta(typeId, new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null, schemas).wrap(this));
+
// perform put() instead of putIfAbsent() because "registered" flag might have been changed or class loader
// might have reloaded described class.
if (IgniteUtils.detectClassLoader(cls).equals(dfltLdr))
@@ -552,10 +530,6 @@ public class PortableContext implements Externalizable {
mappers.putIfAbsent(typeId, idMapper);
- Collection<PortableSchema> schemas = desc.schema() != null ? Collections.singleton(desc.schema()) : null;
-
- metaHnd.addMeta(typeId, new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null, schemas).wrap(this));
-
return desc;
}
@@ -679,7 +653,6 @@ public class PortableContext implements Externalizable {
BinaryInternalIdMapper.defaultInstance(),
null,
false,
- false,
true, /* registered */
true /* predefined */
);
@@ -697,15 +670,13 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param keepDeserialized Keep deserialized flag.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
@SuppressWarnings("ErrorNotRethrown")
public void registerUserType(String clsName,
BinaryIdMapper idMapper,
@Nullable BinarySerializer serializer,
- @Nullable String affKeyFieldName,
- boolean keepDeserialized)
+ @Nullable String affKeyFieldName)
throws BinaryObjectException {
assert idMapper != null;
@@ -750,7 +721,6 @@ public class PortableContext implements Externalizable {
idMapper,
serializer,
true,
- keepDeserialized,
true, /* registered */
false /* predefined */
);
@@ -926,7 +896,7 @@ public class PortableContext implements Externalizable {
*/
private static class TypeDescriptors {
/** Descriptors map. */
- private final Map<String, TypeDescriptor> descs = new HashMap<>();
+ private final Map<String, TypeDescriptor> descs = new LinkedHashMap<>();
/**
* Add type descriptor.
@@ -935,7 +905,6 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param keepDeserialized Keep deserialized flag.
* @param canOverride Whether this descriptor can be override.
* @throws org.apache.ignite.binary.BinaryObjectException If failed.
*/
@@ -943,14 +912,12 @@ public class PortableContext implements Externalizable {
BinaryIdMapper idMapper,
BinarySerializer serializer,
String affKeyFieldName,
- boolean keepDeserialized,
boolean canOverride)
throws BinaryObjectException {
TypeDescriptor desc = new TypeDescriptor(clsName,
idMapper,
serializer,
affKeyFieldName,
- keepDeserialized,
canOverride);
TypeDescriptor oldDesc = descs.get(clsName);
@@ -987,9 +954,6 @@ public class PortableContext implements Externalizable {
/** Affinity key field name. */
private String affKeyFieldName;
- /** Keep deserialized flag. */
- private boolean keepDeserialized;
-
/** Whether this descriptor can be override. */
private boolean canOverride;
@@ -1000,16 +964,14 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param keepDeserialized Keep deserialized flag.
* @param canOverride Whether this descriptor can be override.
*/
private TypeDescriptor(String clsName, BinaryIdMapper idMapper, BinarySerializer serializer,
- String affKeyFieldName, boolean keepDeserialized, boolean canOverride) {
+ String affKeyFieldName, boolean canOverride) {
this.clsName = clsName;
this.idMapper = idMapper;
this.serializer = serializer;
this.affKeyFieldName = affKeyFieldName;
- this.keepDeserialized = keepDeserialized;
this.canOverride = canOverride;
}
@@ -1026,7 +988,6 @@ public class PortableContext implements Externalizable {
idMapper = other.idMapper;
serializer = other.serializer;
affKeyFieldName = other.affKeyFieldName;
- keepDeserialized = other.keepDeserialized;
canOverride = other.canOverride;
}
else if (!other.canOverride)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 4fe8d84..4439eee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -112,7 +112,7 @@ import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.spi.IgniteNodeValidationResult;
import org.jetbrains.annotations.Nullable;
@@ -1019,7 +1019,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
// Intentionally compare Boolean references using '!=' below to check if the flag has been explicitly set.
if (cfg.isKeepBinaryInStore() && cfg.isKeepBinaryInStore() != CacheConfiguration.DFLT_KEEP_BINARY_IN_STORE
- && !(ctx.config().getMarshaller() instanceof PortableMarshaller))
+ && !(ctx.config().getMarshaller() instanceof BinaryMarshaller))
U.warn(log, "CacheConfiguration.isKeepBinaryInStore() configuration property will be ignored because " +
"PortableMarshaller is not used");
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
index 551ada5..05e9263 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
@@ -69,7 +69,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import sun.misc.Unsafe;
@@ -157,7 +157,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
- if (marsh instanceof PortableMarshaller) {
+ if (marsh instanceof BinaryMarshaller) {
BinaryMetadataHandler metaHnd = new BinaryMetadataHandler() {
@Override public void addMeta(int typeId, BinaryType newMeta) throws BinaryObjectException {
assert newMeta != null;
@@ -201,11 +201,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
};
- PortableMarshaller pMarh0 = (PortableMarshaller)marsh;
+ BinaryMarshaller pMarh0 = (BinaryMarshaller)marsh;
portableCtx = new PortableContext(metaHnd, ctx.config());
- IgniteUtils.invoke(PortableMarshaller.class, pMarh0, "setPortableContext", portableCtx);
+ IgniteUtils.invoke(BinaryMarshaller.class, pMarh0, "setPortableContext", portableCtx,
+ ctx.config());
portableMarsh = new GridPortableMarshaller(portableCtx);
@@ -272,12 +273,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
}
- startLatch.countDown();
-
for (Map.Entry<Integer, BinaryMetadata> e : metaBuf.entrySet())
addMeta(e.getKey(), e.getValue().wrap(portableCtx));
metaBuf.clear();
+
+ startLatch.countDown();
}
/** {@inheritDoc} */
@@ -544,7 +545,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean isPortableEnabled(CacheConfiguration<?, ?> ccfg) {
- return marsh instanceof PortableMarshaller;
+ return marsh instanceof BinaryMarshaller;
}
/**
@@ -601,7 +602,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@Override public CacheObjectContext contextForCache(CacheConfiguration cfg) throws IgniteCheckedException {
assert cfg != null;
- boolean portableEnabled = marsh instanceof PortableMarshaller && !GridCacheUtils.isSystemCache(cfg.getName()) &&
+ boolean portableEnabled = marsh instanceof BinaryMarshaller && !GridCacheUtils.isSystemCache(cfg.getName()) &&
!GridCacheUtils.isIgfsCache(ctx.config(), cfg.getName());
CacheObjectContext ctx0 = super.contextForCache(cfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
index b84908d..29d5155 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
@@ -23,7 +23,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheStore;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
* Default store manager implementation.
@@ -82,6 +82,6 @@ public class CacheOsStoreManager extends GridCacheStoreManagerAdapter {
/** {@inheritDoc} */
@Override public boolean configuredConvertPortable() {
- return !(ctx.config().getMarshaller() instanceof PortableMarshaller && cfg.isKeepBinaryInStore());
+ return !(ctx.config().getMarshaller() instanceof BinaryMarshaller && cfg.isKeepBinaryInStore());
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index e9cd1e3..b53cc46 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -19,13 +19,14 @@ package org.apache.ignite.internal.processors.platform.cpp;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.platform.cpp.PlatformCppConfiguration;
import java.util.Collections;
@@ -71,20 +72,27 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
Marshaller marsh = igniteCfg.getMarshaller();
if (marsh == null) {
- PortableMarshaller marsh0 = new PortableMarshaller();
-
- marsh0.setCompactFooter(false);
-
- igniteCfg.setMarshaller(marsh0);
+ igniteCfg.setMarshaller(new BinaryMarshaller());
cppCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
- PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
+ BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
}
- else if (!(marsh instanceof PortableMarshaller))
- throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
+ else if (!(marsh instanceof BinaryMarshaller))
+ throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() +
" can be used when running Apache Ignite C++): " + marsh.getClass().getName());
- else if (((PortableMarshaller)marsh).isCompactFooter())
- throw new IgniteException("Unsupported " + PortableMarshaller.class.getName() +
+
+ BinaryConfiguration bCfg = igniteCfg.getBinaryConfiguration();
+
+ if (bCfg == null) {
+ bCfg = new BinaryConfiguration();
+
+ bCfg.setCompactFooter(false);
+
+ igniteCfg.setBinaryConfiguration(bCfg);
+ }
+
+ if (bCfg.isCompactFooter())
+ throw new IgniteException("Unsupported " + BinaryMarshaller.class.getName() +
" \"compactFooter\" flag: must be false when running Apache Ignite C++.");
// Set Ignite home so that marshaller context works.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index a59fd22..a0c5a0b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.platform.dotnet;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
import org.apache.ignite.internal.MarshallerContextImpl;
@@ -36,8 +37,8 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
import java.util.ArrayList;
@@ -92,20 +93,27 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
Marshaller marsh = igniteCfg.getMarshaller();
if (marsh == null) {
- PortableMarshaller marsh0 = new PortableMarshaller();
-
- marsh0.setCompactFooter(false);
-
- igniteCfg.setMarshaller(marsh0);
+ igniteCfg.setMarshaller(new BinaryMarshaller());
dotNetCfg0.warnings(Collections.singleton("Marshaller is automatically set to " +
- PortableMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
+ BinaryMarshaller.class.getName() + " (other nodes must have the same marshaller type)."));
}
- else if (!(marsh instanceof PortableMarshaller))
- throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName() +
+ else if (!(marsh instanceof BinaryMarshaller))
+ throw new IgniteException("Unsupported marshaller (only " + BinaryMarshaller.class.getName() +
" can be used when running Apache Ignite.NET): " + marsh.getClass().getName());
- else if (((PortableMarshaller)marsh).isCompactFooter())
- throw new IgniteException("Unsupported " + PortableMarshaller.class.getName() +
+
+ BinaryConfiguration bCfg = igniteCfg.getBinaryConfiguration();
+
+ if (bCfg == null) {
+ bCfg = new BinaryConfiguration();
+
+ bCfg.setCompactFooter(false);
+
+ igniteCfg.setBinaryConfiguration(bCfg);
+ }
+
+ if (bCfg.isCompactFooter())
+ throw new IgniteException("Unsupported " + BinaryMarshaller.class.getName() +
" \"compactFooter\" flag: must be false when running Apache Ignite.NET.");
// Set Ignite home so that marshaller context works.
@@ -235,11 +243,11 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
try {
PortableContext ctx = new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
marsh.setContext(new MarshallerContextImpl(null));
- ctx.configure(marsh);
+ ctx.configure(marsh, new IgniteConfiguration());
return new GridPortableMarshaller(ctx);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/BinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/BinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/BinaryMarshaller.java
new file mode 100644
index 0000000..455c83e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/BinaryMarshaller.java
@@ -0,0 +1,146 @@
+/*
+ * 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.marshaller.portable;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableContext;
+import org.apache.ignite.marshaller.AbstractMarshaller;
+import org.apache.ignite.marshaller.MarshallerContext;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of {@link org.apache.ignite.marshaller.Marshaller} that lets to serialize and deserialize all objects
+ * in the portable format.
+ * <p>
+ * {@code PortableMarshaller} is tested only on Java HotSpot VM on other VMs it could yield unexpected results.
+ * <p>
+ * <h1 class="header">Configuration</h1>
+ * <h2 class="header">Mandatory</h2>
+ * This marshaller has no mandatory configuration parameters.
+ * <h2 class="header">Java Example</h2>
+ * <pre name="code" class="java">
+ * PortableMarshaller marshaller = new PortableMarshaller();
+ *
+ * IgniteConfiguration cfg = new IgniteConfiguration();
+ *
+ * // Override marshaller.
+ * cfg.setMarshaller(marshaller);
+ *
+ * // Starts grid.
+ * G.start(cfg);
+ * </pre>
+ * <h2 class="header">Spring Example</h2>
+ * PortableMarshaller can be configured from Spring XML configuration file:
+ * <pre name="code" class="xml">
+ * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
+ * ...
+ * <property name="marshaller">
+ * <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
+ * ...
+ * </bean>
+ * </property>
+ * ...
+ * </bean>
+ * </pre>
+ * <p>
+ * <img src="http://ignite.apache.org/images/spring-small.png">
+ * <br>
+ * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
+ */
+public class BinaryMarshaller extends AbstractMarshaller {
+ /** */
+ private GridPortableMarshaller impl;
+
+ /**
+ * Returns currently set {@link MarshallerContext}.
+ *
+ * @return Marshaller context.
+ */
+ public MarshallerContext getContext() {
+ return ctx;
+ }
+
+ /**
+ * Sets {@link PortableContext}.
+ * <p/>
+ * @param ctx Portable context.
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private void setPortableContext(PortableContext ctx, IgniteConfiguration cfg) {
+ ctx.configure(this, cfg);
+
+ impl = new GridPortableMarshaller(ctx);
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException {
+ return impl.marshal(obj);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void marshal(@Nullable Object obj, OutputStream out) throws IgniteCheckedException {
+ byte[] arr = marshal(obj);
+
+ try {
+ out.write(arr);
+ }
+ catch (IOException e) {
+ throw new BinaryObjectException("Failed to marshal the object: " + obj, e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
+ return impl.deserialize(bytes, clsLdr);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
+ ByteArrayOutputStream buf = new ByteArrayOutputStream();
+
+ // we have to fully read the InputStream because GridPortableMarshaller requires support of a method that
+ // returns number of bytes remaining.
+ try {
+ byte[] arr = new byte[4096];
+
+ int cnt;
+
+ while ((cnt = in.read(arr)) != -1)
+ buf.write(arr, 0, cnt);
+
+ buf.flush();
+
+ return impl.deserialize(buf.toByteArray(), clsLdr);
+ }
+ catch (IOException e) {
+ throw new BinaryObjectException("Failed to unmarshal the object from InputStream", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onUndeploy(ClassLoader ldr) {
+ impl.context().onUndeploy(ldr);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
deleted file mode 100644
index 1704c8a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ /dev/null
@@ -1,299 +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.marshaller.portable;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.portable.GridPortableMarshaller;
-import org.apache.ignite.internal.portable.PortableContext;
-import org.apache.ignite.marshaller.AbstractMarshaller;
-import org.apache.ignite.marshaller.MarshallerContext;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinarySerializer;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link org.apache.ignite.marshaller.Marshaller} that lets to serialize and deserialize all objects
- * in the portable format.
- * <p>
- * {@code PortableMarshaller} is tested only on Java HotSpot VM on other VMs it could yield unexpected results.
- * <p>
- * <h1 class="header">Configuration</h1>
- * <h2 class="header">Mandatory</h2>
- * This marshaller has no mandatory configuration parameters.
- * <h2 class="header">Java Example</h2>
- * <pre name="code" class="java">
- * PortableMarshaller marshaller = new PortableMarshaller();
- *
- * IgniteConfiguration cfg = new IgniteConfiguration();
- *
- * // Override marshaller.
- * cfg.setMarshaller(marshaller);
- *
- * // Starts grid.
- * G.start(cfg);
- * </pre>
- * <h2 class="header">Spring Example</h2>
- * PortableMarshaller can be configured from Spring XML configuration file:
- * <pre name="code" class="xml">
- * <bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true">
- * ...
- * <property name="marshaller">
- * <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
- * ...
- * </bean>
- * </property>
- * ...
- * </bean>
- * </pre>
- * <p>
- * <img src="http://ignite.apache.org/images/spring-small.png">
- * <br>
- * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
- */
-public class PortableMarshaller extends AbstractMarshaller {
- /** Default value of "keep deserialized" flag. */
- public static final boolean DFLT_KEEP_DESERIALIZED = true;
-
- /** Default value of "compact footer" flag. */
- public static final boolean DFLT_COMPACT_FOOTER = true;
-
- // TODO ignite-1282 Move to IgniteConfiguration.
- /** Class names. */
- private Collection<String> clsNames;
-
- /** ID mapper. */
- private BinaryIdMapper idMapper;
-
- /** Serializer. */
- private BinarySerializer serializer;
-
- /** Types. */
- private Collection<BinaryTypeConfiguration> typeCfgs;
-
- /** Keep deserialized flag. */
- private boolean keepDeserialized = DFLT_KEEP_DESERIALIZED;
-
- /** Compact footer. */
- private boolean compactFooter = DFLT_COMPACT_FOOTER;
-
- /** */
- private GridPortableMarshaller impl;
-
- /**
- * Gets class names.
- *
- * @return Class names.
- */
- public Collection<String> getClassNames() {
- return clsNames;
- }
-
- /**
- * Sets class names of portable objects explicitly.
- *
- * @param clsNames Class names.
- */
- public void setClassNames(Collection<String> clsNames) {
- this.clsNames = new ArrayList<>(clsNames.size());
-
- for (String clsName : clsNames)
- this.clsNames.add(clsName.trim());
- }
-
- /**
- * Gets ID mapper.
- *
- * @return ID mapper.
- */
- public BinaryIdMapper getIdMapper() {
- return idMapper;
- }
-
- /**
- * Sets ID mapper.
- *
- * @param idMapper ID mapper.
- */
- public void setIdMapper(BinaryIdMapper idMapper) {
- this.idMapper = idMapper;
- }
-
- /**
- * Gets serializer.
- *
- * @return Serializer.
- */
- public BinarySerializer getSerializer() {
- return serializer;
- }
-
- /**
- * Sets serializer.
- *
- * @param serializer Serializer.
- */
- public void setSerializer(BinarySerializer serializer) {
- this.serializer = serializer;
- }
-
- /**
- * Gets types configuration.
- *
- * @return Types configuration.
- */
- public Collection<BinaryTypeConfiguration> getTypeConfigurations() {
- return typeCfgs;
- }
-
- /**
- * Sets type configurations.
- *
- * @param typeCfgs Type configurations.
- */
- public void setTypeConfigurations(Collection<BinaryTypeConfiguration> typeCfgs) {
- this.typeCfgs = typeCfgs;
- }
-
- /**
- * If {@code true}, {@link org.apache.ignite.binary.BinaryObject} will cache deserialized instance after
- * {@link org.apache.ignite.binary.BinaryObject#deserialize()} is called. All consequent calls of this
- * method on the same instance of {@link org.apache.ignite.binary.BinaryObject} will return that cached
- * value without actually deserializing portable object. If you need to override this
- * behaviour for some specific type, use {@link org.apache.ignite.binary.BinaryTypeConfiguration#setKeepDeserialized(Boolean)}
- * method.
- * <p>
- * Default value if {@code true}.
- *
- * @return Whether deserialized value is kept.
- */
- public boolean isKeepDeserialized() {
- return keepDeserialized;
- }
-
- /**
- * @param keepDeserialized Whether deserialized value is kept.
- */
- public void setKeepDeserialized(boolean keepDeserialized) {
- this.keepDeserialized = keepDeserialized;
- }
-
- /**
- * Get whether to write footers in compact form. When enabled, Ignite will not write fields metadata
- * when serializing objects, because internally {@code PortableMarshaller} already distribute metadata inside
- * cluster. This increases serialization performance.
- * <p>
- * <b>WARNING!</b> This mode should be disabled when already serialized data can be taken from some external
- * sources (e.g. cache store which stores data in binary form, data center replication, etc.). Otherwise binary
- * objects without any associated metadata could appear in the cluster and Ignite will not be able to deserialize
- * it.
- * <p>
- * Defaults to {@link #DFLT_COMPACT_FOOTER}.
- *
- * @return Whether to write footers in compact form.
- */
- public boolean isCompactFooter() {
- return compactFooter;
- }
-
- /**
- * Set whether to write footers in compact form. See {@link #isCompactFooter()} for more info.
- *
- * @param compactFooter Whether to write footers in compact form.
- */
- public void setCompactFooter(boolean compactFooter) {
- this.compactFooter = compactFooter;
- }
-
- /**
- * Returns currently set {@link MarshallerContext}.
- *
- * @return Marshaller context.
- */
- public MarshallerContext getContext() {
- return ctx;
- }
-
- /**
- * Sets {@link PortableContext}.
- * <p/>
- * @param ctx Portable context.
- */
- @SuppressWarnings("UnusedDeclaration")
- private void setPortableContext(PortableContext ctx) {
- ctx.configure(this);
-
- impl = new GridPortableMarshaller(ctx);
- }
-
- /** {@inheritDoc} */
- @Override public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException {
- return impl.marshal(obj);
- }
-
- /** {@inheritDoc} */
- @Override public void marshal(@Nullable Object obj, OutputStream out) throws IgniteCheckedException {
- byte[] arr = marshal(obj);
-
- try {
- out.write(arr);
- }
- catch (IOException e) {
- throw new BinaryObjectException("Failed to marshal the object: " + obj, e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public <T> T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
- return impl.deserialize(bytes, clsLdr);
- }
-
- /** {@inheritDoc} */
- @Override public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
- ByteArrayOutputStream buf = new ByteArrayOutputStream();
-
- byte[] arr = new byte[4096];
- int cnt;
-
- // we have to fully read the InputStream because GridPortableMarshaller requires support of a method that
- // returns number of bytes remaining.
- try {
- while ((cnt = in.read(arr)) != -1)
- buf.write(arr, 0, cnt);
-
- buf.flush();
-
- return impl.deserialize(buf.toByteArray(), clsLdr);
- }
- catch (IOException e) {
- throw new BinaryObjectException("Failed to unmarshal the object from InputStream", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void onUndeploy(ClassLoader ldr) {
- impl.context().onUndeploy(ldr);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 4b2c8ee..94deec2 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -292,13 +292,14 @@ org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage
org.apache.ignite.internal.managers.indexing.GridIndexingManager$1
org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerAdapter
org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1
-org.apache.ignite.internal.portable.BinaryMetaDataImpl
+org.apache.ignite.internal.portable.BinaryMetadata
org.apache.ignite.internal.portable.BinaryObjectEx
org.apache.ignite.internal.portable.BinaryObjectImpl
org.apache.ignite.internal.portable.BinaryObjectOffheapImpl
org.apache.ignite.internal.portable.BinaryReaderExImpl$Flag
org.apache.ignite.internal.portable.PortableClassDescriptor$Mode
org.apache.ignite.internal.portable.PortableContext
+org.apache.ignite.internal.portable.PortableSchema
org.apache.ignite.internal.portable.builder.PortableLazyMap$1$1$1
org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion
org.apache.ignite.internal.processors.affinity.GridAffinityAssignment
@@ -434,6 +435,7 @@ org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$3
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$4
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$5
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$6
+org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$7
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeFutureSet
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$MessageHandler
org.apache.ignite.internal.processors.cache.GridCacheProcessor$2
@@ -542,7 +544,7 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtGetFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtGetFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtGetFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException
-org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition$4
+org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$3
@@ -577,7 +579,6 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFutu
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$4
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$5
-org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$6
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxRemote
@@ -636,16 +637,18 @@ org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtFor
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysRequest
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysResponse
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandPool$1
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandPool$2$1
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandPool$DemandWorker$1
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandPool$DemandWorker$2
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander$1
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander$2
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander$4$1
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander$DemandWorker$1
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander$DemandWorker$2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$1
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$SupplyContextPhase
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyPool$1
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyPool$DemandMessage
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture$2
@@ -654,7 +657,6 @@ org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPar
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleRequest
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader$10
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader$2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader$3
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader$4
@@ -739,10 +741,11 @@ org.apache.ignite.internal.processors.cache.local.atomic.GridLocalAtomicCache$9
org.apache.ignite.internal.processors.cache.portable.CacheDefaultPortableAffinityKeyMapper
org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$1
org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$4
+org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$5
org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$MetaDataEntryFilter
org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$MetaDataPredicate
-org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$MetaDataProcessor
-org.apache.ignite.internal.processors.cache.portable.PortableMetaDataKey
+org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl$MetadataProcessor
+org.apache.ignite.internal.processors.cache.portable.PortableMetadataKey
org.apache.ignite.internal.processors.cache.query.CacheQueryType
org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryFuture$1
org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryFuture$3
@@ -1158,7 +1161,8 @@ org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandle
org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$GetAndRemoveCommand
org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$GetAndReplaceCommand
org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$GetCommand
-org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$MetadataCommand
+org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$MetadataJob
+org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$MetadataTask
org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$MetricsCommand
org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$PrependCommand
org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheCommandHandler$PutAllCommand
@@ -1174,6 +1178,7 @@ org.apache.ignite.internal.processors.rest.handlers.cache.GridCacheRestResponse
org.apache.ignite.internal.processors.rest.handlers.datastructures.DataStructuresCommandHandler$1
org.apache.ignite.internal.processors.rest.handlers.query.CacheQueryFieldsMetaResult
org.apache.ignite.internal.processors.rest.handlers.query.CacheQueryResult
+org.apache.ignite.internal.processors.rest.handlers.query.QueryCommandHandler$QueryCursorIterator
org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler$2
org.apache.ignite.internal.processors.rest.handlers.task.GridTaskCommandHandler$ExeCallable
org.apache.ignite.internal.processors.rest.handlers.task.GridTaskResultRequest
[38/55] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/ignite-1282' into ignite-1282
Posted by ag...@apache.org.
Merge remote-tracking branch 'origin/ignite-1282' into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0d56b41c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0d56b41c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0d56b41c
Branch: refs/heads/ignite-1.5
Commit: 0d56b41ca0beee7929a2bd02293b84f42f34b8eb
Parents: 462f833 c505f48
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 13:01:58 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 13:01:58 2015 +0300
----------------------------------------------------------------------
.../config/binary/example-ignite-binary.xml | 2 +-
.../java/org/apache/ignite/IgniteBinary.java | 9 +-
.../java/org/apache/ignite/IgniteCache.java | 3 +-
.../apache/ignite/binary/BinaryIdMapper.java | 4 +-
.../org/apache/ignite/binary/BinaryObject.java | 5 +-
.../apache/ignite/binary/BinarySerializer.java | 4 +-
.../ignite/binary/BinaryTypeConfiguration.java | 47 +--
.../configuration/BinaryConfiguration.java | 139 +++++++
.../configuration/IgniteConfiguration.java | 29 +-
.../apache/ignite/internal/IgniteKernal.java | 7 +-
.../internal/portable/BinaryObjectImpl.java | 11 +-
.../portable/PortableClassDescriptor.java | 16 +-
.../internal/portable/PortableContext.java | 85 ++--
.../processors/cache/GridCacheProcessor.java | 4 +-
.../CacheObjectBinaryProcessorImpl.java | 17 +-
.../cache/store/CacheOsStoreManager.java | 4 +-
.../cpp/PlatformCppConfigurationClosure.java | 30 +-
.../PlatformDotNetConfigurationClosure.java | 34 +-
.../marshaller/portable/BinaryMarshaller.java | 146 +++++++
.../marshaller/portable/PortableMarshaller.java | 299 --------------
.../resources/META-INF/classnames.properties | 31 +-
.../portable/BinaryFieldsAbstractSelfTest.java | 33 +-
.../portable/BinaryFieldsHeapSelfTest.java | 4 +-
.../portable/BinaryFieldsOffheapSelfTest.java | 4 +-
.../BinaryFooterOffsetsAbstractSelfTest.java | 27 +-
.../BinaryFooterOffsetsHeapSelfTest.java | 4 +-
.../BinaryFooterOffsetsOffheapSelfTest.java | 4 +-
.../portable/BinaryMarshallerSelfTest.java | 402 +++++++------------
.../BinaryObjectBuilderAdditionalSelfTest.java | 13 +-
.../portable/BinaryObjectBuilderSelfTest.java | 43 +-
.../GridPortableAffinityKeySelfTest.java | 13 +-
...idPortableMarshallerCtxDisabledSelfTest.java | 10 +-
.../portable/GridPortableMetaDataSelfTest.java | 13 +-
.../portable/GridPortableWildcardsSelfTest.java | 243 ++++++-----
.../BinaryFieldsHeapNonCompactSelfTest.java | 4 -
...IgniteCacheAbstractExecutionContextTest.java | 4 +-
.../IgniteCacheTxExecutionContextTest.java | 2 -
...naryObjectsAbstractDataStreamerSelfTest.java | 10 +-
...aryObjectsAbstractMultiThreadedSelfTest.java | 10 +-
.../GridCacheBinaryObjectsAbstractSelfTest.java | 4 +-
...ntNodeBinaryObjectMetadataMultinodeTest.java | 4 +-
...CacheClientNodeBinaryObjectMetadataTest.java | 19 +-
.../GridCachePortableStoreAbstractSelfTest.java | 11 +-
...ridPortableCacheEntryMemorySizeSelfTest.java | 10 +-
...leDuplicateIndexObjectsAbstractSelfTest.java | 11 +-
.../DataStreamProcessorPortableSelfTest.java | 4 +-
.../GridDataStreamerImplSelfTest.java | 4 +-
...ridCacheAffinityRoutingPortableSelfTest.java | 13 +-
.../GridCacheMemoryModePortableSelfTest.java | 4 +-
...acheOffHeapTieredAtomicPortableSelfTest.java | 9 +-
...eapTieredEvictionAtomicPortableSelfTest.java | 9 +-
...heOffHeapTieredEvictionPortableSelfTest.java | 9 +-
.../GridCacheOffHeapTieredPortableSelfTest.java | 9 +-
...sNearPartitionedByteArrayValuesSelfTest.java | 4 +-
...sPartitionedOnlyByteArrayValuesSelfTest.java | 4 +-
.../IgnitePortableCacheFullApiTestSuite.java | 4 +-
.../IgnitePortableCacheTestSuite.java | 4 +-
.../IgnitePortableObjectsTestSuite.java | 2 +-
...niteCacheP2pUnmarshallingQueryErrorTest.java | 6 +-
.../IgnitePortableCacheQueryTestSuite.java | 4 +-
.../Config/Compute/compute-grid1.xml | 46 ++-
.../Config/marshaller-explicit.xml | 8 +-
62 files changed, 925 insertions(+), 1046 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0d56b41c/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
[41/55] [abbrv] ignite git commit: Merge branch 'ignite-1282' of
https://git-wip-us.apache.org/repos/asf/ignite into ignite-1282
Posted by ag...@apache.org.
Merge branch 'ignite-1282' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6d4ecfde
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6d4ecfde
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6d4ecfde
Branch: refs/heads/ignite-1.5
Commit: 6d4ecfde78f94dd52834306d14deeaec63a46359
Parents: 9b6adb2 0d56b41
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 14:04:57 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 14:04:57 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryWriterExImpl.java | 101 ++++++++++++-------
.../portable/PortableClassDescriptor.java | 45 ++++-----
.../ignite/internal/portable/PortableUtils.java | 32 +-----
.../builder/BinaryObjectBuilderImpl.java | 8 +-
.../streams/PortableAbstractOutputStream.java | 7 +-
.../portable/streams/PortableOutputStream.java | 7 ++
.../memory/PlatformOutputStreamImpl.java | 7 +-
7 files changed, 107 insertions(+), 100 deletions(-)
----------------------------------------------------------------------
[54/55] [abbrv] ignite git commit: Add the attribute only if binary
marshaller is used.
Posted by ag...@apache.org.
Add the attribute only if binary marshaller is used.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/df859c0a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/df859c0a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/df859c0a
Branch: refs/heads/ignite-1.5
Commit: df859c0a1b3c493d7df56a3e76699cac6169a06a
Parents: 802d48b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Sat Nov 21 15:17:06 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Sat Nov 21 15:17:06 2015 +0300
----------------------------------------------------------------------
.../main/java/org/apache/ignite/internal/IgniteKernal.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/df859c0a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 249564a..082ffa5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -158,6 +158,7 @@ import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.lifecycle.LifecycleEventType;
import org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.mxbean.ClusterLocalNodeMetricsMXBean;
import org.apache.ignite.mxbean.IgniteMXBean;
import org.apache.ignite.mxbean.ThreadPoolMXBean;
@@ -1276,9 +1277,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
add(ATTR_MARSHALLER_USE_DFLT_SUID,
getBoolean(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, OptimizedMarshaller.USE_DFLT_SUID));
- add(ATTR_MARSHALLER_COMPACT_FOOTER, cfg.getBinaryConfiguration() == null ?
- BinaryConfiguration.DFLT_COMPACT_FOOTER :
- cfg.getBinaryConfiguration().isCompactFooter());
+ if (cfg.getMarshaller() instanceof BinaryMarshaller) {
+ add(ATTR_MARSHALLER_COMPACT_FOOTER, cfg.getBinaryConfiguration() == null ?
+ BinaryConfiguration.DFLT_COMPACT_FOOTER :
+ cfg.getBinaryConfiguration().isCompactFooter());
+ }
add(ATTR_USER_NAME, System.getProperty("user.name"));
add(ATTR_GRID_NAME, gridName);
[12/55] [abbrv] ignite git commit: IGNITE-1847: GIT failed to change
class name casing (1/2).
Posted by ag...@apache.org.
IGNITE-1847: GIT failed to change class name casing (1/2).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a0efe760
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a0efe760
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a0efe760
Branch: refs/heads/ignite-1.5
Commit: a0efe76068eb6c802e5c228d9b5734722b82f5ad
Parents: 63d5506
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 18 10:30:11 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 18 10:30:11 2015 +0300
----------------------------------------------------------------------
.../portable/BinaryMetaDataCollector.java | 254 -------------------
.../portable/BinaryMetadataCollector2.java | 254 +++++++++++++++++++
.../portable/PortableClassDescriptor.java | 2 +-
.../CacheObjectBinaryProcessorImpl.java | 44 ++--
.../cache/portable/PortableMetaDataKey.java | 82 ------
.../cache/portable/PortableMetadataKey2.java | 82 ++++++
6 files changed, 359 insertions(+), 359 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a0efe760/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java
deleted file mode 100644
index 67e1a0d..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Writer for meta data collection.
- */
-class BinaryMetadataCollector implements BinaryWriter {
- /** */
- private final Map<String, Integer> meta = new HashMap<>();
-
- /** */
- private final String typeName;
-
- /**
- * @param typeName Type name.
- */
- BinaryMetadataCollector(String typeName) {
- this.typeName = typeName;
- }
-
- /**
- * @return Field meta data.
- */
- Map<String, Integer> meta() {
- return meta;
- }
-
- /** {@inheritDoc} */
- @Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BYTE);
- }
-
- /** {@inheritDoc} */
- @Override public void writeShort(String fieldName, short val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.SHORT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeInt(String fieldName, int val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.INT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeLong(String fieldName, long val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.LONG);
- }
-
- /** {@inheritDoc} */
- @Override public void writeFloat(String fieldName, float val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.FLOAT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDouble(String fieldName, double val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DOUBLE);
- }
-
- /** {@inheritDoc} */
- @Override public void writeChar(String fieldName, char val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.CHAR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BOOLEAN);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL);
- }
-
- /** {@inheritDoc} */
- @Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.STRING);
- }
-
- /** {@inheritDoc} */
- @Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.UUID);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DATE);
- }
-
- /** {@inheritDoc} */
- @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP);
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.ENUM);
- }
-
- /** {@inheritDoc} */
- @Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.ENUM_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.OBJECT);
- }
-
- /** {@inheritDoc} */
- @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BYTE_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.SHORT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.INT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.LONG_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.FLOAT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DOUBLE_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.CHAR_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.BOOLEAN_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeStringArray(String fieldName, @Nullable String[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.STRING_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.UUID_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DATE_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.OBJECT_ARR);
- }
-
- /** {@inheritDoc} */
- @Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
- throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.COL);
- }
-
- /** {@inheritDoc} */
- @Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.MAP);
- }
-
- /** {@inheritDoc} */
- @Override public BinaryRawWriter rawWriter() {
- return (BinaryRawWriter)Proxy.newProxyInstance(getClass().getClassLoader(),
- new Class<?>[] { BinaryRawWriterEx.class },
- new InvocationHandler() {
- @Override public Object invoke(Object proxy, Method mtd, Object[] args) throws Throwable {
- return null;
- }
- });
- }
-
- /**
- * @param name Field name.
- * @param mode Field mode.
- * @throws BinaryObjectException In case of error.
- */
- private void add(String name, PortableClassDescriptor.Mode mode) throws BinaryObjectException {
- assert name != null;
-
- int fieldTypeId = mode.typeId();
-
- Integer oldFieldTypeId = meta.put(name, fieldTypeId);
-
- if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) {
- throw new BinaryObjectException(
- "Field is written twice with different types [" +
- "typeName=" + typeName +
- ", fieldName=" + name +
- ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldTypeId) +
- ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) +
- ']'
- );
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a0efe760/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java
new file mode 100644
index 0000000..701c619
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector2.java
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Writer for meta data collection.
+ */
+class BinaryMetadataCollector2 implements BinaryWriter {
+ /** */
+ private final Map<String, Integer> meta = new HashMap<>();
+
+ /** */
+ private final String typeName;
+
+ /**
+ * @param typeName Type name.
+ */
+ BinaryMetadataCollector2(String typeName) {
+ this.typeName = typeName;
+ }
+
+ /**
+ * @return Field meta data.
+ */
+ Map<String, Integer> meta() {
+ return meta;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BYTE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShort(String fieldName, short val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.SHORT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeInt(String fieldName, int val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.INT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLong(String fieldName, long val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.LONG);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeFloat(String fieldName, float val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.FLOAT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDouble(String fieldName, double val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DOUBLE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeChar(String fieldName, char val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.CHAR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BOOLEAN);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DECIMAL);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.STRING);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.UUID);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DATE);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.ENUM);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.ENUM_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.OBJECT);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BYTE_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.SHORT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.INT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.LONG_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.FLOAT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DOUBLE_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.CHAR_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.BOOLEAN_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeStringArray(String fieldName, @Nullable String[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.STRING_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.UUID_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.DATE_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.OBJECT_ARR);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
+ throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.COL);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws BinaryObjectException {
+ add(fieldName, PortableClassDescriptor.Mode.MAP);
+ }
+
+ /** {@inheritDoc} */
+ @Override public BinaryRawWriter rawWriter() {
+ return (BinaryRawWriter)Proxy.newProxyInstance(getClass().getClassLoader(),
+ new Class<?>[] { BinaryRawWriterEx.class },
+ new InvocationHandler() {
+ @Override public Object invoke(Object proxy, Method mtd, Object[] args) throws Throwable {
+ return null;
+ }
+ });
+ }
+
+ /**
+ * @param name Field name.
+ * @param mode Field mode.
+ * @throws BinaryObjectException In case of error.
+ */
+ private void add(String name, PortableClassDescriptor.Mode mode) throws BinaryObjectException {
+ assert name != null;
+
+ int fieldTypeId = mode.typeId();
+
+ Integer oldFieldTypeId = meta.put(name, fieldTypeId);
+
+ if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) {
+ throw new BinaryObjectException(
+ "Field is written twice with different types [" +
+ "typeName=" + typeName +
+ ", fieldName=" + name +
+ ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldTypeId) +
+ ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) +
+ ']'
+ );
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a0efe760/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 225e0ba..7fa6bc3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -546,7 +546,7 @@ public class PortableClassDescriptor {
if (obj.getClass() != BinaryMetadata.class
&& ctx.isMetaDataChanged(typeId, writer.metaDataHashSum())) {
- BinaryMetadataCollector metaCollector = new BinaryMetadataCollector(typeName);
+ BinaryMetadataCollector2 metaCollector = new BinaryMetadataCollector2(typeName);
if (serializer != null)
serializer.writeBinary(obj, metaCollector);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a0efe760/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
index 117eece..e6eb494 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
@@ -110,7 +110,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private final boolean clientNode;
/** */
- private volatile IgniteCacheProxy<PortableMetadataKey, BinaryMetadata> metaDataCache;
+ private volatile IgniteCacheProxy<PortableMetadataKey2, BinaryMetadata> metaDataCache;
/** */
private final ConcurrentHashMap8<Integer, BinaryTypeImpl> clientMetaDataCache;
@@ -120,7 +120,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private static final long serialVersionUID = 0L;
@Override public boolean apply(GridCacheEntryEx e) {
- return e.key().value(e.context().cacheObjectContext(), false) instanceof PortableMetadataKey;
+ return e.key().value(e.context().cacheObjectContext(), false) instanceof PortableMetadataKey2;
}
};
@@ -238,7 +238,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
GridCacheQueryManager qryMgr = metaDataCache.context().queries();
- CacheQuery<Map.Entry<PortableMetadataKey, BinaryMetadata>> qry =
+ CacheQuery<Map.Entry<PortableMetadataKey2, BinaryMetadata>> qry =
qryMgr.createScanQuery(new MetaDataPredicate(), null, false);
qry.keepAll(false);
@@ -246,9 +246,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
qry.projection(ctx.cluster().get().forNode(oldestSrvNode));
try {
- CacheQueryFuture<Map.Entry<PortableMetadataKey, BinaryMetadata>> fut = qry.execute();
+ CacheQueryFuture<Map.Entry<PortableMetadataKey2, BinaryMetadata>> fut = qry.execute();
- Map.Entry<PortableMetadataKey, BinaryMetadata> next;
+ Map.Entry<PortableMetadataKey2, BinaryMetadata> next;
while ((next = fut.next()) != null) {
assert next.getKey() != null : next;
@@ -294,7 +294,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
* @param key Metadata key.
* @param newMeta Metadata.
*/
- private void addClientCacheMetaData(PortableMetadataKey key, final BinaryMetadata newMeta) {
+ private void addClientCacheMetaData(PortableMetadataKey2 key, final BinaryMetadata newMeta) {
int key0 = key.typeId();
clientMetaDataCache.compute(key0,
@@ -460,7 +460,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
BinaryMetadata newMeta0 = ((BinaryTypeImpl)newMeta).metadata();
- final PortableMetadataKey key = new PortableMetadataKey(typeId);
+ final PortableMetadataKey2 key = new PortableMetadataKey2(typeId);
try {
BinaryMetadata oldMeta = metaDataCache.localPeek(key);
@@ -483,7 +483,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
if (clientNode)
return clientMetaDataCache.get(typeId);
else {
- BinaryMetadata meta = metaDataCache.localPeek(new PortableMetadataKey(typeId));
+ BinaryMetadata meta = metaDataCache.localPeek(new PortableMetadataKey2(typeId));
return meta != null ? meta.wrap(portableCtx) : null;
}
@@ -497,16 +497,16 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@Override public Map<Integer, BinaryType> metadata(Collection<Integer> typeIds)
throws BinaryObjectException {
try {
- Collection<PortableMetadataKey> keys = new ArrayList<>(typeIds.size());
+ Collection<PortableMetadataKey2> keys = new ArrayList<>(typeIds.size());
for (Integer typeId : typeIds)
- keys.add(new PortableMetadataKey(typeId));
+ keys.add(new PortableMetadataKey2(typeId));
- Map<PortableMetadataKey, BinaryMetadata> meta = metaDataCache.getAll(keys);
+ Map<PortableMetadataKey2, BinaryMetadata> meta = metaDataCache.getAll(keys);
Map<Integer, BinaryType> res = U.newHashMap(meta.size());
- for (Map.Entry<PortableMetadataKey, BinaryMetadata> e : meta.entrySet())
+ for (Map.Entry<PortableMetadataKey2, BinaryMetadata> e : meta.entrySet())
res.put(e.getKey().typeId(), e.getValue().wrap(portableCtx));
return res;
@@ -527,10 +527,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
});
else {
return F.viewReadOnly(metaDataCache.entrySetx(metaPred),
- new C1<Cache.Entry<PortableMetadataKey, BinaryMetadata>, BinaryType>() {
+ new C1<Cache.Entry<PortableMetadataKey2, BinaryMetadata>, BinaryType>() {
private static final long serialVersionUID = 0L;
- @Override public BinaryType apply(Cache.Entry<PortableMetadataKey, BinaryMetadata> e) {
+ @Override public BinaryType apply(Cache.Entry<PortableMetadataKey2, BinaryMetadata> e) {
return e.getValue().wrap(portableCtx);
}
});
@@ -799,7 +799,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
*/
private static class MetaDataProcessor implements
- EntryProcessor<PortableMetadataKey, BinaryMetadata, BinaryObjectException>, Externalizable {
+ EntryProcessor<PortableMetadataKey2, BinaryMetadata, BinaryObjectException>, Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -829,7 +829,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public BinaryObjectException process(
- MutableEntry<PortableMetadataKey, BinaryMetadata> entry,
+ MutableEntry<PortableMetadataKey2, BinaryMetadata> entry,
Object... args) {
try {
BinaryMetadata oldMeta = entry.getValue();
@@ -873,15 +873,15 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
*
*/
- class MetaDataEntryListener implements CacheEntryUpdatedListener<PortableMetadataKey, BinaryMetadata> {
+ class MetaDataEntryListener implements CacheEntryUpdatedListener<PortableMetadataKey2, BinaryMetadata> {
/** {@inheritDoc} */
@Override public void onUpdated(
- Iterable<CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata>> evts)
+ Iterable<CacheEntryEvent<? extends PortableMetadataKey2, ? extends BinaryMetadata>> evts)
throws CacheEntryListenerException {
- for (CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata> evt : evts) {
+ for (CacheEntryEvent<? extends PortableMetadataKey2, ? extends BinaryMetadata> evt : evts) {
assert evt.getEventType() == EventType.CREATED || evt.getEventType() == EventType.UPDATED : evt;
- PortableMetadataKey key = evt.getKey();
+ PortableMetadataKey2 key = evt.getKey();
final BinaryMetadata newMeta = evt.getValue();
@@ -906,7 +906,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean evaluate(CacheEntryEvent<?, ?> evt) throws CacheEntryListenerException {
- return evt.getKey() instanceof PortableMetadataKey;
+ return evt.getKey() instanceof PortableMetadataKey2;
}
/** {@inheritDoc} */
@@ -924,7 +924,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean apply(Object key, Object val) {
- return key instanceof PortableMetadataKey;
+ return key instanceof PortableMetadataKey2;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a0efe760/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java
deleted file mode 100644
index f838c82..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java
+++ /dev/null
@@ -1,82 +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.processors.cache.portable;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Key for portable meta data.
- */
-class PortableMetadataKey extends GridCacheUtilityKey<PortableMetadataKey> implements Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private int typeId;
-
- /**
- * For {@link Externalizable}.
- */
- public PortableMetadataKey() {
- // No-op.
- }
-
- /**
- * @param typeId Type ID.
- */
- PortableMetadataKey(int typeId) {
- this.typeId = typeId;
- }
-
- /**
- * @return Type id.
- */
- public int typeId() {
- return typeId;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeInt(typeId);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- typeId = in.readInt();
- }
-
- /** {@inheritDoc} */
- @Override protected boolean equalsx(PortableMetadataKey key) {
- return typeId == key.typeId;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return typeId;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(PortableMetadataKey.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a0efe760/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java
new file mode 100644
index 0000000..4c99b70
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetadataKey2.java
@@ -0,0 +1,82 @@
+/*
+ * 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.processors.cache.portable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.internal.processors.cache.GridCacheUtilityKey;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Key for portable meta data.
+ */
+class PortableMetadataKey2 extends GridCacheUtilityKey<PortableMetadataKey2> implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private int typeId;
+
+ /**
+ * For {@link Externalizable}.
+ */
+ public PortableMetadataKey2() {
+ // No-op.
+ }
+
+ /**
+ * @param typeId Type ID.
+ */
+ PortableMetadataKey2(int typeId) {
+ this.typeId = typeId;
+ }
+
+ /**
+ * @return Type id.
+ */
+ public int typeId() {
+ return typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(typeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ typeId = in.readInt();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean equalsx(PortableMetadataKey2 key) {
+ return typeId == key.typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return typeId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(PortableMetadataKey2.class, this);
+ }
+}
\ No newline at end of file
[02/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
deleted file mode 100644
index 150110f..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ /dev/null
@@ -1,2157 +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.
- */
-
-// ReSharper disable NonReadonlyMemberInGetHashCode
-// ReSharper disable CompareOfFloatsByEqualityOperator
-// ReSharper disable PossibleInvalidOperationException
-// ReSharper disable UnusedAutoPropertyAccessor.Global
-// ReSharper disable MemberCanBePrivate.Global
-namespace Apache.Ignite.Core.Tests.Portable
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- 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;
-
- /// <summary>
- ///
- /// </summary>
- [TestFixture]
- public class PortableSelfTest {
- /** */
- private Marshaller _marsh;
-
- /// <summary>
- ///
- /// </summary>
- [TestFixtureSetUp]
- public void BeforeTest()
- {
- _marsh = new Marshaller(null);
- }
-
- /**
- * <summary>Check write of primitive boolean.</summary>
- */
- [Test]
- public void TestWritePrimitiveBool()
- {
- Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(false)), false);
- Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(true)), true);
-
- Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)false)), false);
- Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive boolean array.</summary>
- */
- [Test]
- public void TestWritePrimitiveBoolArray()
- {
- bool[] vals = { true, false };
-
- Assert.AreEqual(_marsh.Unmarshal<bool[]>(_marsh.Marshal(vals)), vals);
-
- bool?[] vals2 = { true, false };
-
- Assert.AreEqual(_marsh.Unmarshal<bool?[]>(_marsh.Marshal(vals2)), vals2);
- }
-
- /**
- * <summary>Check write of primitive sbyte.</summary>
- */
- [Test]
- public void TestWritePrimitiveSbyte()
- {
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal((sbyte)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MinValue)), sbyte.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MaxValue)), sbyte.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)1)), (sbyte?)1);
- Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive sbyte array.</summary>
- */
- [Test]
- public void TestWritePrimitiveSbyteArray()
- {
- sbyte[] vals = { sbyte.MinValue, 0, 1, sbyte.MaxValue };
- sbyte[] newVals = _marsh.Unmarshal<sbyte[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive byte.</summary>
- */
- [Test]
- public void TestWritePrimitiveByte()
- {
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal((byte)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MinValue)), byte.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MaxValue)), byte.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)1)), (byte?)1);
- Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive byte array.</summary>
- */
- [Test]
- public void TestWritePrimitiveByteArray()
- {
- byte[] vals = { byte.MinValue, 0, 1, byte.MaxValue };
- byte[] newVals = _marsh.Unmarshal<byte[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive short.</summary>
- */
- [Test]
- public void TestWritePrimitiveShort()
- {
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal((short)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MinValue)), short.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MaxValue)), short.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)1)), (short?)1);
- Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive short array.</summary>
- */
- [Test]
- public void TestWritePrimitiveShortArray()
- {
- short[] vals = { short.MinValue, 0, 1, short.MaxValue };
- short[] newVals = _marsh.Unmarshal<short[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive ushort.</summary>
- */
- [Test]
- public void TestWritePrimitiveUshort()
- {
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal((ushort)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MinValue)), ushort.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MaxValue)), ushort.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)1)), (ushort?)1);
- Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive short array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUshortArray()
- {
- ushort[] vals = { ushort.MinValue, 0, 1, ushort.MaxValue };
- ushort[] newVals = _marsh.Unmarshal<ushort[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive char.</summary>
- */
- [Test]
- public void TestWritePrimitiveChar()
- {
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal((char)1)), (char)1);
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MinValue)), char.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MaxValue)), char.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)1)), (char?)1);
- Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveCharArray()
- {
- char[] vals = { char.MinValue, (char)0, (char)1, char.MaxValue };
- char[] newVals = _marsh.Unmarshal<char[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive int.</summary>
- */
- [Test]
- public void TestWritePrimitiveInt()
- {
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MinValue)), int.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MaxValue)), int.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveIntArray()
- {
- int[] vals = { int.MinValue, 0, 1, int.MaxValue };
- int[] newVals = _marsh.Unmarshal<int[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive uint.</summary>
- */
- [Test]
- public void TestWritePrimitiveUint()
- {
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal((uint)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MinValue)), uint.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MaxValue)), uint.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)1)), (int?)1);
- Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive uint array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUintArray()
- {
- uint[] vals = { uint.MinValue, 0, 1, uint.MaxValue };
- uint[] newVals = _marsh.Unmarshal<uint[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive long.</summary>
- */
- [Test]
- public void TestWritePrimitiveLong()
- {
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal((long)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MinValue)), long.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MaxValue)), long.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)1)), (long?)1);
- Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive long array.</summary>
- */
- [Test]
- public void TestWritePrimitiveLongArray()
- {
- long[] vals = { long.MinValue, 0, 1, long.MaxValue };
- long[] newVals = _marsh.Unmarshal<long[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive ulong.</summary>
- */
- [Test]
- public void TestWritePrimitiveUlong()
- {
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal((ulong)1)), 1);
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MinValue)), ulong.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MaxValue)), ulong.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)1)), (ulong?)1);
- Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive ulong array.</summary>
- */
- [Test]
- public void TestWritePrimitiveUlongArray()
- {
- ulong[] vals = { ulong.MinValue, 0, 1, ulong.MaxValue };
- ulong[] newVals = _marsh.Unmarshal<ulong[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive float.</summary>
- */
- [Test]
- public void TestWritePrimitiveFloat()
- {
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal((float)1)), (float)1);
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MinValue)), float.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MaxValue)), float.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)1)), (float?)1);
- Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive float array.</summary>
- */
- [Test]
- public void TestWritePrimitiveFloatArray()
- {
- float[] vals = { float.MinValue, 0, 1, float.MaxValue };
- float[] newVals = _marsh.Unmarshal<float[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of primitive double.</summary>
- */
- [Test]
- public void TestWritePrimitiveDouble()
- {
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal((double)1)), (double)1);
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MinValue)), double.MinValue);
- Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MaxValue)), double.MaxValue);
-
- Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)1)), (double?)1);
- Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)null)), null);
- }
-
- /**
- * <summary>Check write of primitive double array.</summary>
- */
- [Test]
- public void TestWritePrimitiveDoubleArray()
- {
- double[] vals = { double.MinValue, 0, 1, double.MaxValue };
- double[] newVals = _marsh.Unmarshal<double[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of decimal.</summary>
- */
- [Test]
- public void TestWritePrimitiveDecimal()
- {
- decimal val;
-
- // Test positibe and negative.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Zero)), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, true, 0))), val);
-
- // Test 32, 64 and 96 bits + mixed.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, true, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, true, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, false, 0))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, true, 0))), val);
-
- // Test extremes.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("65536"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-65536"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("4294967296"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-4294967296"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("281474976710656"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-281474976710656"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("18446744073709551616"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-18446744073709551616"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("1208925819614629174706176"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-1208925819614629174706176"))), val);
-
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MaxValue)), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MinValue)), val);
-
- // Test scale.
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("11,12"))), val);
- Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-11,12"))), val);
-
- // Test null.
- Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal((decimal?)null)), null);
- }
-
- /**
- * <summary>Check write of decimal array.</summary>
- */
- [Test]
- public void TestWritePrimitiveDecimalArray()
- {
- decimal?[] vals = { decimal.One, decimal.Parse("11,12") };
- var newVals = _marsh.Unmarshal<decimal?[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of string.</summary>
- */
- [Test]
- public void TestWriteString()
- {
- Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal("str")), "str");
- Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal((string) null)), null);
- }
-
- /**
- * <summary>Check write of string array.</summary>
- */
- [Test]
- public void TestWriteStringArray()
- {
- string[] vals = { "str1", null, "", "str2", null};
- string[] newVals = _marsh.Unmarshal<string[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of Guid.</summary>
- */
- [Test]
- public void TestWriteGuid()
- {
- Guid guid = Guid.NewGuid();
- Guid? nGuid = guid;
-
- Assert.AreEqual(_marsh.Unmarshal<Guid>(_marsh.Marshal(guid)), guid);
- Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), nGuid);
-
- nGuid = null;
-
- // ReSharper disable once ExpressionIsAlwaysNull
- Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), null);
- }
-
- /**
- * <summary>Check write of string array.</summary>
- */
- [Test]
- public void TestWriteGuidArray()
- {
- Guid?[] vals = { Guid.NewGuid(), null, Guid.Empty, Guid.NewGuid(), null };
- Guid?[] newVals = _marsh.Unmarshal<Guid?[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /**
- * <summary>Check write of enum.</summary>
- */
- [Test]
- public void TestWriteEnum()
- {
- TestEnum val = TestEnum.Val1;
-
- Assert.AreEqual(_marsh.Unmarshal<TestEnum>(_marsh.Marshal(val)), val);
- }
-
- /**
- * <summary>Check write of enum.</summary>
- */
- [Test]
- public void TestWriteEnumArray()
- {
- TestEnum[] vals = { TestEnum.Val2, TestEnum.Val3 };
- TestEnum[] newVals = _marsh.Unmarshal<TestEnum[]>(_marsh.Marshal(vals));
-
- Assert.AreEqual(vals, newVals);
- }
-
- /// <summary>
- /// Test object with dates.
- /// </summary>
- [Test]
- public void TestDateObject()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(DateTimeType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- DateTime now = DateTime.Now;
-
- DateTimeType obj = new DateTimeType(now);
-
- DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
-
- Assert.AreEqual(obj.Utc, otherObj.Utc);
- Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
- Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
-
- Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
- Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
- Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
- }
-
- /// <summary>
- /// Tests the DateTime marshalling.
- /// </summary>
- [Test]
- public void TestDateTime()
- {
- var time = DateTime.Now;
- Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
-
- var timeUtc = DateTime.UtcNow;
- Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), timeUtc);
-
- // Check exception with non-UTC date
- var stream = new BinaryHeapStream(128);
- var writer = _marsh.StartMarshal(stream);
- Assert.Throws<InvalidOperationException>(() => writer.WriteTimestamp(DateTime.Now));
- }
-
- /**
- * <summary>Check generic collections.</summary>
- */
- [Test]
- public void TestGenericCollections()
- {
- var list = new List<string> {"1"};
-
- var data = _marsh.Marshal(list);
-
- var newObjList = _marsh.Unmarshal<IList<string>>(data);
-
- CollectionAssert.AreEquivalent(list, newObjList);
- }
-
- /// <summary>
- /// Tests marshal aware type with generic collections.
- /// </summary>
- [Test]
- public void TestGenericCollectionsType()
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (PrimitiveFieldType)),
- new BinaryTypeConfiguration(typeof (GenericCollectionsType<PrimitiveFieldType, SerializableObject>))
- }
- });
-
- var obj = new GenericCollectionsType<PrimitiveFieldType, SerializableObject>
- {
- Keys = new[] {new PrimitiveFieldType(), new PrimitiveFieldType()},
- Values =
- new List<SerializableObject>
- {
- new SerializableObject {Foo = 1},
- new SerializableObject {Foo = 5}
- },
- Pairs = new Dictionary<PrimitiveFieldType, SerializableObject>
- {
- {new PrimitiveFieldType(), new SerializableObject {Foo = 10}},
- {new PrimitiveFieldType {PByte = 10}, new SerializableObject {Foo = 20}}
- },
- Objects = new object[] {1, 2, "3", 4.4}
- };
-
- var data = marsh.Marshal(obj);
-
- var result = marsh.Unmarshal<GenericCollectionsType<PrimitiveFieldType, SerializableObject>>(data);
-
- CollectionAssert.AreEquivalent(obj.Keys, result.Keys);
- CollectionAssert.AreEquivalent(obj.Values, result.Values);
- CollectionAssert.AreEquivalent(obj.Pairs, result.Pairs);
- CollectionAssert.AreEquivalent(obj.Objects, result.Objects);
- }
-
- /**
- * <summary>Check property read.</summary>
- */
- [Test]
- public void TestProperty()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PropertyType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- PropertyType obj = new PropertyType
- {
- Field1 = 1,
- Field2 = 2
- };
-
- byte[] data = marsh.Marshal(obj);
-
- PropertyType newObj = marsh.Unmarshal<PropertyType>(data);
-
- Assert.AreEqual(obj.Field1, newObj.Field1);
- Assert.AreEqual(obj.Field2, newObj.Field2);
-
- IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.Field1, portNewObj.GetField<int>("field1"));
- Assert.AreEqual(obj.Field2, portNewObj.GetField<int>("Field2"));
- }
-
- /**
- * <summary>Check write of primitive fields through reflection.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsReflective()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsPortable()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldPortableType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldPortableType obj = new PrimitiveFieldPortableType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsRawPortable()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldRawPortableType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldRawPortableType obj = new PrimitiveFieldRawPortableType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check write of primitive fields through portable interface.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsSerializer()
- {
- var typeCfgs = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (PrimitiveFieldType))
- {
- Serializer = new PrimitiveFieldsSerializer()
- }
- };
-
- BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- /**
- * <summary>Check decimals.</summary>
- */
- [Test]
- public void TestDecimalFields()
- {
- BinaryConfiguration cfg = new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (DecimalReflective)),
- new BinaryTypeConfiguration(typeof (DecimalMarshalAware))
- }
- };
-
- Marshaller marsh = new Marshaller(cfg);
-
- // 1. Test reflective stuff.
- DecimalReflective obj1 = new DecimalReflective
- {
- Val = decimal.Zero,
- ValArr = new decimal?[] {decimal.One, decimal.MinusOne}
- };
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj1), BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal?[]>("valArr"));
-
- Assert.AreEqual(obj1.Val, portObj.Deserialize<DecimalReflective>().Val);
- Assert.AreEqual(obj1.ValArr, portObj.Deserialize<DecimalReflective>().ValArr);
-
- // 2. Test marshal aware stuff.
- DecimalMarshalAware obj2 = new DecimalMarshalAware();
-
- obj2.Val = decimal.Zero;
- obj2.ValArr = new decimal?[] { decimal.One, decimal.MinusOne };
- obj2.RawVal = decimal.MaxValue;
- obj2.RawValArr = new decimal?[] { decimal.MinusOne, decimal.One} ;
-
- portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj2), BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
- Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal?[]>("valArr"));
-
- Assert.AreEqual(obj2.Val, portObj.Deserialize<DecimalMarshalAware>().Val);
- Assert.AreEqual(obj2.ValArr, portObj.Deserialize<DecimalMarshalAware>().ValArr);
- Assert.AreEqual(obj2.RawVal, portObj.Deserialize<DecimalMarshalAware>().RawVal);
- Assert.AreEqual(obj2.RawValArr, portObj.Deserialize<DecimalMarshalAware>().RawValArr);
- }
-
- /**
- * <summary>Check write of primitive fields through raw serializer.</summary>
- */
- [Test]
- public void TestPrimitiveFieldsRawSerializer()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- BinaryTypeConfiguration typeCfg =
- new BinaryTypeConfiguration(typeof(PrimitiveFieldType));
-
- typeCfg.Serializer = new PrimitiveFieldsRawSerializer();
-
- typeCfgs.Add(typeCfg);
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- PrimitiveFieldType obj = new PrimitiveFieldType();
-
- CheckPrimitiveFields(marsh, obj);
- }
-
- private void CheckPrimitiveFields(Marshaller marsh, PrimitiveFieldType obj)
- {
- obj.PBool = true;
- obj.PByte = 2;
- obj.PSbyte = 3;
- obj.PShort = 4;
- obj.PUshort = 5;
- obj.PInt = 6;
- obj.PUint = 7;
- obj.PLong = 8;
- obj.PUlong = 9;
- obj.PChar = 'a';
- obj.PFloat = 10;
- obj.PDouble = 11;
- obj.PString = "abc";
- obj.PGuid = Guid.NewGuid();
- obj.PnGuid = Guid.NewGuid();
- obj.IgniteGuid = new IgniteGuid(Guid.NewGuid(), 123);
-
- CheckPrimitiveFieldsSerialization(marsh, obj);
- }
-
- private void CheckPrimitiveFieldsSerialization(Marshaller marsh, PrimitiveFieldType obj)
- {
- byte[] bytes = marsh.Marshal(obj);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- PrimitiveFieldType newObj = portObj.Deserialize<PrimitiveFieldType>();
-
- Assert.AreEqual(obj, newObj);
- }
-
- /**
- * <summary>Check write of object with enums.</summary>
- */
- [Test]
- public void TestEnumsReflective()
- {
- Marshaller marsh =
- new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations =
- new List<BinaryTypeConfiguration> {new BinaryTypeConfiguration(typeof (EnumType))}
- });
-
- EnumType obj = new EnumType
- {
- PEnum = TestEnum.Val1,
- PEnumArray = new[] {TestEnum.Val2, TestEnum.Val3}
- };
-
- byte[] bytes = marsh.Marshal(obj);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- EnumType newObj = portObj.Deserialize<EnumType>();
-
- Assert.AreEqual(obj.PEnum, newObj.PEnum);
- Assert.AreEqual(obj.PEnumArray, newObj.PEnumArray);
- }
-
- /**
- * <summary>Check write of object with collections.</summary>
- */
- [Test]
- public void TestCollectionsReflective()
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (CollectionsType)),
- new BinaryTypeConfiguration(typeof (InnerObjectType))
- }
- });
-
- var obj = new CollectionsType
- {
- Hashtable = new Hashtable {{1, 2}, {3, 4}},
- LinkedList = new LinkedList<int>(new[] {1, 2, 3}),
- SortedDict = new SortedDictionary<string, int> {{"1", 2}},
- Dict = new Dictionary<int, string> {{1, "2"}},
- Arr = new[] {new InnerObjectType()}
- };
-
- var list = new ArrayList
- {
- true,
- (byte) 1,
- (short) 2,
- 'a',
- 3,
- (long) 4,
- (float) 5,
- (double) 6,
- "string",
- Guid.NewGuid(),
- new InnerObjectType
- {
- PInt1 = 1,
- PInt2 = 2
- }
- };
-
- obj.Col1 = list;
-
- byte[] bytes = marsh.Marshal(obj);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
-
- CollectionsType newObj = portObj.Deserialize<CollectionsType>();
-
- Assert.AreEqual(obj, newObj);
-
- obj.Col1 = null;
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
-
- obj.Col1 = list;
- obj.Col2 = list;
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
-
- obj.Col2 = new TestList();
-
- Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
- }
-
- /**
- * <summary>Check write of object fields through reflective serializer.</summary>
- */
- [Test]
- public void TestObjectReflective()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(OuterObjectType)));
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(InnerObjectType)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- CheckObject(marsh, new OuterObjectType(), new InnerObjectType());
- }
-
- /**
- * <summary>Test handles.</summary>
- */
- [Test]
- public void TestHandles()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleInner)));
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleOuter)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- HandleOuter outer = new HandleOuter();
-
- outer.Before = "outBefore";
- outer.After = "outAfter";
- outer.RawBefore = "outRawBefore";
- outer.RawAfter = "outRawAfter";
-
- HandleInner inner = new HandleInner();
-
- inner.Before = "inBefore";
- inner.After = "inAfter";
- inner.RawBefore = "inRawBefore";
- inner.RawAfter = "inRawAfter";
-
- outer.Inner = inner;
- outer.RawInner = inner;
-
- inner.Outer = outer;
- inner.RawOuter = outer;
-
- byte[] bytes = marsh.Marshal(outer);
-
- IBinaryObject outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
- HandleInner newInner = newOuter.Inner;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
-
- // Get inner object by field.
- IBinaryObject innerObj = outerObj.GetField<IBinaryObject>("inner");
-
- newInner = innerObj.Deserialize<HandleInner>();
- newOuter = newInner.Outer;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
-
- // Get outer object from inner object by handle.
- outerObj = innerObj.GetField<IBinaryObject>("outer");
-
- newOuter = outerObj.Deserialize<HandleOuter>();
- newInner = newOuter.Inner;
-
- CheckHandlesConsistency(outer, inner, newOuter, newInner);
- }
-
- /**
- * <summary>Test handles with exclusive writes.</summary>
- */
- [Test]
- public void TestHandlesExclusive([Values(true, false)] bool detached, [Values(true, false)] bool asPortable)
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (HandleInner)),
- new BinaryTypeConfiguration(typeof (HandleOuterExclusive))
- }
- });
-
- var inner = new HandleInner
- {
- Before = "inBefore",
- After = "inAfter",
- RawBefore = "inRawBefore",
- RawAfter = "inRawAfter"
- };
-
- var outer = new HandleOuterExclusive
- {
- Before = "outBefore",
- After = "outAfter",
- RawBefore = "outRawBefore",
- RawAfter = "outRawAfter",
- Inner = inner,
- RawInner = inner
- };
-
- inner.Outer = outer;
- inner.RawOuter = outer;
-
- var bytes = asPortable
- ? marsh.Marshal(new IgniteBinary(marsh).ToBinary<IBinaryObject>(outer))
- : marsh.Marshal(outer);
-
- IBinaryObject outerObj;
-
- if (detached)
- {
- var reader = new BinaryReader(marsh, new Dictionary<long, IBinaryTypeDescriptor>(),
- new BinaryHeapStream(bytes), BinaryMode.ForceBinary, null);
-
- reader.DetachNext();
-
- outerObj = reader.Deserialize<IBinaryObject>();
- }
- else
- outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
-
- Assert.IsFalse(newOuter == newOuter.Inner.Outer);
- Assert.IsFalse(newOuter == newOuter.Inner.RawOuter);
- Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
- Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
-
- Assert.IsFalse(newOuter.Inner == newOuter.RawInner);
-
- Assert.IsTrue(newOuter.Inner.Outer == newOuter.Inner.RawOuter);
- Assert.IsTrue(newOuter.RawInner.Outer == newOuter.RawInner.RawOuter);
-
- Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.Inner);
- Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.RawInner);
- Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.Inner);
- Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.RawInner);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedDefault()
- {
- CheckKeepSerialized(new BinaryConfiguration(), true);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedDefaultFalse()
- {
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.DefaultKeepDeserialized = false;
-
- CheckKeepSerialized(cfg, false);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedTypeCfgFalse()
- {
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
-
- typeCfg.KeepDeserialized = false;
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
-
- CheckKeepSerialized(cfg, false);
- }
-
- ///
- /// <summary>Test KeepSerialized property</summary>
- ///
- [Test]
- public void TestKeepSerializedTypeCfgTrue()
- {
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
- typeCfg.KeepDeserialized = true;
-
- BinaryConfiguration cfg = new BinaryConfiguration();
- cfg.DefaultKeepDeserialized = false;
-
- cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
-
- CheckKeepSerialized(cfg, true);
- }
-
- /// <summary>
- /// Test correct serialization/deserialization of arrays of special types.
- /// </summary>
- [Test]
- public void TestSpecialArrays()
- {
- ICollection<BinaryTypeConfiguration> typeCfgs =
- new List<BinaryTypeConfiguration>();
-
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArray)));
- typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArrayMarshalAware)));
-
- BinaryConfiguration cfg = new BinaryConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- Marshaller marsh = new Marshaller(cfg);
-
- Guid[] guidArr = { Guid.NewGuid() };
- Guid?[] nGuidArr = { Guid.NewGuid() };
- DateTime[] dateArr = { DateTime.Now.ToUniversalTime() };
- DateTime?[] nDateArr = { DateTime.Now.ToUniversalTime() };
-
- // Use special object.
- SpecialArray obj1 = new SpecialArray
- {
- GuidArr = guidArr,
- NGuidArr = nGuidArr,
- DateArr = dateArr,
- NDateArr = nDateArr
- };
-
- byte[] bytes = marsh.Marshal(obj1);
-
- IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.IsNotNull(portObj.Deserialize<SpecialArray>());
-
- Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("guidArr"));
- Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("nGuidArr"));
- Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("dateArr"));
- Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("nDateArr"));
-
- obj1 = portObj.Deserialize<SpecialArray>();
-
- Assert.AreEqual(guidArr, obj1.GuidArr);
- Assert.AreEqual(nGuidArr, obj1.NGuidArr);
- Assert.AreEqual(dateArr, obj1.DateArr);
- Assert.AreEqual(nDateArr, obj1.NDateArr);
-
- // Use special with IGridPortableMarshalAware.
- SpecialArrayMarshalAware obj2 = new SpecialArrayMarshalAware();
-
- obj2.GuidArr = guidArr;
- obj2.NGuidArr = nGuidArr;
- obj2.DateArr = dateArr;
- obj2.NDateArr = nDateArr;
-
- bytes = marsh.Marshal(obj2);
-
- portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("a"));
- Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("b"));
- Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("c"));
- Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("d"));
-
- obj2 = portObj.Deserialize<SpecialArrayMarshalAware>();
-
- Assert.AreEqual(guidArr, obj2.GuidArr);
- Assert.AreEqual(nGuidArr, obj2.NGuidArr);
- Assert.AreEqual(dateArr, obj2.DateArr);
- Assert.AreEqual(nDateArr, obj2.NDateArr);
- }
-
- /// <summary>
- /// Writes objects of various sizes to test schema compaction
- /// (where field offsets can be stored as 1, 2 or 4 bytes).
- /// </summary>
- [Test]
- public void TestCompactSchema()
- {
- var marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (SpecialArray)),
- new BinaryTypeConfiguration(typeof (SpecialArrayMarshalAware))
- }
- });
-
- var dt = new SpecialArrayMarshalAware();
-
- foreach (var i in new[] {1, 5, 10, 13, 14, 15, 100, 200, 1000, 5000, 15000, 30000})
- {
- dt.NGuidArr = Enumerable.Range(1, i).Select(x => (Guid?) Guid.NewGuid()).ToArray();
- dt.NDateArr = Enumerable.Range(1, i).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray();
-
- var bytes = marsh.Marshal(dt);
-
- var res = marsh.Unmarshal<SpecialArrayMarshalAware>(bytes);
-
- CollectionAssert.AreEquivalent(dt.NGuidArr, res.NGuidArr);
- CollectionAssert.AreEquivalent(dt.NDateArr, res.NDateArr);
- }
- }
-
- private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
- {
- if (cfg.TypeConfigurations == null)
- {
- cfg.TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof(PropertyType))
- };
- }
-
- Marshaller marsh = new Marshaller(cfg);
-
- byte[] data = marsh.Marshal(new PropertyType());
-
- IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- PropertyType deserialized1 = portNewObj.Deserialize<PropertyType>();
- PropertyType deserialized2 = portNewObj.Deserialize<PropertyType>();
-
- Assert.NotNull(deserialized1);
-
- Assert.AreEqual(expKeep, deserialized1 == deserialized2);
- }
-
- private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter,
- HandleInner newInner)
- {
- Assert.True(newOuter != null);
- Assert.AreEqual(outer.Before, newOuter.Before);
- Assert.True(newOuter.Inner == newInner);
- Assert.AreEqual(outer.After, newOuter.After);
- Assert.AreEqual(outer.RawBefore, newOuter.RawBefore);
- Assert.True(newOuter.RawInner == newInner);
- Assert.AreEqual(outer.RawAfter, newOuter.RawAfter);
-
- Assert.True(newInner != null);
- Assert.AreEqual(inner.Before, newInner.Before);
- Assert.True(newInner.Outer == newOuter);
- Assert.AreEqual(inner.After, newInner.After);
- Assert.AreEqual(inner.RawBefore, newInner.RawBefore);
- Assert.True(newInner.RawOuter == newOuter);
- Assert.AreEqual(inner.RawAfter, newInner.RawAfter);
- }
-
- private static void CheckObject(Marshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
- {
- inObj.PInt1 = 1;
- inObj.PInt2 = 2;
-
- outObj.InObj = inObj;
-
- byte[] bytes = marsh.Marshal(outObj);
-
- IBinaryObject portOutObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
-
- Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
-
- OuterObjectType newOutObj = portOutObj.Deserialize<OuterObjectType>();
-
- Assert.AreEqual(outObj, newOutObj);
- }
-
- public class OuterObjectType
- {
- public InnerObjectType InObj { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var type = obj as OuterObjectType;
-
- return type != null && Equals(InObj, type.InObj);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return InObj != null ? InObj.GetHashCode() : 0;
- }
- }
-
- [Serializable]
- public class InnerObjectType
- {
- public int PInt1 { get; set; }
-
- public int PInt2 { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var that = obj as InnerObjectType;
-
- return that != null && (PInt1 == that.PInt1 && PInt2 == that.PInt2);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return 31 * PInt1 + PInt2;
- }
-
- /** <inheritdoc /> */
- public override string ToString()
- {
- return "InnerObjectType[pInt1=" + PInt1 + ", pInt2=" + PInt2 + ']';
- }
- }
-
- public class CollectionsType
- {
- public ICollection Col1 { get; set; }
-
- public ArrayList Col2 { get; set; }
-
- public Hashtable Hashtable { get; set; }
-
- public Dictionary<int, string> Dict { get; set; }
-
- public InnerObjectType[] Arr { get; set; }
-
- public SortedDictionary<string, int> SortedDict { get; set; }
-
- public LinkedList<int> LinkedList { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var that = obj as CollectionsType;
-
- return that != null
- && CompareCollections(Col1, that.Col1)
- && CompareCollections(Col2, that.Col2)
- && CompareCollections(Hashtable, that.Hashtable)
- && CompareCollections(Dict, that.Dict)
- && CompareCollections(Arr, that.Arr)
- && CompareCollections(SortedDict, that.SortedDict)
- && CompareCollections(LinkedList, that.LinkedList);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- int res = 0;
-
- foreach (var col in new object[] {Col1, Col2, Hashtable, Dict, Arr, SortedDict, LinkedList})
- res = 31*res + (col != null ? col.GetHashCode() : 0);
-
- return res;
- }
- }
-
- public class GenericCollectionsType<TKey, TValue> : IBinarizable
- {
- public ICollection<TKey> Keys { get; set; }
-
- public ICollection<TValue> Values { get; set; }
-
- public IDictionary<TKey, TValue> Pairs { get; set; }
-
- public ICollection<object> Objects { get; set; }
-
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteObject("Keys", Keys);
- writer.WriteObject("Values", Values);
- writer.WriteObject("Pairs", Pairs);
- writer.WriteObject("Objects", Objects);
- }
-
- public void ReadBinary(IBinaryReader reader)
- {
- Keys = (ICollection<TKey>) reader.ReadObject<object>("Keys");
- Values = (ICollection<TValue>) reader.ReadObject<object>("Values");
- Pairs = (IDictionary<TKey, TValue>) reader.ReadObject<object>("Pairs");
- Objects = (ICollection<object>) reader.ReadObject<object>("Objects");
- }
- }
-
- public class TestList : ArrayList
- {
-
- }
-
- private static bool CompareCollections(ICollection col1, ICollection col2)
- {
- if (col1 == null && col2 == null)
- return true;
- if (col1 == null || col2 == null)
- return false;
-
- return col1.OfType<object>().SequenceEqual(col2.OfType<object>());
- }
-
- public class PrimitiveArrayFieldType
- {
- public bool[] PBool { get; set; }
-
- public sbyte[] PSbyte { get; set; }
-
- public byte[] PByte { get; set; }
-
- public short[] PShort { get; set; }
-
- public ushort[] PUshort { get; set; }
-
- public char[] PChar { get; set; }
-
- public int[] PInt { get; set; }
-
- public uint[] PUint { get; set; }
-
- public long[] PLong { get; set; }
-
- public ulong[] PUlong { get; set; }
-
- public float[] PFloat { get; set; }
-
- public double[] PDouble { get; set; }
-
- public string[] PString { get; set; }
-
- public Guid?[] PGuid { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- var other = obj as PrimitiveArrayFieldType;
-
- return other != null && (PBool == other.PBool &&
- PByte == other.PByte &&
- PSbyte == other.PSbyte &&
- PShort == other.PShort &&
- PUshort == other.PUshort &&
- PInt == other.PInt &&
- PUint == other.PUint &&
- PLong == other.PLong &&
- PUlong == other.PUlong &&
- PChar == other.PChar &&
- PFloat == other.PFloat &&
- PDouble == other.PDouble &&
- PString == other.PString &&
- PGuid == other.PGuid);
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return PInt != null && PInt.Length > 0 ? PInt[0].GetHashCode() : 0;
- }
- }
-
- public class SpecialArray
- {
- public Guid[] GuidArr;
- public Guid?[] NGuidArr;
- public DateTime[] DateArr;
- public DateTime?[] NDateArr;
- }
-
- public class SpecialArrayMarshalAware : SpecialArray, IBinarizable
- {
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteObject("a", GuidArr);
- writer.WriteObject("b", NGuidArr);
- writer.WriteObject("c", DateArr);
- writer.WriteObject("d", NDateArr);
- }
-
- public void ReadBinary(IBinaryReader reader)
- {
- GuidArr = reader.ReadObject<Guid[]>("a");
- NGuidArr = reader.ReadObject<Guid?[]>("b");
- DateArr = reader.ReadObject<DateTime[]>("c");
- NDateArr = reader.ReadObject<DateTime?[]>("d");
- }
- }
-
- public class EnumType
- {
- public TestEnum PEnum { get; set; }
-
- public TestEnum[] PEnumArray { get; set; }
- }
-
- [Serializable]
- public class PrimitiveFieldType
- {
- public bool PBool { get; set; }
-
- public sbyte PSbyte { get; set; }
-
- public byte PByte { get; set; }
-
- public short PShort { get; set; }
-
- public ushort PUshort { get; set; }
-
- public char PChar { get; set; }
-
- public int PInt { get; set; }
-
- public uint PUint { get; set; }
-
- public long PLong { get; set; }
-
- public ulong PUlong { get; set; }
-
- public float PFloat { get; set; }
-
- public double PDouble { get; set; }
-
- public string PString { get; set; }
-
- public Guid PGuid { get; set; }
-
- public Guid? PnGuid { get; set; }
-
- public IgniteGuid IgniteGuid { get; set; }
-
- /** <inheritdoc /> */
- public override bool Equals(object obj)
- {
- if (this == obj)
- return true;
-
- if (obj != null && obj is PrimitiveFieldType)
- {
- PrimitiveFieldType that = (PrimitiveFieldType)obj;
-
- return PBool == that.PBool &&
- PByte == that.PByte &&
- PSbyte == that.PSbyte &&
- PShort == that.PShort &&
- PUshort == that.PUshort &&
- PInt == that.PInt &&
- PUint == that.PUint &&
- PLong == that.PLong &&
- PUlong == that.PUlong &&
- PChar == that.PChar &&
- PFloat == that.PFloat &&
- PDouble == that.PDouble &&
- (string.Equals(PString, that.PString)) &&
- PGuid.Equals(that.PGuid) &&
- IgniteGuid.Equals(that.IgniteGuid) &&
- (PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
- }
- return false;
- }
-
- /** <inheritdoc /> */
- public override int GetHashCode()
- {
- return PInt;
- }
- }
-
- public class PrimitiveFieldPortableType : PrimitiveFieldType, IBinarizable
- {
- public unsafe void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteBoolean("bool", PBool);
- writer.WriteByte("byte", PByte);
- writer.WriteShort("short", PShort);
- writer.WriteInt("int", PInt);
- writer.WriteLong("long", PLong);
- writer.WriteChar("char", PChar);
- writer.WriteFloat("float", PFloat);
- writer.WriteDouble("double", PDouble);
-
- sbyte sByte = PSbyte;
- ushort uShort = PUshort;
- uint uInt = PUint;
- ulong uLong = PUlong;
-
- writer.WriteByte("sbyte", *(byte*)&sByte);
- writer.WriteShort("ushort", *(short*)&uShort);
- writer.WriteInt("uint", *(int*)&uInt);
- writer.WriteLong("ulong", *(long*)&uLong);
-
- writer.WriteString("string", PString);
- writer.WriteGuid("guid", PGuid);
- writer.WriteGuid("nguid", PnGuid);
-
- writer.WriteObject("iguid", IgniteGuid);
- }
-
- public unsafe void ReadBinary(IBinaryReader reader)
- {
- PBool = reader.ReadBoolean("bool");
- PByte = reader.ReadByte("byte");
- PShort = reader.ReadShort("short");
- PInt = reader.ReadInt("int");
-
- PLong = reader.ReadLong("long");
- PChar = reader.ReadChar("char");
- PFloat = reader.ReadFloat("float");
- PDouble = reader.ReadDouble("double");
-
- byte sByte = reader.ReadByte("sbyte");
- short uShort = reader.ReadShort("ushort");
- int uInt = reader.ReadInt("uint");
- long uLong = reader.ReadLong("ulong");
-
- PSbyte = *(sbyte*)&sByte;
- PUshort = *(ushort*)&uShort;
- PUint = *(uint*)&uInt;
- PUlong = *(ulong*)&uLong;
-
- PString = reader.ReadString("string");
- PGuid = reader.ReadObject<Guid>("guid");
- PnGuid = reader.ReadGuid("nguid");
-
- IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
- }
- }
-
- public class PrimitiveFieldRawPortableType : PrimitiveFieldType, IBinarizable
- {
- public unsafe void WriteBinary(IBinaryWriter writer)
- {
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteBoolean(PBool);
- rawWriter.WriteByte(PByte);
- rawWriter.WriteShort(PShort);
- rawWriter.WriteInt(PInt);
- rawWriter.WriteLong(PLong);
- rawWriter.WriteChar(PChar);
- rawWriter.WriteFloat(PFloat);
- rawWriter.WriteDouble(PDouble);
-
- sbyte sByte = PSbyte;
- ushort uShort = PUshort;
- uint uInt = PUint;
- ulong uLong = PUlong;
-
- rawWriter.WriteByte(*(byte*)&sByte);
- rawWriter.WriteShort(*(short*)&uShort);
- rawWriter.WriteInt(*(int*)&uInt);
- rawWriter.WriteLong(*(long*)&uLong);
-
- rawWriter.WriteString(PString);
- rawWriter.WriteGuid(PGuid);
- rawWriter.WriteGuid(PnGuid);
-
- rawWriter.WriteObject(IgniteGuid);
- }
-
- public unsafe void ReadBinary(IBinaryReader reader)
- {
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- PBool = rawReader.ReadBoolean();
- PByte = rawReader.ReadByte();
- PShort = rawReader.ReadShort();
- PInt = rawReader.ReadInt();
-
- PLong = rawReader.ReadLong();
- PChar = rawReader.ReadChar();
- PFloat = rawReader.ReadFloat();
- PDouble = rawReader.ReadDouble();
-
- byte sByte = rawReader.ReadByte();
- short uShort = rawReader.ReadShort();
- int uInt = rawReader.ReadInt();
- long uLong = rawReader.ReadLong();
-
- PSbyte = *(sbyte*)&sByte;
- PUshort = *(ushort*)&uShort;
- PUint = *(uint*)&uInt;
- PUlong = *(ulong*)&uLong;
-
- PString = rawReader.ReadString();
- PGuid = rawReader.ReadGuid().Value;
- PnGuid = rawReader.ReadGuid();
-
- IgniteGuid = rawReader.ReadObject<IgniteGuid>();
- }
- }
-
- public class PrimitiveFieldsSerializer : IBinarySerializer
- {
- public unsafe void WriteBinary(object obj, IBinaryWriter writer)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- writer.WriteBoolean("bool", obj0.PBool);
- writer.WriteByte("byte", obj0.PByte);
- writer.WriteShort("short", obj0.PShort);
- writer.WriteInt("int", obj0.PInt);
- writer.WriteLong("long", obj0.PLong);
- writer.WriteChar("char", obj0.PChar);
- writer.WriteFloat("float", obj0.PFloat);
- writer.WriteDouble("double", obj0.PDouble);
-
- sbyte sByte = obj0.PSbyte;
- ushort uShort = obj0.PUshort;
- uint uInt = obj0.PUint;
- ulong uLong = obj0.PUlong;
-
- writer.WriteByte("sbyte", *(byte*)&sByte);
- writer.WriteShort("ushort", *(short*)&uShort);
- writer.WriteInt("uint", *(int*)&uInt);
- writer.WriteLong("ulong", *(long*)&uLong);
-
- writer.WriteString("string", obj0.PString);
- writer.WriteGuid("guid", obj0.PGuid);
- writer.WriteGuid("nguid", obj0.PnGuid);
-
- writer.WriteObject("iguid", obj0.IgniteGuid);
- }
-
- public unsafe void ReadBinary(object obj, IBinaryReader reader)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- obj0.PBool = reader.ReadBoolean("bool");
- obj0.PByte = reader.ReadByte("byte");
- obj0.PShort = reader.ReadShort("short");
- obj0.PInt = reader.ReadInt("int");
-
- obj0.PLong = reader.ReadLong("long");
- obj0.PChar = reader.ReadChar("char");
- obj0.PFloat = reader.ReadFloat("float");
- obj0.PDouble = reader.ReadDouble("double");
-
- byte sByte = reader.ReadByte("sbyte");
- short uShort = reader.ReadShort("ushort");
- int uInt = reader.ReadInt("uint");
- long uLong = reader.ReadLong("ulong");
-
- obj0.PSbyte = *(sbyte*)&sByte;
- obj0.PUshort = *(ushort*)&uShort;
- obj0.PUint = *(uint*)&uInt;
- obj0.PUlong = *(ulong*)&uLong;
-
- obj0.PString = reader.ReadString("string");
- obj0.PGuid = reader.ReadObject<Guid>("guid");
- obj0.PnGuid = reader.ReadGuid("nguid");
-
- obj0.IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
- }
- }
-
- public class PrimitiveFieldsRawSerializer : IBinarySerializer
- {
- public unsafe void WriteBinary(object obj, IBinaryWriter writer)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteBoolean(obj0.PBool);
- rawWriter.WriteByte(obj0.PByte);
- rawWriter.WriteShort( obj0.PShort);
- rawWriter.WriteInt( obj0.PInt);
- rawWriter.WriteLong( obj0.PLong);
- rawWriter.WriteChar(obj0.PChar);
- rawWriter.WriteFloat(obj0.PFloat);
- rawWriter.WriteDouble( obj0.PDouble);
-
- sbyte sByte = obj0.PSbyte;
- ushort uShort = obj0.PUshort;
- uint uInt = obj0.PUint;
- ulong uLong = obj0.PUlong;
-
- rawWriter.WriteByte(*(byte*)&sByte);
- rawWriter.WriteShort(*(short*)&uShort);
- rawWriter.WriteInt(*(int*)&uInt);
- rawWriter.WriteLong(*(long*)&uLong);
-
- rawWriter.WriteString(obj0.PString);
- rawWriter.WriteGuid(obj0.PGuid);
- rawWriter.WriteGuid(obj0.PnGuid);
-
- rawWriter.WriteObject(obj0.IgniteGuid);
- }
-
- public unsafe void ReadBinary(object obj, IBinaryReader reader)
- {
- PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- obj0.PBool = rawReader.ReadBoolean();
- obj0.PByte = rawReader.ReadByte();
- obj0.PShort = rawReader.ReadShort();
- obj0.PInt = rawReader.ReadInt();
- obj0.PLong = rawReader.ReadLong();
- obj0.PChar = rawReader.ReadChar();
- obj0.PFloat = rawReader.ReadFloat();
- obj0.PDouble = rawReader.ReadDouble();
-
- byte sByte = rawReader.ReadByte();
- short uShort = rawReader.ReadShort();
- int uInt = rawReader.ReadInt();
- long uLong = rawReader.ReadLong();
-
- obj0.PSbyte = *(sbyte*)&sByte;
- obj0.PUshort = *(ushort*)&uShort;
- obj0.PUint = *(uint*)&uInt;
- obj0.PUlong = *(ulong*)&uLong;
-
- obj0.PString = rawReader.ReadString();
- obj0.PGuid = rawReader.ReadGuid().Value;
- obj0.PnGuid = rawReader.ReadGuid();
-
- obj0.IgniteGuid = rawReader.ReadObject<IgniteGuid>();
- }
- }
-
- public class HandleOuter : IBinarizable
- {
- public string Before;
- public HandleInner Inner;
- public string After;
-
- public string RawBefore;
- public HandleInner RawInner;
- public string RawAfter;
-
- /** <inheritdoc /> */
- virtual public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteString("before", Before);
- writer.WriteObject("inner", Inner);
- writer.WriteString("after", After);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteString(RawBefore);
- rawWriter.WriteObject(RawInner);
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- virtual public void ReadBinary(IBinaryReader reader)
- {
- Before = reader.ReadString("before");
- Inner = reader.ReadObject<HandleInner>("inner");
- After = reader.ReadString("after");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- RawBefore = rawReader.ReadString();
- RawInner = rawReader.ReadObject<HandleInner>();
- RawAfter = rawReader.ReadString();
- }
- }
-
- public class HandleInner : IBinarizable
- {
- public string Before;
- public HandleOuter Outer;
- public string After;
-
- public string RawBefore;
- public HandleOuter RawOuter;
- public string RawAfter;
-
- /** <inheritdoc /> */
- virtual public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteString("before", Before);
- writer.WriteObject("outer", Outer);
- writer.WriteString("after", After);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteString(RawBefore);
- rawWriter.WriteObject(RawOuter);
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- virtual public void ReadBinary(IBinaryReader reader)
- {
- Before = reader.ReadString("before");
- Outer = reader.ReadObject<HandleOuter>("outer");
- After = reader.ReadString("after");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- RawBefore = rawReader.ReadString();
- RawOuter = rawReader.ReadObject<HandleOuter>();
- RawAfter = rawReader.ReadString();
- }
- }
-
-
- public class HandleOuterExclusive : HandleOuter
- {
- /** <inheritdoc /> */
- override public void WriteBinary(IBinaryWriter writer)
- {
- BinaryWriter writer0 = (BinaryWriter)writer;
-
- writer.WriteString("before", Before);
-
- writer0.WithDetach(w => w.WriteObject("inner", Inner));
-
- writer.WriteString("after", After);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteString(RawBefore);
-
- writer0.WithDetach(w => w.WriteObject(RawInner));
-
- rawWriter.WriteString(RawAfter);
- }
-
- /** <inheritdoc /> */
- override public void ReadBinary(IBinaryReader reader)
- {
- var reader0 = (BinaryReader) reader;
-
- Before = reader0.ReadString("before");
-
- reader0.DetachNext();
- Inner = reader0.ReadObject<HandleInner>("inner");
-
- After = reader0.ReadString("after");
-
- var rawReader = (BinaryReader) reader.GetRawReader();
-
- RawBefore = rawReader.ReadString();
-
- reader0.DetachNext();
- RawInner = rawReader.ReadObject<HandleInner>();
-
- RawAfter = rawReader.ReadString();
- }
- }
-
- public class PropertyType
- {
- public int Field1;
-
- public int Field2
- {
- get;
- set;
- }
- }
-
- public enum TestEnum
- {
- Val1, Val2, Val3 = 10
- }
-
- public class DecimalReflective
- {
- /** */
- public decimal? Val;
-
- /** */
- public decimal?[] ValArr;
- }
-
- public class DecimalMarshalAware : DecimalReflective, IBinarizable
- {
- /** */
- public decimal? RawVal;
-
- /** */
- public decimal?[] RawValArr;
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteDecimal("val", Val);
- writer.WriteDecimalArray("valArr", ValArr);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteDecimal(RawVal);
- rawWriter.WriteDecimalArray(RawValArr);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Val = reader.ReadDecimal("val");
- ValArr = reader.ReadDecimalArray("valArr");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- RawVal = rawReader.ReadDecimal();
- RawValArr = rawReader.ReadDecimalArray();
- }
- }
-
- /// <summary>
- /// Date time type.
- /// </summary>
- public class DateTimeType : IBinarizable
- {
- public DateTime Utc;
-
- public DateTime? UtcNull;
-
- public DateTime?[] UtcArr;
-
- public DateTime UtcRaw;
-
- public DateTime? UtcNullRaw;
-
- public DateTime?[] UtcArrRaw;
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="now">Current local time.</param>
- public DateTimeType(DateTime now)
- {
- Utc = now.ToUniversalTime();
-
- UtcNull = Utc;
-
- UtcArr = new DateTime?[] { Utc };
-
- UtcRaw = Utc;
-
- UtcNullRaw = UtcNull;
-
- UtcArrRaw = new[] { UtcArr[0] };
- }
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteTimestamp("utc", Utc);
- writer.WriteTimestamp("utcNull", UtcNull);
- writer.WriteTimestampArray("utcArr", UtcArr);
-
- IBinaryRawWriter rawWriter = writer.GetRawWriter();
-
- rawWriter.WriteTimestamp(UtcRaw);
- rawWriter.WriteTimestamp(UtcNullRaw);
- rawWriter.WriteTimestampArray(UtcArrRaw);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Utc = reader.ReadTimestamp("utc").Value;
- UtcNull = reader.ReadTimestamp("utc").Value;
- UtcArr = reader.ReadTimestampArray("utcArr");
-
- IBinaryRawReader rawReader = reader.GetRawReader();
-
- UtcRaw = rawReader.ReadTimestamp().Value;
- UtcNullRaw = rawReader.ReadTimestamp().Value;
- UtcArrRaw = rawReader.ReadTimestampArray();
- }
- }
-
- [Serializable]
- private class SerializableObject
- {
- public int Foo { get; set; }
-
- private bool Equals(SerializableObject other)
- {
- return Foo == other.Foo;
- }
-
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(null, obj)) return false;
- if (ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != GetType()) return false;
-
- return Equals((SerializableObject) obj);
- }
-
- public override int GetHashCode()
- {
- return Foo;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
deleted file mode 100644
index 32b659e..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableStructureTest.cs
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Portable
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Binary;
- using NUnit.Framework;
-
- /// <summary>
- /// Contains tests for portable type structure.
- /// </summary>
- [TestFixture]
- public class PortableStructureTest
- {
- /** Repeat count. */
- public static readonly int RepeatCnt = 10;
-
- /** Objects per mode. */
- public static readonly int ObjectsPerMode = 5;
-
- /// <summary>
- /// Test object write with different structures.
- /// </summary>
- [Test]
- public void TestStructure()
- {
- for (int i = 1; i <= RepeatCnt; i++)
- {
- Console.WriteLine(">>> Iteration started: " + i);
-
- // 1. Generate and shuffle objects.
- IList<BranchedType> objs = new List<BranchedType>();
-
- for (int j = 0; j < 6 * ObjectsPerMode; j++)
- objs.Add(new BranchedType((j%6) + 1));
-
- objs = IgniteUtils.Shuffle(objs);
-
- // 2. Create new marshaller.
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType));
-
- BinaryConfiguration cfg = new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg }
- };
-
- Marshaller marsh = new Marshaller(cfg);
-
- // 3. Marshal all data and ensure deserialized object is fine.
- foreach (BranchedType obj in objs)
- {
- Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');
-
- byte[] data = marsh.Marshal(obj);
-
- BranchedType other = marsh.Unmarshal<BranchedType>(data);
-
- Assert.IsTrue(obj.Equals(other));
- }
-
- Console.WriteLine();
-
- // 4. Ensure that all fields are recorded.
- var desc = marsh.GetDescriptor(typeof (BranchedType));
-
- CollectionAssert.AreEquivalent(new[] {"mode", "f2", "f3", "f4", "f5", "f6", "f7", "f8"},
- desc.WriterTypeStructure.FieldTypes.Keys);
- }
- }
- }
-
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- public class BranchedType : IBinarizable
- {
- public int mode;
- public int f2;
- public int f3;
- public int f4;
- public int f5;
- public int f6;
- public int f7;
- public int f8;
-
- public BranchedType(int mode)
- {
- this.mode = mode;
-
- switch (mode)
- {
- case 1:
- f2 = 2;
-
- break;
-
- case 2:
- f2 = 2;
- f3 = 3;
- f4 = 4;
-
- break;
-
- case 3:
- f2 = 2;
- f3 = 3;
- f5 = 5;
-
- break;
-
- case 4:
- f2 = 2;
- f3 = 3;
- f5 = 5;
- f6 = 6;
-
- break;
-
- case 5:
- f2 = 2;
- f3 = 3;
- f7 = 7;
-
- break;
-
- case 6:
- f8 = 8;
-
- break;
- }
- }
-
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteInt("mode", mode);
-
- switch (mode)
- {
- case 1:
- writer.WriteInt("f2", f2);
-
- break;
-
- case 2:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f4", f4);
-
- break;
-
- case 3:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f5", f5);
-
- break;
-
- case 4:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f5", f5);
- writer.WriteInt("f6", f6);
-
- break;
-
- case 5:
- writer.WriteInt("f2", f2);
- writer.WriteInt("f3", f3);
- writer.WriteInt("f7", f7);
-
- break;
-
- case 6:
- writer.WriteInt("f8", f8);
-
- break;
- }
- }
-
- public void ReadBinary(IBinaryReader reader)
- {
- mode = reader.ReadInt("mode");
-
- switch (mode)
- {
- case 1:
- f2 = reader.ReadInt("f2");
-
- break;
-
- case 2:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f4 = reader.ReadInt("f4");
-
- break;
-
- case 3:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f5 = reader.ReadInt("f5");
-
- break;
-
- case 4:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f5 = reader.ReadInt("f5");
- f6 = reader.ReadInt("f6");
-
- break;
-
- case 5:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
- f7 = reader.ReadInt("f7");
-
- break;
-
- case 6:
- f8 = reader.ReadInt("f8");
-
- break;
- }
- }
-
- public bool Equals(BranchedType other)
- {
- return mode == other.mode && f2 == other.f2 && f3 == other.f3 && f4 == other.f4 && f5 == other.f5 &&
- f6 == other.f6 && f7 == other.f7 && f8 == other.f8;
- }
- }
-}
[44/55] [abbrv] ignite git commit: IGNITE-1966 .Net: Fixed handle
leak during partitioned scan query.
Posted by ag...@apache.org.
IGNITE-1966 .Net: Fixed handle leak during partitioned scan query.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9c717855
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9c717855
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9c717855
Branch: refs/heads/ignite-1.5
Commit: 9c7178557a7dde74fec0a709e8a574ecae0c6930
Parents: 911ca9d
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 14:32:27 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 14:32:27 2015 +0300
----------------------------------------------------------------------
.../processors/platform/cache/PlatformCache.java | 9 ++++-----
.../Cache/CacheTestAsyncWrapper.cs | 1 -
.../Cache/Query/CacheQueriesTest.cs | 2 --
.../Apache.Ignite.Core/Cache/Query/ScanQuery.cs | 14 +-------------
.../Impl/Cache/CacheEntryFilterHolder.cs | 15 ---------------
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 15 ++-------------
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 2 +-
7 files changed, 8 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c717855/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 6ec52d6..5943440 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -36,15 +36,14 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.cache.query.QueryCursorEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
import org.apache.ignite.internal.processors.platform.PlatformContext;
+import org.apache.ignite.internal.processors.platform.PlatformNativeException;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQuery;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformFieldsQueryCursor;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformQueryCursor;
-import org.apache.ignite.internal.processors.platform.PlatformNativeException;
import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.GridConcurrentFactory;
import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteFuture;
import org.jetbrains.annotations.Nullable;
@@ -373,13 +372,13 @@ public class PlatformCache extends PlatformAbstractTarget {
/**
* Loads cache via localLoadCache or loadCache.
*/
- private void loadCache0(BinaryRawReaderEx reader, boolean loc) throws IgniteCheckedException {
+ private void loadCache0(BinaryRawReaderEx reader, boolean loc) {
PlatformCacheEntryFilter filter = null;
Object pred = reader.readObjectDetached();
if (pred != null)
- filter = platformCtx.createCacheEntryFilter(pred, reader.readLong());
+ filter = platformCtx.createCacheEntryFilter(pred, 0);
Object[] args = reader.readObjectArray();
@@ -955,7 +954,7 @@ public class PlatformCache extends PlatformAbstractTarget {
Object pred = reader.readObjectDetached();
if (pred != null)
- qry.setFilter(platformCtx.createCacheEntryFilter(pred, reader.readLong()));
+ qry.setFilter(platformCtx.createCacheEntryFilter(pred, 0));
qry.setLocal(loc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c717855/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 430272f..33c9f11 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -26,7 +26,6 @@ namespace Apache.Ignite.Core.Tests.Cache
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
- using Apache.Ignite.Core.Common;
/// <summary>
/// Wraps IGridCache implementation to simplify async mode testing.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c717855/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 411ef05..08a98f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -565,7 +565,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// Check scan query with partitions.
/// </summary>
[Test]
- [Ignore("IGNITE-1012")]
public void TestScanQueryPartitions([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<QueryPerson>(MaxItemCnt, loc, false);
@@ -575,7 +574,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// Check scan query with partitions in binary mode.
/// </summary>
[Test]
- [Ignore("IGNITE-1012")]
public void TestScanQueryPartitionsBinary([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<BinaryObject>(MaxItemCnt, loc, true);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c717855/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
index 12fb363..2c9cf35 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Query/ScanQuery.cs
@@ -17,7 +17,6 @@
namespace Apache.Ignite.Core.Cache.Query
{
- using System;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Cache;
@@ -64,18 +63,7 @@ namespace Apache.Ignite.Core.Cache.Query
var holder = new CacheEntryFilterHolder(Filter, (key, val) => Filter.Invoke(
new CacheEntry<TK, TV>((TK) key, (TV) val)), writer.Marshaller, keepBinary);
- try
- {
- writer.WriteObject(holder);
- }
- catch (Exception)
- {
- writer.Marshaller.Ignite.HandleRegistry.Release(holder.Handle);
-
- throw;
- }
-
- writer.WriteLong(holder.Handle);
+ writer.WriteObject(holder);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c717855/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
index 0963145..4487c59 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
@@ -42,9 +42,6 @@ namespace Apache.Ignite.Core.Impl.Cache
/** Grid. */
private readonly Marshaller _marsh;
- /** Handle. */
- private readonly long _handle;
-
/// <summary>
/// Initializes a new instance of the <see cref="CacheEntryFilterHolder" /> class.
/// </summary>
@@ -63,16 +60,6 @@ namespace Apache.Ignite.Core.Impl.Cache
_invoker = invoker;
_marsh = marsh;
_keepBinary = keepBinary;
-
- _handle = marsh.Ignite.HandleRegistry.Allocate(this);
- }
-
- /// <summary>
- /// Gets the handle.
- /// </summary>
- public long Handle
- {
- get { return _handle; }
}
/// <summary>
@@ -112,8 +99,6 @@ namespace Apache.Ignite.Core.Impl.Cache
_marsh = reader0.Marshaller;
_invoker = GetInvoker(_pred);
-
- _handle = _marsh.Ignite.HandleRegistry.Allocate(this);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c717855/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index b1870d7..262ff12 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -270,21 +270,10 @@ namespace Apache.Ignite.Core.Impl.Cache
{
if (p != null)
{
- var p0 = new CacheEntryFilterHolder(p, (k, v) => p.Invoke(new CacheEntry<TK, TV>((TK)k, (TV)v)),
+ var p0 = new CacheEntryFilterHolder(p, (k, v) => p.Invoke(new CacheEntry<TK, TV>((TK) k, (TV) v)),
Marshaller, IsKeepBinary);
- try
- {
- writer.WriteObject(p0);
- }
- catch (Exception)
- {
- writer.Marshaller.Ignite.HandleRegistry.Release(p0.Handle);
-
- throw;
- }
-
- writer.WriteLong(p0.Handle);
+ writer.WriteObject(p0);
}
else
writer.WriteObject<CacheEntryFilterHolder>(null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9c717855/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 98ea106..e554cfc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -313,7 +313,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
private long CacheEntryFilterCreate(void* target, long memPtr)
{
- return SafeCall(() => CacheEntryFilterHolder.CreateInstance(memPtr, _ignite).Handle);
+ return SafeCall(() => _handleRegistry.Allocate(CacheEntryFilterHolder.CreateInstance(memPtr, _ignite)));
}
private int CacheEntryFilterApply(void* target, long objPtr, long memPtr)
[32/55] [abbrv] ignite git commit: IGNITE-1282: .NET: Disabled
accidently enabled test.
Posted by ag...@apache.org.
IGNITE-1282: .NET: Disabled accidently enabled test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6d834217
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6d834217
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6d834217
Branch: refs/heads/ignite-1.5
Commit: 6d8342176fbd15171975757a284ee30cdd3ba698
Parents: 3c74503
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 11:08:53 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 11:08:53 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6d834217/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 08a98f6..411ef05 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -565,6 +565,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// Check scan query with partitions.
/// </summary>
[Test]
+ [Ignore("IGNITE-1012")]
public void TestScanQueryPartitions([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<QueryPerson>(MaxItemCnt, loc, false);
@@ -574,6 +575,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// Check scan query with partitions in binary mode.
/// </summary>
[Test]
+ [Ignore("IGNITE-1012")]
public void TestScanQueryPartitionsBinary([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<BinaryObject>(MaxItemCnt, loc, true);
[11/55] [abbrv] ignite git commit: IGNITE-1847: Added "field" method
to BinaryType and reworked internal metadata handling.
Posted by ag...@apache.org.
IGNITE-1847: Added "field" method to BinaryType and reworked internal metadata handling.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/63d55062
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/63d55062
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/63d55062
Branch: refs/heads/ignite-1.5
Commit: 63d55062790f481f104bd03eaf53c75473233e56
Parents: f3b0be7
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 18 10:24:15 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 18 10:24:15 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/binary/BinaryObject.java | 9 -
.../org/apache/ignite/binary/BinaryType.java | 11 +-
.../internal/portable/BinaryFieldImpl.java | 14 +-
.../portable/BinaryMetaDataCollector.java | 99 +++--
.../internal/portable/BinaryMetaDataImpl.java | 150 --------
.../internal/portable/BinaryMetadata.java | 152 ++++++++
.../portable/BinaryMetadataHandler.java | 44 +++
.../portable/BinaryNoopMetadataHandler.java | 53 +++
.../internal/portable/BinaryObjectEx.java | 4 +-
.../internal/portable/BinaryObjectImpl.java | 13 -
.../portable/BinaryObjectOffheapImpl.java | 13 -
.../internal/portable/BinaryTypeImpl.java | 75 ++++
.../portable/PortableClassDescriptor.java | 169 +++++----
.../internal/portable/PortableContext.java | 39 +-
.../portable/PortableMetaDataHandler.java | 44 ---
.../ignite/internal/portable/PortableUtils.java | 104 +++++-
.../builder/BinaryObjectBuilderImpl.java | 32 +-
.../portable/builder/PortableValueWithType.java | 9 +-
.../CacheObjectBinaryProcessorImpl.java | 360 +++++++------------
.../cache/portable/PortableMetaDataKey.java | 10 +-
.../platform/PlatformContextImpl.java | 10 +-
.../PlatformDotNetConfigurationClosure.java | 19 +-
.../processors/query/GridQueryProcessor.java | 2 +-
.../portable/BinaryFieldsAbstractSelfTest.java | 24 +-
...idBinaryObjectBuilderAdditionalSelfTest.java | 2 +-
.../GridBinaryObjectBuilderSelfTest.java | 4 +-
...idPortableMarshallerCtxDisabledSelfTest.java | 33 +-
.../GridPortableMarshallerSelfTest.java | 13 +-
.../portable/GridPortableMetaDataSelfTest.java | 12 +-
.../portable/GridPortableWildcardsSelfTest.java | 23 +-
.../PortableCompactOffsetsAbstractSelfTest.java | 21 +-
.../portable/TestCachingMetadataHandler.java | 45 +++
...ntNodeBinaryObjectMetadataMultinodeTest.java | 4 +-
...CacheClientNodeBinaryObjectMetadataTest.java | 5 +-
...ridPortableCacheEntryMemorySizeSelfTest.java | 14 +-
.../PlatformComputeBinarizableArgTask.java | 2 +-
36 files changed, 840 insertions(+), 797 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
index f48f350..9481618 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
@@ -137,15 +137,6 @@ public interface BinaryObject extends Serializable, Cloneable {
public boolean hasField(String fieldName);
/**
- * Gets field descriptor.
- *
- * @param fieldName Field name.
- * @return Field descriptor.
- * @throws BinaryObjectException If failed.
- */
- public BinaryField fieldDescriptor(String fieldName) throws BinaryObjectException;
-
- /**
* Gets fully deserialized instance of binary object.
*
* @return Fully deserialized instance of binary object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
index d149fd4..52bb212 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryType.java
@@ -38,7 +38,7 @@ public interface BinaryType {
*
* @return Collection of all field names for this binary type.
*/
- public Collection<String> fields();
+ public Collection<String> fieldNames();
/**
* Gets name of the field type for a given field.
@@ -49,6 +49,15 @@ public interface BinaryType {
public String fieldTypeName(String fieldName);
/**
+ * Get {@link BinaryField} for the given field name. Later this field can be used for fast field's value
+ * retrieval from concrete {@link BinaryObject}.
+ *
+ * @param fieldName Field name.
+ * @return Binary field.
+ */
+ public BinaryField field(String fieldName);
+
+ /**
* Binary objects can optionally specify custom key-affinity mapping in the
* configuration. This method returns the name of the field which should be
* used for the key-affinity mapping.
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldImpl.java
index b8a25c1..810c820 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryFieldImpl.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.binary.BinaryObject;
@@ -26,6 +27,9 @@ import org.apache.ignite.binary.BinaryField;
* Implementation of portable field descriptor.
*/
public class BinaryFieldImpl implements BinaryField {
+ /** Type ID. */
+ private final int typeId;
+
/** Well-known object schemas. */
@GridToStringExclude
private final PortableSchemaRegistry schemas;
@@ -43,11 +47,13 @@ public class BinaryFieldImpl implements BinaryField {
* @param fieldName Field name.
* @param fieldId Field ID.
*/
- public BinaryFieldImpl(PortableSchemaRegistry schemas, String fieldName, int fieldId) {
+ public BinaryFieldImpl(int typeId, PortableSchemaRegistry schemas, String fieldName, int fieldId) {
+ assert typeId != 0;
assert schemas != null;
assert fieldName != null;
assert fieldId != 0;
+ this.typeId = typeId;
this.schemas = schemas;
this.fieldName = fieldName;
this.fieldId = fieldId;
@@ -82,6 +88,12 @@ public class BinaryFieldImpl implements BinaryField {
* @return Field offset.
*/
private int fieldOrder(BinaryObjectEx obj) {
+ if (typeId != obj.typeId()) {
+ throw new BinaryObjectException("Failed to get field because type ID of passed object differs" +
+ " from type ID this " + BinaryField.class.getSimpleName() + " belongs to [expected=" + typeId +
+ ", actual=" + obj.typeId() + ']');
+ }
+
int schemaId = obj.schemaId();
PortableSchema schema = schemas.schema(schemaId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java
index b053a55..67e1a0d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataCollector.java
@@ -35,9 +35,9 @@ import org.jetbrains.annotations.Nullable;
/**
* Writer for meta data collection.
*/
-class BinaryMetaDataCollector implements BinaryWriter {
+class BinaryMetadataCollector implements BinaryWriter {
/** */
- private final Map<String, String> meta = new HashMap<>();
+ private final Map<String, Integer> meta = new HashMap<>();
/** */
private final String typeName;
@@ -45,176 +45,176 @@ class BinaryMetaDataCollector implements BinaryWriter {
/**
* @param typeName Type name.
*/
- BinaryMetaDataCollector(String typeName) {
+ BinaryMetadataCollector(String typeName) {
this.typeName = typeName;
}
/**
* @return Field meta data.
*/
- Map<String, String> meta() {
+ Map<String, Integer> meta() {
return meta;
}
/** {@inheritDoc} */
@Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
- add(fieldName, byte.class);
+ add(fieldName, PortableClassDescriptor.Mode.BYTE);
}
/** {@inheritDoc} */
@Override public void writeShort(String fieldName, short val) throws BinaryObjectException {
- add(fieldName, short.class);
+ add(fieldName, PortableClassDescriptor.Mode.SHORT);
}
/** {@inheritDoc} */
@Override public void writeInt(String fieldName, int val) throws BinaryObjectException {
- add(fieldName, int.class);
+ add(fieldName, PortableClassDescriptor.Mode.INT);
}
/** {@inheritDoc} */
@Override public void writeLong(String fieldName, long val) throws BinaryObjectException {
- add(fieldName, long.class);
+ add(fieldName, PortableClassDescriptor.Mode.LONG);
}
/** {@inheritDoc} */
@Override public void writeFloat(String fieldName, float val) throws BinaryObjectException {
- add(fieldName, float.class);
+ add(fieldName, PortableClassDescriptor.Mode.FLOAT);
}
/** {@inheritDoc} */
@Override public void writeDouble(String fieldName, double val) throws BinaryObjectException {
- add(fieldName, double.class);
+ add(fieldName, PortableClassDescriptor.Mode.DOUBLE);
}
/** {@inheritDoc} */
@Override public void writeChar(String fieldName, char val) throws BinaryObjectException {
- add(fieldName, char.class);
+ add(fieldName, PortableClassDescriptor.Mode.CHAR);
}
/** {@inheritDoc} */
@Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException {
- add(fieldName, boolean.class);
+ add(fieldName, PortableClassDescriptor.Mode.BOOLEAN);
}
/** {@inheritDoc} */
@Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL.typeName());
+ add(fieldName, PortableClassDescriptor.Mode.DECIMAL);
}
/** {@inheritDoc} */
@Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException {
- add(fieldName, String.class);
+ add(fieldName, PortableClassDescriptor.Mode.STRING);
}
/** {@inheritDoc} */
@Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException {
- add(fieldName, UUID.class);
+ add(fieldName, PortableClassDescriptor.Mode.UUID);
}
/** {@inheritDoc} */
@Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException {
- add(fieldName, Date.class);
+ add(fieldName, PortableClassDescriptor.Mode.DATE);
}
/** {@inheritDoc} */
@Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException {
- add(fieldName, Timestamp.class);
+ add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP);
}
/** {@inheritDoc} */
@Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException {
- add(fieldName, Enum.class);
+ add(fieldName, PortableClassDescriptor.Mode.ENUM);
}
/** {@inheritDoc} */
@Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException {
- add(fieldName, Enum[].class);
+ add(fieldName, PortableClassDescriptor.Mode.ENUM_ARR);
}
/** {@inheritDoc} */
@Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException {
- add(fieldName, Object.class);
+ add(fieldName, PortableClassDescriptor.Mode.OBJECT);
}
/** {@inheritDoc} */
@Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException {
- add(fieldName, byte[].class);
+ add(fieldName, PortableClassDescriptor.Mode.BYTE_ARR);
}
/** {@inheritDoc} */
@Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException {
- add(fieldName, short[].class);
+ add(fieldName, PortableClassDescriptor.Mode.SHORT_ARR);
}
/** {@inheritDoc} */
@Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException {
- add(fieldName, int[].class);
+ add(fieldName, PortableClassDescriptor.Mode.INT_ARR);
}
/** {@inheritDoc} */
@Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException {
- add(fieldName, long[].class);
+ add(fieldName, PortableClassDescriptor.Mode.LONG_ARR);
}
/** {@inheritDoc} */
@Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException {
- add(fieldName, float[].class);
+ add(fieldName, PortableClassDescriptor.Mode.FLOAT_ARR);
}
/** {@inheritDoc} */
@Override public void writeDoubleArray(String fieldName, @Nullable double[] val) throws BinaryObjectException {
- add(fieldName, double[].class);
+ add(fieldName, PortableClassDescriptor.Mode.DOUBLE_ARR);
}
/** {@inheritDoc} */
@Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException {
- add(fieldName, char[].class);
+ add(fieldName, PortableClassDescriptor.Mode.CHAR_ARR);
}
/** {@inheritDoc} */
@Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val) throws BinaryObjectException {
- add(fieldName, boolean[].class);
+ add(fieldName, PortableClassDescriptor.Mode.BOOLEAN_ARR);
}
/** {@inheritDoc} */
@Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val) throws BinaryObjectException {
- add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR.typeName());
+ add(fieldName, PortableClassDescriptor.Mode.DECIMAL_ARR);
}
/** {@inheritDoc} */
@Override public void writeStringArray(String fieldName, @Nullable String[] val) throws BinaryObjectException {
- add(fieldName, String[].class);
+ add(fieldName, PortableClassDescriptor.Mode.STRING_ARR);
}
/** {@inheritDoc} */
@Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException {
- add(fieldName, UUID[].class);
+ add(fieldName, PortableClassDescriptor.Mode.UUID_ARR);
}
/** {@inheritDoc} */
@Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException {
- add(fieldName, Date[].class);
+ add(fieldName, PortableClassDescriptor.Mode.DATE_ARR);
}
/** {@inheritDoc} */
@Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException {
- add(fieldName, Timestamp[].class);
+ add(fieldName, PortableClassDescriptor.Mode.TIMESTAMP_ARR);
}
/** {@inheritDoc} */
@Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException {
- add(fieldName, Object[].class);
+ add(fieldName, PortableClassDescriptor.Mode.OBJECT_ARR);
}
/** {@inheritDoc} */
@Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
throws BinaryObjectException {
- add(fieldName, Collection.class);
+ add(fieldName, PortableClassDescriptor.Mode.COL);
}
/** {@inheritDoc} */
@Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map) throws BinaryObjectException {
- add(fieldName, Map.class);
+ add(fieldName, PortableClassDescriptor.Mode.MAP);
}
/** {@inheritDoc} */
@@ -230,32 +230,23 @@ class BinaryMetaDataCollector implements BinaryWriter {
/**
* @param name Field name.
- * @param fieldType Field type.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @param mode Field mode.
+ * @throws BinaryObjectException In case of error.
*/
- private void add(String name, Class<?> fieldType) throws BinaryObjectException {
- assert fieldType != null;
-
- add(name, fieldType.getSimpleName());
- }
-
- /**
- * @param name Field name.
- * @param fieldTypeName Field type name.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- private void add(String name, String fieldTypeName) throws BinaryObjectException {
+ private void add(String name, PortableClassDescriptor.Mode mode) throws BinaryObjectException {
assert name != null;
- String oldFieldTypeName = meta.put(name, fieldTypeName);
+ int fieldTypeId = mode.typeId();
+
+ Integer oldFieldTypeId = meta.put(name, fieldTypeId);
- if (oldFieldTypeName != null && !oldFieldTypeName.equals(fieldTypeName)) {
+ if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) {
throw new BinaryObjectException(
"Field is written twice with different types [" +
"typeName=" + typeName +
", fieldName=" + name +
- ", fieldTypeName1=" + oldFieldTypeName +
- ", fieldTypeName2=" + fieldTypeName +
+ ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldTypeId) +
+ ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) +
']'
);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java
deleted file mode 100644
index 18f538b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetaDataImpl.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryRawReader;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Portable meta data implementation.
- */
-public class BinaryMetaDataImpl implements BinaryType, Binarylizable, Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private String typeName;
-
- /** */
- @GridToStringInclude
- private Map<String, String> fields;
-
- /** */
- private volatile Map<Integer, String> fldIdToName;
-
- /** */
- private String affKeyFieldName;
-
- /**
- * For {@link Externalizable}.
- */
- public BinaryMetaDataImpl() {
- // No-op.
- }
-
- /**
- * @param typeName Type name.
- * @param fields Fields map.
- * @param affKeyFieldName Affinity key field name.
- */
- public BinaryMetaDataImpl(String typeName, @Nullable Map<String, String> fields,
- @Nullable String affKeyFieldName) {
- assert typeName != null;
-
- this.typeName = typeName;
- this.fields = fields;
- this.affKeyFieldName = affKeyFieldName;
- }
-
- /** {@inheritDoc} */
- @Override public String typeName() {
- return typeName;
- }
-
- /** {@inheritDoc} */
- @Override public Collection<String> fields() {
- return fields != null ? fields.keySet() : Collections.<String>emptyList();
- }
-
- /**
- * @return Fields.
- */
- public Map<String, String> fields0() {
- return fields != null ? fields : Collections.<String, String>emptyMap();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String fieldTypeName(String fieldName) {
- return fields != null ? fields.get(fieldName) : null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String affinityKeyFieldName() {
- return affKeyFieldName;
- }
-
- /**
- * @return Fields meta data.
- */
- public Map<String, String> fieldsMeta() {
- return fields != null ? fields : Collections.<String, String>emptyMap();
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeString(out, typeName);
- U.writeMap(out, fields);
- U.writeString(out, affKeyFieldName);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- typeName = U.readString(in);
- fields = U.readMap(in);
- affKeyFieldName = U.readString(in);
- }
-
- /** {@inheritDoc} */
- @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
- BinaryRawWriter raw = writer.rawWriter();
-
- raw.writeString(typeName);
- raw.writeString(affKeyFieldName);
- raw.writeMap(fields);
- }
-
- /** {@inheritDoc} */
- @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
- BinaryRawReader raw = reader.rawReader();
-
- typeName = raw.readString();
- affKeyFieldName = raw.readString();
- fields = raw.readMap();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(BinaryMetaDataImpl.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java
new file mode 100644
index 0000000..fe88d11
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Portable metadata which is passed over a wire.
+ */
+public class BinaryMetadata implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Type ID. */
+ private int typeId;
+
+ /** Type name. */
+ private String typeName;
+
+ /** Recorded object fields. */
+ @GridToStringInclude
+ private Map<String, Integer> fields;
+
+ /** Affinity key field name. */
+ private String affKeyFieldName;
+
+ /**
+ * For {@link Externalizable}.
+ */
+ public BinaryMetadata() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param typeId Type ID.
+ * @param typeName Type name.
+ * @param fields Fields map.
+ * @param affKeyFieldName Affinity key field name.
+ */
+ public BinaryMetadata(int typeId, String typeName, @Nullable Map<String, Integer> fields,
+ @Nullable String affKeyFieldName) {
+ assert typeName != null;
+
+ this.typeId = typeId;
+ this.typeName = typeName;
+ this.fields = fields;
+ this.affKeyFieldName = affKeyFieldName;
+ }
+
+ /**
+ * @return Type ID.
+ */
+ public int typeId() {
+ return typeId;
+ }
+
+ /**
+ * @return Type name.
+ */
+ public String typeName() {
+ return typeName;
+ }
+
+ /**
+ * @return Fields.
+ */
+ public Collection<String> fields() {
+ return fields != null ? fields.keySet() : Collections.<String>emptyList();
+ }
+
+ /**
+ * @return Fields.
+ */
+ public Map<String, Integer> fieldsMap() {
+ return fields != null ? fields : Collections.<String, Integer>emptyMap();
+ }
+
+ /**
+ * @param fieldName Field name.
+ * @return Field type name.
+ */
+ @Nullable public String fieldTypeName(String fieldName) {
+ Integer typeId = fields != null ? fields.get(fieldName) : null;
+
+ return typeId != null ? PortableUtils.fieldTypeName(typeId) : null;
+ }
+
+ /**
+ * @return Affinity key field name.
+ */
+ @Nullable public String affinityKeyFieldName() {
+ return affKeyFieldName;
+ }
+
+ /**
+ * Wrap metadata into binary type.
+ *
+ * @param ctx Portable context.
+ * @return Binary type.
+ */
+ public BinaryTypeImpl wrap(PortableContext ctx) {
+ return new BinaryTypeImpl(ctx, this);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(typeId);
+ U.writeString(out, typeName);
+ U.writeMap(out, fields);
+ U.writeString(out, affKeyFieldName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ typeId = in.readInt();
+ typeName = U.readString(in);
+ fields = U.readMap(in);
+ affKeyFieldName = U.readString(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(BinaryMetadata.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataHandler.java
new file mode 100644
index 0000000..add8c2d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataHandler.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
+
+/**
+ * Portable meta data handler.
+ */
+public interface BinaryMetadataHandler {
+ /**
+ * Adds meta data.
+ *
+ * @param typeId Type ID.
+ * @param meta Meta data.
+ * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ */
+ public void addMeta(int typeId, BinaryType meta) throws BinaryObjectException;
+
+ /**
+ * Gets meta data for provided type ID.
+ *
+ * @param typeId Type ID.
+ * @return Meta data.
+ * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ */
+ public BinaryType metadata(int typeId) throws BinaryObjectException;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryNoopMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryNoopMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryNoopMetadataHandler.java
new file mode 100644
index 0000000..c4fc5e3
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryNoopMetadataHandler.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
+
+/**
+ * No-op metadata handler.
+ */
+public class BinaryNoopMetadataHandler implements BinaryMetadataHandler {
+ /** Cached singleton instance. */
+ private static final BinaryNoopMetadataHandler INSTANCE = new BinaryNoopMetadataHandler();
+
+ /**
+ * @return Instance.
+ */
+ public static BinaryNoopMetadataHandler instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Private constructor.
+ */
+ private BinaryNoopMetadataHandler() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void addMeta(int typeId, BinaryType meta) throws BinaryObjectException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public BinaryType metadata(int typeId) throws BinaryObjectException {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
index 50b9d42..b3512ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
@@ -176,10 +176,10 @@ public abstract class BinaryObjectEx implements BinaryObject {
SB buf = new SB(meta.typeName());
- if (meta.fields() != null) {
+ if (meta.fieldNames() != null) {
buf.a(" [hash=").a(idHash);
- for (String name : meta.fields()) {
+ for (String name : meta.fieldNames()) {
Object val = field(ctx, name);
buf.a(", ").a(name).a('=');
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
index 800ca40..d432ea0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
@@ -462,19 +462,6 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
}
/** {@inheritDoc} */
- @Override public BinaryField fieldDescriptor(String fieldName) throws BinaryObjectException {
- A.notNull(fieldName, "fieldName");
-
- int typeId = typeId();
-
- PortableSchemaRegistry schemaReg = ctx.schemaRegistry(typeId);
-
- int fieldId = ctx.userTypeIdMapper(typeId).fieldId(typeId, fieldName);
-
- return new BinaryFieldImpl(schemaReg, fieldName, fieldId);
- }
-
- /** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(ctx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
index 9b6735f..f7cb844 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
@@ -140,19 +140,6 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
}
/** {@inheritDoc} */
- @Override public BinaryField fieldDescriptor(String fieldName) throws BinaryObjectException {
- A.notNull(fieldName, "fieldName");
-
- int typeId = typeId();
-
- PortableSchemaRegistry schemaReg = ctx.schemaRegistry(typeId);
-
- int fieldId = ctx.userTypeIdMapper(typeId).fieldId(typeId, fieldName);
-
- return new BinaryFieldImpl(schemaReg, fieldName, fieldId);
- }
-
- /** {@inheritDoc} */
@Override public int start() {
return start;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
new file mode 100644
index 0000000..40b6252
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryType;
+
+import java.util.Collection;
+
+/**
+ * Binary type implementation.
+ */
+public class BinaryTypeImpl implements BinaryType {
+ /** Portable context. */
+ private final PortableContext ctx;
+
+ /** Type metadata. */
+ private final BinaryMetadata meta;
+
+ /**
+ * Constructor.
+ *
+ * @param ctx Portable context.
+ * @param meta Type metadata.
+ */
+ public BinaryTypeImpl(PortableContext ctx, BinaryMetadata meta) {
+ this.ctx = ctx;
+ this.meta = meta;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String typeName() {
+ return meta.typeName();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> fieldNames() {
+ return meta.fields();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String fieldTypeName(String fieldName) {
+ return meta.fieldTypeName(fieldName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public BinaryFieldImpl field(String fieldName) {
+ return ctx.createField(meta.typeId(), fieldName);
+ }
+
+ public String affinityKeyFieldName() {
+ return meta.affinityKeyFieldName();
+ }
+
+ /**
+ * @return Metadata.
+ */
+ public BinaryMetadata metadata() {
+ return meta;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index c9870b4..225e0ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -92,7 +92,7 @@ public class PortableClassDescriptor {
private final Method readResolveMtd;
/** */
- private final Map<String, String> fieldsMeta;
+ private final Map<String, Integer> fieldsMeta;
/** */
private final boolean keepDeserialized;
@@ -182,7 +182,7 @@ public class PortableClassDescriptor {
case UUID_ARR:
case DATE_ARR:
case TIMESTAMP_ARR:
- case OBJ_ARR:
+ case OBJECT_ARR:
case COL:
case MAP:
case MAP_ENTRY:
@@ -210,7 +210,7 @@ public class PortableClassDescriptor {
ctor = constructor(cls);
fields = new ArrayList<>();
- fieldsMeta = metaDataEnabled ? new HashMap<String, String>() : null;
+ fieldsMeta = metaDataEnabled ? new HashMap<String, Integer>() : null;
Collection<String> names = new HashSet<>();
Collection<Integer> ids = new HashSet<>();
@@ -237,7 +237,7 @@ public class PortableClassDescriptor {
fields.add(fieldInfo);
if (metaDataEnabled)
- fieldsMeta.put(name, fieldInfo.fieldMode().typeName());
+ fieldsMeta.put(name, fieldInfo.fieldMode().typeId());
}
}
}
@@ -283,7 +283,7 @@ public class PortableClassDescriptor {
/**
* @return Fields meta data.
*/
- Map<String, String> fieldsMeta() {
+ Map<String, Integer> fieldsMeta() {
return fieldsMeta;
}
@@ -337,6 +337,7 @@ public class PortableClassDescriptor {
/**
* @return portableReadResolve() method
*/
+ @SuppressWarnings("UnusedDeclaration")
@Nullable Method getReadResolveMethod() {
return readResolveMtd;
}
@@ -430,66 +431,66 @@ public class PortableClassDescriptor {
break;
case SHORT_ARR:
- writer.doWriteShortArray((short[])obj);
+ writer.doWriteShortArray((short[]) obj);
break;
case INT_ARR:
- writer.doWriteIntArray((int[])obj);
+ writer.doWriteIntArray((int[]) obj);
break;
case LONG_ARR:
- writer.doWriteLongArray((long[])obj);
+ writer.doWriteLongArray((long[]) obj);
break;
case FLOAT_ARR:
- writer.doWriteFloatArray((float[])obj);
+ writer.doWriteFloatArray((float[]) obj);
break;
case DOUBLE_ARR:
- writer.doWriteDoubleArray((double[])obj);
+ writer.doWriteDoubleArray((double[]) obj);
break;
case CHAR_ARR:
- writer.doWriteCharArray((char[])obj);
+ writer.doWriteCharArray((char[]) obj);
break;
case BOOLEAN_ARR:
- writer.doWriteBooleanArray((boolean[])obj);
+ writer.doWriteBooleanArray((boolean[]) obj);
break;
case DECIMAL_ARR:
- writer.doWriteDecimalArray((BigDecimal[])obj);
+ writer.doWriteDecimalArray((BigDecimal[]) obj);
break;
case STRING_ARR:
- writer.doWriteStringArray((String[])obj);
+ writer.doWriteStringArray((String[]) obj);
break;
case UUID_ARR:
- writer.doWriteUuidArray((UUID[])obj);
+ writer.doWriteUuidArray((UUID[]) obj);
break;
case DATE_ARR:
- writer.doWriteDateArray((Date[])obj);
+ writer.doWriteDateArray((Date[]) obj);
break;
case TIMESTAMP_ARR:
- writer.doWriteTimestampArray((Timestamp[])obj);
+ writer.doWriteTimestampArray((Timestamp[]) obj);
break;
- case OBJ_ARR:
+ case OBJECT_ARR:
writer.doWriteObjectArray((Object[])obj);
break;
@@ -543,9 +544,9 @@ public class PortableClassDescriptor {
writer.popSchema();
}
- if (obj.getClass() != BinaryMetaDataImpl.class
+ if (obj.getClass() != BinaryMetadata.class
&& ctx.isMetaDataChanged(typeId, writer.metaDataHashSum())) {
- BinaryMetaDataCollector metaCollector = new BinaryMetaDataCollector(typeName);
+ BinaryMetadataCollector metaCollector = new BinaryMetadataCollector(typeName);
if (serializer != null)
serializer.writeBinary(obj, metaCollector);
@@ -711,6 +712,7 @@ public class PortableClassDescriptor {
* @return Constructor.
* @throws org.apache.ignite.binary.BinaryObjectException If constructor doesn't exist.
*/
+ @SuppressWarnings("ConstantConditions")
@Nullable private static Constructor<?> constructor(Class<?> cls) throws BinaryObjectException {
assert cls != null;
@@ -739,11 +741,8 @@ public class PortableClassDescriptor {
Method writeObj = cls.getDeclaredMethod("writeObject", ObjectOutputStream.class);
Method readObj = cls.getDeclaredMethod("readObject", ObjectInputStream.class);
- if (!Modifier.isStatic(writeObj.getModifiers()) && !Modifier.isStatic(readObj.getModifiers()) &&
- writeObj.getReturnType() == void.class && readObj.getReturnType() == void.class)
- use = true;
- else
- use = false;
+ use = !Modifier.isStatic(writeObj.getModifiers()) && !Modifier.isStatic(readObj.getModifiers()) &&
+ writeObj.getReturnType() == void.class && readObj.getReturnType() == void.class;
}
catch (NoSuchMethodException e) {
use = false;
@@ -813,7 +812,7 @@ public class PortableClassDescriptor {
else if (cls == Timestamp[].class)
return Mode.TIMESTAMP_ARR;
else if (cls.isArray())
- return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJ_ARR;
+ return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJECT_ARR;
else if (cls == BinaryObjectImpl.class)
return Mode.PORTABLE_OBJ;
else if (Binarylizable.class.isAssignableFrom(cls))
@@ -961,66 +960,66 @@ public class PortableClassDescriptor {
break;
case SHORT_ARR:
- writer.writeShortArrayField((short[])val);
+ writer.writeShortArrayField((short[]) val);
break;
case INT_ARR:
- writer.writeIntArrayField((int[])val);
+ writer.writeIntArrayField((int[]) val);
break;
case LONG_ARR:
- writer.writeLongArrayField((long[])val);
+ writer.writeLongArrayField((long[]) val);
break;
case FLOAT_ARR:
- writer.writeFloatArrayField((float[])val);
+ writer.writeFloatArrayField((float[]) val);
break;
case DOUBLE_ARR:
- writer.writeDoubleArrayField((double[])val);
+ writer.writeDoubleArrayField((double[]) val);
break;
case CHAR_ARR:
- writer.writeCharArrayField((char[])val);
+ writer.writeCharArrayField((char[]) val);
break;
case BOOLEAN_ARR:
- writer.writeBooleanArrayField((boolean[])val);
+ writer.writeBooleanArrayField((boolean[]) val);
break;
case DECIMAL_ARR:
- writer.writeDecimalArrayField((BigDecimal[])val);
+ writer.writeDecimalArrayField((BigDecimal[]) val);
break;
case STRING_ARR:
- writer.writeStringArrayField((String[])val);
+ writer.writeStringArrayField((String[]) val);
break;
case UUID_ARR:
- writer.writeUuidArrayField((UUID[])val);
+ writer.writeUuidArrayField((UUID[]) val);
break;
case DATE_ARR:
- writer.writeDateArrayField((Date[])val);
+ writer.writeDateArrayField((Date[]) val);
break;
case TIMESTAMP_ARR:
- writer.writeTimestampArrayField((Timestamp[])val);
+ writer.writeTimestampArrayField((Timestamp[]) val);
break;
- case OBJ_ARR:
+ case OBJECT_ARR:
writer.writeObjectArrayField((Object[])val);
break;
@@ -1211,7 +1210,7 @@ public class PortableClassDescriptor {
break;
- case OBJ_ARR:
+ case OBJECT_ARR:
val = reader.readObjectArray(id);
break;
@@ -1275,134 +1274,134 @@ public class PortableClassDescriptor {
/** */
enum Mode {
/** */
- BYTE("byte"),
+ BYTE(GridPortableMarshaller.BYTE),
/** */
- SHORT("short"),
+ SHORT(GridPortableMarshaller.SHORT),
/** */
- INT("int"),
+ INT(GridPortableMarshaller.INT),
/** */
- LONG("long"),
+ LONG(GridPortableMarshaller.LONG),
/** */
- FLOAT("float"),
+ FLOAT(GridPortableMarshaller.FLOAT),
/** */
- DOUBLE("double"),
+ DOUBLE(GridPortableMarshaller.DOUBLE),
/** */
- CHAR("char"),
+ CHAR(GridPortableMarshaller.CHAR),
/** */
- BOOLEAN("boolean"),
+ BOOLEAN(GridPortableMarshaller.BOOLEAN),
/** */
- DECIMAL("decimal"),
+ DECIMAL(GridPortableMarshaller.DECIMAL),
/** */
- STRING("String"),
+ STRING(GridPortableMarshaller.STRING),
/** */
- UUID("UUID"),
+ UUID(GridPortableMarshaller.UUID),
/** */
- DATE("Date"),
+ DATE(GridPortableMarshaller.DATE),
/** */
- TIMESTAMP("Timestamp"),
+ TIMESTAMP(GridPortableMarshaller.TIMESTAMP),
/** */
- BYTE_ARR("byte[]"),
+ BYTE_ARR(GridPortableMarshaller.BYTE_ARR),
/** */
- SHORT_ARR("short[]"),
+ SHORT_ARR(GridPortableMarshaller.SHORT_ARR),
/** */
- INT_ARR("int[]"),
+ INT_ARR(GridPortableMarshaller.INT_ARR),
/** */
- LONG_ARR("long[]"),
+ LONG_ARR(GridPortableMarshaller.LONG_ARR),
/** */
- FLOAT_ARR("float[]"),
+ FLOAT_ARR(GridPortableMarshaller.FLOAT_ARR),
/** */
- DOUBLE_ARR("double[]"),
+ DOUBLE_ARR(GridPortableMarshaller.DOUBLE_ARR),
/** */
- CHAR_ARR("char[]"),
+ CHAR_ARR(GridPortableMarshaller.CHAR_ARR),
/** */
- BOOLEAN_ARR("boolean[]"),
+ BOOLEAN_ARR(GridPortableMarshaller.BOOLEAN_ARR),
/** */
- DECIMAL_ARR("decimal[]"),
+ DECIMAL_ARR(GridPortableMarshaller.DECIMAL_ARR),
/** */
- STRING_ARR("String[]"),
+ STRING_ARR(GridPortableMarshaller.STRING_ARR),
/** */
- UUID_ARR("UUID[]"),
+ UUID_ARR(GridPortableMarshaller.UUID_ARR),
/** */
- DATE_ARR("Date[]"),
+ DATE_ARR(GridPortableMarshaller.DATE_ARR),
/** */
- TIMESTAMP_ARR("Timestamp[]"),
+ TIMESTAMP_ARR(GridPortableMarshaller.TIMESTAMP_ARR),
/** */
- OBJ_ARR("Object[]"),
+ OBJECT_ARR(GridPortableMarshaller.OBJ_ARR),
/** */
- COL("Collection"),
+ COL(GridPortableMarshaller.COL),
/** */
- MAP("Map"),
+ MAP(GridPortableMarshaller.MAP),
/** */
- MAP_ENTRY("Entry"),
+ MAP_ENTRY(GridPortableMarshaller.MAP_ENTRY),
/** */
- PORTABLE_OBJ("Object"),
+ PORTABLE_OBJ(GridPortableMarshaller.OBJ),
/** */
- ENUM("Enum"),
+ ENUM(GridPortableMarshaller.ENUM),
/** */
- ENUM_ARR("Enum[]"),
+ ENUM_ARR(GridPortableMarshaller.ENUM_ARR),
/** */
- CLASS("Class"),
+ CLASS(GridPortableMarshaller.CLASS),
/** */
- PORTABLE("Object"),
+ PORTABLE(GridPortableMarshaller.PORTABLE_OBJ),
/** */
- EXTERNALIZABLE("Object"),
+ EXTERNALIZABLE(GridPortableMarshaller.OBJ),
/** */
- OBJECT("Object"),
+ OBJECT(GridPortableMarshaller.OBJ),
/** */
- EXCLUSION("Exclusion");
+ EXCLUSION(GridPortableMarshaller.OBJ);
/** */
- private final String typeName;
+ private final int typeId;
/**
- * @param typeName Type name.
+ * @param typeId Type ID.
*/
- Mode(String typeName) {
- this.typeName = typeName;
+ Mode(int typeId) {
+ this.typeId = typeId;
}
/**
- * @return Type name.
+ * @return Type ID.
*/
- String typeName() {
- return typeName;
+ int typeId() {
+ return typeId;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 928be63..86578ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -134,7 +134,7 @@ public class PortableContext implements Externalizable {
private final Map<String, BinaryIdMapper> typeMappers = new ConcurrentHashMap8<>(0);
/** */
- private PortableMetaDataHandler metaHnd;
+ private BinaryMetadataHandler metaHnd;
/** */
private MarshallerContext marshCtx;
@@ -165,8 +165,9 @@ public class PortableContext implements Externalizable {
* @param metaHnd Meta data handler.
* @param igniteCfg Ignite configuration.
*/
- public PortableContext(PortableMetaDataHandler metaHnd, @Nullable IgniteConfiguration igniteCfg) {
+ public PortableContext(BinaryMetadataHandler metaHnd, IgniteConfiguration igniteCfg) {
assert metaHnd != null;
+ assert igniteCfg != null;
this.metaHnd = metaHnd;
this.igniteCfg = igniteCfg;
@@ -202,7 +203,6 @@ public class PortableContext implements Externalizable {
registerPredefinedType(Date.class, GridPortableMarshaller.DATE);
registerPredefinedType(Timestamp.class, GridPortableMarshaller.TIMESTAMP);
registerPredefinedType(UUID.class, GridPortableMarshaller.UUID);
- // TODO: How to handle timestamp? It has the same ID in .Net.
registerPredefinedType(byte[].class, GridPortableMarshaller.BYTE_ARR);
registerPredefinedType(short[].class, GridPortableMarshaller.SHORT_ARR);
@@ -237,9 +237,6 @@ public class PortableContext implements Externalizable {
registerPredefinedType(T2.class, 62);
// IDs range [200..1000] is used by Ignite internal APIs.
-
- registerPredefinedType(BinaryObjectImpl.class, 200);
- registerPredefinedType(BinaryMetaDataImpl.class, 201);
}
/**
@@ -570,7 +567,7 @@ public class PortableContext implements Externalizable {
mappers.putIfAbsent(typeId, idMapper);
- metaHnd.addMeta(typeId, new BinaryMetaDataImpl(typeName, desc.fieldsMeta(), null));
+ metaHnd.addMeta(typeId, new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null).wrap(this));
return desc;
}
@@ -752,7 +749,7 @@ public class PortableContext implements Externalizable {
typeMappers.put(typeName, idMapper);
- Map<String, String> fieldsMeta = null;
+ Map<String, Integer> fieldsMeta = null;
if (cls != null) {
PortableClassDescriptor desc = new PortableClassDescriptor(
@@ -777,7 +774,22 @@ public class PortableContext implements Externalizable {
descByCls.put(cls, desc);
}
- metaHnd.addMeta(id, new BinaryMetaDataImpl(typeName, fieldsMeta, affKeyFieldName));
+ metaHnd.addMeta(id, new BinaryMetadata(id, typeName, fieldsMeta, affKeyFieldName).wrap(this));
+ }
+
+ /**
+ * Create binary field.
+ *
+ * @param typeId Type ID.
+ * @param fieldName Field name.
+ * @return Binary field.
+ */
+ public BinaryFieldImpl createField(int typeId, String fieldName) {
+ PortableSchemaRegistry schemaReg = schemaRegistry(typeId);
+
+ int fieldId = userTypeIdMapper(typeId).fieldId(typeId, fieldName);
+
+ return new BinaryFieldImpl(typeId, schemaReg, fieldName, fieldId);
}
/**
@@ -816,8 +828,8 @@ public class PortableContext implements Externalizable {
* @param fields Fields map.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
- public void updateMetaData(int typeId, String typeName, Map<String, String> fields) throws BinaryObjectException {
- updateMetaData(typeId, new BinaryMetaDataImpl(typeName, fields, null));
+ public void updateMetaData(int typeId, String typeName, Map<String, Integer> fields) throws BinaryObjectException {
+ updateMetaData(typeId, new BinaryMetadata(typeId, typeName, fields, null));
}
/**
@@ -825,8 +837,8 @@ public class PortableContext implements Externalizable {
* @param meta Meta data.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
- public void updateMetaData(int typeId, BinaryMetaDataImpl meta) throws BinaryObjectException {
- metaHnd.addMeta(typeId, meta);
+ public void updateMetaData(int typeId, BinaryMetadata meta) throws BinaryObjectException {
+ metaHnd.addMeta(typeId, meta.wrap(this));
}
/**
@@ -890,6 +902,7 @@ public class PortableContext implements Externalizable {
* @param clsName Class name.
* @return Type name.
*/
+ @SuppressWarnings("ResultOfMethodCallIgnored")
public static String typeName(String clsName) {
assert clsName != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java
deleted file mode 100644
index 8b2eef2..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataHandler.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryType;
-
-/**
- * Portable meta data handler.
- */
-public interface PortableMetaDataHandler {
- /**
- * Adds meta data.
- *
- * @param typeId Type ID.
- * @param meta Meta data.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- public void addMeta(int typeId, BinaryType meta) throws BinaryObjectException;
-
- /**
- * Gets meta data for provided type ID.
- *
- * @param typeId Type ID.
- * @return Meta data.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- public BinaryType metadata(int typeId) throws BinaryObjectException;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index fe97e7e..31f2bf9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -49,6 +49,7 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLASS;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.COL;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE_ARR;
@@ -69,6 +70,7 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENT
import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.PORTABLE_OBJ;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
@@ -116,6 +118,92 @@ public class PortableUtils {
/** Offset which fits into 4 bytes. */
public static final int OFFSET_4 = 4;
+ /** Field type names. */
+ private static final String[] FIELD_TYPE_NAMES;
+
+ static {
+ FIELD_TYPE_NAMES = new String[104];
+
+ FIELD_TYPE_NAMES[BYTE] = "byte";
+ FIELD_TYPE_NAMES[SHORT] = "short";
+ FIELD_TYPE_NAMES[INT] = "int";
+ FIELD_TYPE_NAMES[LONG] = "long";
+ FIELD_TYPE_NAMES[BOOLEAN] = "boolean";
+ FIELD_TYPE_NAMES[FLOAT] = "float";
+ FIELD_TYPE_NAMES[DOUBLE] = "double";
+ FIELD_TYPE_NAMES[CHAR] = "char";
+ FIELD_TYPE_NAMES[UUID] = "UUID";
+ FIELD_TYPE_NAMES[DECIMAL] = "decimal";
+ FIELD_TYPE_NAMES[STRING] = "String";
+ FIELD_TYPE_NAMES[DATE] = "Date";
+ FIELD_TYPE_NAMES[TIMESTAMP] = "Timestamp";
+ FIELD_TYPE_NAMES[ENUM] = "Enum";
+ FIELD_TYPE_NAMES[OBJ] = "Object";
+ FIELD_TYPE_NAMES[PORTABLE_OBJ] = "Object";
+ FIELD_TYPE_NAMES[COL] = "Collection";
+ FIELD_TYPE_NAMES[MAP] = "Map";
+ FIELD_TYPE_NAMES[MAP_ENTRY] = "Entry";
+ FIELD_TYPE_NAMES[CLASS] = "Class";
+ FIELD_TYPE_NAMES[BYTE_ARR] = "byte[]";
+ FIELD_TYPE_NAMES[SHORT_ARR] = "short[]";
+ FIELD_TYPE_NAMES[INT_ARR] = "int[]";
+ FIELD_TYPE_NAMES[LONG_ARR] = "long[]";
+ FIELD_TYPE_NAMES[BOOLEAN_ARR] = "boolean[]";
+ FIELD_TYPE_NAMES[FLOAT_ARR] = "float[]";
+ FIELD_TYPE_NAMES[DOUBLE_ARR] = "double[]";
+ FIELD_TYPE_NAMES[CHAR_ARR] = "char[]";
+ FIELD_TYPE_NAMES[UUID_ARR] = "UUID[]";
+ FIELD_TYPE_NAMES[DECIMAL_ARR] = "decimal[]";
+ FIELD_TYPE_NAMES[STRING_ARR] = "String[]";
+ FIELD_TYPE_NAMES[DATE_ARR] = "Date[]";
+ FIELD_TYPE_NAMES[TIMESTAMP_ARR] = "Timestamp[]";
+ FIELD_TYPE_NAMES[OBJ_ARR] = "Object[]";
+ FIELD_TYPE_NAMES[ENUM_ARR] = "Enum[]";
+ }
+
+ /**
+ * @param typeName Field type name.
+ * @return Field type ID;
+ */
+ @SuppressWarnings("StringEquality")
+ public static int fieldTypeId(String typeName) {
+ for (int i = 0; i < FIELD_TYPE_NAMES.length; i++) {
+ String typeName0 = FIELD_TYPE_NAMES[i];
+
+ if (typeName.equals(typeName0))
+ return i;
+ }
+
+ throw new IllegalArgumentException("Invalid metadata type name: " + typeName);
+ }
+
+ /**
+ * @param typeId Field type ID.
+ * @return Field type name.
+ */
+ public static String fieldTypeName(int typeId) {
+ assert typeId >= 0 && typeId < FIELD_TYPE_NAMES.length : typeId;
+
+ String typeName = FIELD_TYPE_NAMES[typeId];
+
+ assert typeName != null : typeId;
+
+ return typeName;
+ }
+
+ /**
+ * @param typeIds Field type IDs.
+ * @return Field type names.
+ */
+ public static Map<String, String> fieldTypeNames(Map<String, Integer> typeIds) {
+ Map<String, String> names = U.newHashMap(typeIds.size());
+
+ for (Map.Entry<String, Integer> e : typeIds.entrySet())
+ names.put(e.getKey(), fieldTypeName(e.getValue()));
+
+ return names;
+ }
+
/**
* Write flags.
*
@@ -471,22 +559,6 @@ public class PortableUtils {
}
/**
- * Tells whether provided type is portable or a collection.
- *
- * @param cls Class to check.
- * @return Whether type is portable or a collection.
- */
- public static boolean isPortableOrCollectionType(Class<?> cls) {
- assert cls != null;
-
- return isPortableType(cls) ||
- cls == Object[].class ||
- Collection.class.isAssignableFrom(cls) ||
- Map.class.isAssignableFrom(cls) ||
- Map.Entry.class.isAssignableFrom(cls);
- }
-
- /**
* Tells whether provided type is portable.
*
* @param cls Class to check.
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
index 777d30b..ca8f09b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/BinaryObjectBuilderImpl.java
@@ -17,15 +17,10 @@
package org.apache.ignite.internal.portable.builder;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
+import org.apache.ignite.binary.BinaryInvalidTypeException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryInvalidTypeException;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.internal.portable.BinaryObjectImpl;
import org.apache.ignite.internal.portable.BinaryObjectOffheapImpl;
@@ -33,13 +28,18 @@ import org.apache.ignite.internal.portable.BinaryWriterExImpl;
import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
import org.apache.ignite.internal.portable.PortableUtils;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.util.GridArgumentCheck;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.jetbrains.annotations.Nullable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLAGS_POS;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
@@ -284,7 +284,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
BinaryType metadata = ctx.metaData(typeId);
- Map<String, String> newFldsMetadata = null;
+ Map<String, Integer> newFldsMetadata = null;
for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
Object val = entry.getValue();
@@ -305,15 +305,14 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name);
- String newFldTypeName;
+ int newFldTypeId;
if (val instanceof PortableValueWithType)
- newFldTypeName = ((PortableValueWithType) val).typeName();
- else {
- byte type = PortableUtils.typeByClass(val.getClass());
+ newFldTypeId = ((PortableValueWithType) val).typeId();
+ else
+ newFldTypeId = PortableUtils.typeByClass(val.getClass());
- newFldTypeName = CacheObjectBinaryProcessorImpl.fieldTypeName(type);
- }
+ String newFldTypeName = PortableUtils.fieldTypeName(newFldTypeId);
if (oldFldTypeName == null) {
// It's a new field, we have to add it to metadata.
@@ -321,11 +320,10 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
if (newFldsMetadata == null)
newFldsMetadata = new HashMap<>();
- newFldsMetadata.put(name, newFldTypeName);
+ newFldsMetadata.put(name, PortableUtils.fieldTypeId(newFldTypeName));
}
else {
- String objTypeName =
- CacheObjectBinaryProcessorImpl.FIELD_TYPE_NAMES[GridPortableMarshaller.OBJ];
+ String objTypeName = PortableUtils.fieldTypeName(GridPortableMarshaller.OBJ);
if (!objTypeName.equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
throw new BinaryObjectException(
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
index 5ea8e62..5d66328 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableValueWithType.java
@@ -18,7 +18,6 @@
package org.apache.ignite.internal.portable.builder;
import org.apache.ignite.internal.portable.BinaryWriterExImpl;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.util.typedef.internal.S;
/**
@@ -48,9 +47,11 @@ class PortableValueWithType implements PortableLazyValue {
ctx.writeValue(writer, val);
}
- /** {@inheritDoc} */
- public String typeName() {
- return CacheObjectBinaryProcessorImpl.fieldTypeName(type);
+ /**
+ * @return Type ID.
+ */
+ public int typeId() {
+ return type;
}
/** {@inheritDoc} */
[35/55] [abbrv] ignite git commit: Merged ignite-1945 into ignite-1282
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
index 8f79db1..dd08390 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
@@ -20,11 +20,12 @@ package org.apache.ignite.internal.portable;
import org.apache.ignite.binary.BinaryField;
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.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.math.BigDecimal;
@@ -38,7 +39,7 @@ import java.util.UUID;
*/
public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTest {
/** Marshaller. */
- protected PortableMarshaller dfltMarsh;
+ protected BinaryMarshaller dfltMarsh;
/**
* Create marshaller.
@@ -46,22 +47,28 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Portable marshaller.
* @throws Exception If failed.
*/
- protected PortableMarshaller createMarshaller() throws Exception {
+ protected BinaryMarshaller createMarshaller() throws Exception {
PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
- marsh.setCompactFooter(compactFooter());
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setCompactFooter(compactFooter());
- marsh.setTypeConfigurations(Arrays.asList(
+ bCfg.setTypeConfigurations(Arrays.asList(
new BinaryTypeConfiguration(TestObject.class.getName()),
new BinaryTypeConfiguration(TestOuterObject.class.getName()),
new BinaryTypeConfiguration(TestInnerObject.class.getName())
));
+ IgniteConfiguration iCfg = new IgniteConfiguration();
+
+ iCfg.setBinaryConfiguration(bCfg);
+
marsh.setContext(new MarshallerContextTestImpl(null));
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
return marsh;
}
@@ -79,7 +86,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @param marsh Marshaller.
* @return Portable context.
*/
- protected static PortableContext portableContext(PortableMarshaller marsh) {
+ protected static PortableContext portableContext(BinaryMarshaller marsh) {
GridPortableMarshaller impl = U.field(marsh, "impl");
return impl.context();
@@ -384,7 +391,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @param exists Whether field should exist.
* @throws Exception If failed.
*/
- private void checkNormal(PortableMarshaller marsh, String fieldName, boolean exists) throws Exception {
+ private void checkNormal(BinaryMarshaller marsh, String fieldName, boolean exists) throws Exception {
TestContext testCtx = context(marsh, fieldName);
check0(fieldName, testCtx, exists);
@@ -398,7 +405,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @param exists Whether field should exist.
* @throws Exception If failed.
*/
- private void checkNested(PortableMarshaller marsh, String fieldName, boolean exists) throws Exception {
+ private void checkNested(BinaryMarshaller marsh, String fieldName, boolean exists) throws Exception {
TestContext testCtx = nestedContext(marsh, fieldName);
check0(fieldName, testCtx, exists);
@@ -477,7 +484,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Test context.
* @throws Exception If failed.
*/
- private TestContext context(PortableMarshaller marsh, String fieldName) throws Exception {
+ private TestContext context(BinaryMarshaller marsh, String fieldName) throws Exception {
TestObject obj = createObject();
BinaryObjectEx portObj = toPortable(marsh, obj);
@@ -495,7 +502,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Test context.
* @throws Exception If failed.
*/
- private TestContext nestedContext(PortableMarshaller marsh, String fieldName)
+ private TestContext nestedContext(BinaryMarshaller marsh, String fieldName)
throws Exception {
TestObject obj = createObject();
TestOuterObject outObj = new TestOuterObject(obj);
@@ -527,7 +534,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @return Portable object.
* @throws Exception If failed.
*/
- protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
+ protected abstract BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception;
/**
* Outer test object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
index 0140c53..53ba212 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsHeapSelfTest.java
@@ -17,14 +17,14 @@
package org.apache.ignite.internal.portable;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
* Field tests for heap-based portables.
*/
public class BinaryFieldsHeapSelfTest extends BinaryFieldsAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] bytes = marsh.marshal(obj);
return new BinaryObjectImpl(portableContext(marsh), bytes, 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
index 1bd0f72..68bfb30 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsOffheapSelfTest.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.portable;
import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.eclipse.jetty.util.ConcurrentHashSet;
import sun.misc.Unsafe;
@@ -47,7 +47,7 @@ public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
}
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] arr = marsh.marshal(obj);
long ptr = UNSAFE.allocateMemory(arr.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
index 3ec0b83..7267b16 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsAbstractSelfTest.java
@@ -17,16 +17,16 @@
package org.apache.ignite.internal.portable;
+import java.util.Arrays;
import org.apache.ignite.binary.BinaryField;
import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import java.util.Arrays;
-
/**
* Contains tests for compact offsets.
*/
@@ -38,7 +38,7 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
private static int POW_16 = 1 << 16;
/** Marshaller. */
- protected PortableMarshaller marsh;
+ protected BinaryMarshaller marsh;
/** Portable context. */
protected PortableContext ctx;
@@ -49,14 +49,21 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
- marsh = new PortableMarshaller();
+ marsh = new BinaryMarshaller();
+
+ IgniteConfiguration iCfg = new IgniteConfiguration();
- marsh.setCompactFooter(compactFooter());
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
+
+ bCfg.setCompactFooter(compactFooter());
+
+ iCfg.setBinaryConfiguration(bCfg);
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
marsh.setContext(new MarshallerContextTestImpl(null));
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
}
/**
@@ -65,7 +72,7 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
protected boolean compactFooter() {
return true;
}
-
+
/**
* Test 1 byte.
*
@@ -163,7 +170,7 @@ public abstract class BinaryFooterOffsetsAbstractSelfTest extends GridCommonAbst
* @return Portable object.
* @throws Exception If failed.
*/
- protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
+ protected abstract BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception;
/**
* Test object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
index b23f012..471bd44 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsHeapSelfTest.java
@@ -17,14 +17,14 @@
package org.apache.ignite.internal.portable;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
* Compact offsets tests for heap portable objects.
*/
public class BinaryFooterOffsetsHeapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] bytes = marsh.marshal(obj);
return new BinaryObjectImpl(ctx, bytes, 0);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
index e52ebe7..7b44b80 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFooterOffsetsOffheapSelfTest.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.portable;
import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.eclipse.jetty.util.ConcurrentHashSet;
import sun.misc.Unsafe;
@@ -47,7 +47,7 @@ public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstr
}
/** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
+ @Override protected BinaryObjectEx toPortable(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] arr = marsh.marshal(obj);
long ptr = UNSAFE.allocateMemory(arr.length);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
index dfc8109..4584575 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -30,8 +30,10 @@ import org.apache.ignite.binary.BinarySerializer;
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.portable.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.GridMapEntry;
@@ -39,7 +41,7 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jsr166.ConcurrentHashMap8;
@@ -384,9 +386,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testBinaryObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
@@ -413,9 +413,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testEnum() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(Arrays.asList(TestEnum.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(TestEnum.class.getName())));
assertEquals(TestEnum.B, marshalUnmarshal(TestEnum.B, marsh));
}
@@ -426,9 +424,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
public void testDateAndTimestampInSingleObject() throws Exception {
BinaryTypeConfiguration cfg1 = new BinaryTypeConfiguration(DateClass1.class.getName());
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(cfg1));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(cfg1));
Date date = new Date();
Timestamp ts = new Timestamp(System.currentTimeMillis());
@@ -453,9 +449,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testSimpleObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -540,9 +534,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortable() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName()),
new BinaryTypeConfiguration(TestBinary.class.getName())
));
@@ -704,9 +696,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassWithoutPublicConstructor() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
@@ -732,14 +722,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomSerializer() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration type =
new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
type.setSerializer(new CustomSerializer1());
- marsh.setTypeConfigurations(Arrays.asList(type));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(type));
CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
@@ -752,10 +740,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomSerializerWithGlobal() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setSerializer(new CustomSerializer1());
-
BinaryTypeConfiguration type1 =
new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
BinaryTypeConfiguration type2 =
@@ -763,7 +747,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
type2.setSerializer(new CustomSerializer2());
- marsh.setTypeConfigurations(Arrays.asList(type1, type2));
+ BinaryMarshaller marsh = binaryMarshaller(new CustomSerializer1(), Arrays.asList(type1, type2));
CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
@@ -782,8 +766,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomIdMapper() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration type =
new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
@@ -806,7 +788,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(type));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(type));
CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str");
@@ -824,18 +806,21 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCustomIdMapperWithGlobal() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryTypeConfiguration type1 =
+ new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
+ BinaryTypeConfiguration type2 =
+ new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
- marsh.setIdMapper(new BinaryIdMapper() {
+ type2.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
- return 11111;
+ return 44444;
}
@Override public int fieldId(int typeId, String fieldName) {
- assert typeId == 11111;
+ assert typeId == 44444;
- if ("val1".equals(fieldName)) return 22222;
- else if ("val2".equals(fieldName)) return 33333;
+ if ("val1".equals(fieldName)) return 55555;
+ else if ("val2".equals(fieldName)) return 66666;
assert false : "Unknown field: " + fieldName;
@@ -843,29 +828,24 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- BinaryTypeConfiguration type1 =
- new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
- BinaryTypeConfiguration type2 =
- new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
-
- type2.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
- return 44444;
+ return 11111;
}
@Override public int fieldId(int typeId, String fieldName) {
- assert typeId == 44444;
+ assert typeId == 11111;
- if ("val1".equals(fieldName)) return 55555;
- else if ("val2".equals(fieldName)) return 66666;
+ if ("val1".equals(fieldName))
+ return 22222;
+ else if ("val2".equals(fieldName))
+ return 33333;
assert false : "Unknown field: " + fieldName;
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(type1, type2));
+ }, Arrays.asList(type1, type2));
CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str1");
@@ -894,14 +874,10 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDynamicObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(DynamicObject.class.getName())
));
- initializePortableContext(marsh);
-
BinaryObject po1 = marshal(new DynamicObject(0, 10, 20, 30), marsh);
assertEquals(new Integer(10), po1.field("val1"));
@@ -943,9 +919,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCycleLink() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(CycleLinkObject.class.getName())
));
@@ -964,9 +938,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDetached() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(DetachedTestObject.class.getName()),
new BinaryTypeConfiguration(DetachedInnerTestObject.class.getName())
));
@@ -1020,9 +992,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCollectionFields() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(CollectionFieldsObject.class.getName()),
new BinaryTypeConfiguration(Key.class.getName()),
new BinaryTypeConfiguration(Value.class.getName())
@@ -1061,10 +1031,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- // TODO: Only with full headers.
public void _testDefaultMapping() throws Exception {
- PortableMarshaller marsh1 = createMarshaller();
-
BinaryTypeConfiguration customMappingType =
new BinaryTypeConfiguration(TestBinary.class.getName());
@@ -1091,7 +1058,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh1.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh1 = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName()),
customMappingType
));
@@ -1100,16 +1067,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryObjectImpl po = marshal(obj, marsh1);
- PortableMarshaller marsh2 = createMarshaller();
-
- marsh2.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh2 = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName()),
new BinaryTypeConfiguration(TestBinary.class.getName())
));
- PortableContext ctx = initializePortableContext(marsh2);
-
- po.context(ctx);
+ po = marshal(obj, marsh2);
assertEquals(obj, po.deserialize());
}
@@ -1118,8 +1081,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeNames() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
customType1.setIdMapper(new BinaryIdMapper() {
@@ -1168,7 +1129,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(Key.class.getName()),
new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
new BinaryTypeConfiguration("NonExistentClass4"),
@@ -1178,7 +1139,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
customType4
));
- PortableContext ctx = initializePortableContext(marsh);
+ PortableContext ctx = portableContext(marsh);
assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
assertEquals("key".hashCode(), ctx.typeId("Key"));
@@ -1194,8 +1155,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testFieldIdMapping() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
customType1.setIdMapper(new BinaryIdMapper() {
@@ -1238,12 +1197,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(Key.class.getName()),
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(Key.class.getName()),
new BinaryTypeConfiguration("NonExistentClass2"),
customType1,
customType2));
- PortableContext ctx = initializePortableContext(marsh);
+ PortableContext ctx = portableContext(marsh);
assertEquals("val".hashCode(), ctx.fieldId("key".hashCode(), "val"));
assertEquals("val".hashCode(), ctx.fieldId("nonexistentclass2".hashCode(), "val"));
@@ -1260,8 +1219,6 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDuplicateTypeId() throws Exception {
- final PortableMarshaller marsh = createMarshaller();
-
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration("org.gridgain.Class1");
customType1.setIdMapper(new BinaryIdMapper() {
@@ -1286,13 +1243,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(customType1, customType2));
-
try {
- initializePortableContext(marsh);
+ binaryMarshaller(Arrays.asList(customType1, customType2));
}
catch (IgniteCheckedException e) {
- assertEquals("Duplicate type ID [clsName=org.gridgain.Class1, id=100]",
+ assertEquals("Duplicate type ID [clsName=org.gridgain.Class2, id=100]",
e.getCause().getCause().getMessage());
return;
@@ -1305,14 +1260,10 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopy() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
- initializePortableContext(marsh);
-
SimpleObject obj = simpleObject();
final BinaryObject po = marshal(obj, marsh);
@@ -1432,9 +1383,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyString() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1455,9 +1404,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyUuid() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1480,9 +1427,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyByteArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1519,9 +1464,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyShortArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1542,9 +1485,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyIntArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1565,9 +1506,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyLongArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1588,9 +1527,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyFloatArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1611,9 +1548,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyDoubleArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1634,9 +1569,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyCharArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1657,9 +1590,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyStringArray() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1680,9 +1611,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyObject() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1709,9 +1638,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyNonPrimitives() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(SimpleObject.class.getName())
));
@@ -1748,9 +1675,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPortableCopyMixed() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
SimpleObject obj = simpleObject();
@@ -1794,82 +1719,26 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testKeepDeserialized() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
- marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
- marsh.setKeepDeserialized(true);
+ BinaryObjectImpl po = marshal(simpleObject(), marsh);
- BinaryObject po = marshal(simpleObject(), marsh);
+ CacheObjectContext coCtx = new CacheObjectContext(newContext(), null, false, true, false);
- assert po.deserialize() == po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
- marsh.setKeepDeserialized(false);
+ assert po.value(coCtx, false) == po.value(coCtx, false);
po = marshal(simpleObject(), marsh);
assert po.deserialize() != po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(true);
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() == po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(false);
- marsh.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(SimpleObject.class.getName())));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() != po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(true);
-
- BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
-
- typeCfg.setKeepDeserialized(false);
-
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() != po.deserialize();
-
- marsh = createMarshaller();
-
- marsh.setKeepDeserialized(false);
-
- typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
-
- typeCfg.setKeepDeserialized(true);
-
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
-
- po = marshal(simpleObject(), marsh);
-
- assert po.deserialize() == po.deserialize();
}
/**
* @throws Exception If failed.
*/
public void testOffheapPortable() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
- PortableContext ctx = initializePortableContext(marsh);
+ PortableContext ctx = portableContext(marsh);
SimpleObject simpleObj = simpleObject();
@@ -1961,10 +1830,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*
*/
public void testReadResolve() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(
- Arrays.asList(MySingleton.class.getName(), SingletonMarker.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration(MySingleton.class.getName()),
+ new BinaryTypeConfiguration(SingletonMarker.class.getName())));
BinaryObjectImpl portableObj = marshal(MySingleton.INSTANCE, marsh);
@@ -1979,9 +1847,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*
*/
public void testReadResolveOnPortableAware() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(Collections.singletonList(MyTestClass.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Collections.singletonList(
+ new BinaryTypeConfiguration(MyTestClass.class.getName())));
BinaryObjectImpl portableObj = marshal(new MyTestClass(), marsh);
@@ -1994,9 +1861,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If ecxeption thrown.
*/
public void testDeclareReadResolveInParent() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- marsh.setClassNames(Arrays.asList(ChildPortable.class.getName()));
+ BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(new BinaryTypeConfiguration(ChildPortable.class.getName())));
BinaryObjectImpl portableObj = marshal(new ChildPortable(), marsh);
@@ -2009,14 +1874,12 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*
*/
public void testDecimalFields() throws Exception {
- PortableMarshaller marsh = createMarshaller();
-
- Collection<String> clsNames = new ArrayList<>();
+ Collection<BinaryTypeConfiguration> clsNames = new ArrayList<>();
- clsNames.add(DecimalReflective.class.getName());
- clsNames.add(DecimalMarshalAware.class.getName());
+ clsNames.add(new BinaryTypeConfiguration(DecimalReflective.class.getName()));
+ clsNames.add(new BinaryTypeConfiguration(DecimalMarshalAware.class.getName()));
- marsh.setClassNames(clsNames);
+ BinaryMarshaller marsh = binaryMarshaller(clsNames);
// 1. Test reflective stuff.
DecimalReflective obj1 = new DecimalReflective();
@@ -2054,8 +1917,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws IgniteCheckedException If failed.
*/
- public void testFinalField() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ public void testFinalField() throws IgniteCheckedException {
+ BinaryMarshaller marsh = binaryMarshaller();
SimpleObjectWithFinal obj = new SimpleObjectWithFinal();
@@ -2071,9 +1934,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
// Checking the writer directly.
assertEquals(false, INSTANCE.isAcquired());
- PortableMarshaller marsh0 = createMarshaller();
-
- try (BinaryWriterExImpl writer = new BinaryWriterExImpl(portableContext(marsh0))) {
+ BinaryMarshaller marsh = binaryMarshaller();
+
+ try (BinaryWriterExImpl writer = new BinaryWriterExImpl(portableContext(marsh))) {
assertEquals(true, INSTANCE.isAcquired());
writer.writeString("Thread local test");
@@ -2086,16 +1949,16 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
// Checking the portable marshaller.
assertEquals(false, INSTANCE.isAcquired());
- PortableMarshaller marsh = createMarshaller();
+ marsh = binaryMarshaller();
marsh.marshal(new SimpleObject());
assertEquals(false, INSTANCE.isAcquired());
- // Checking the builder.
- PortableMarshaller marsh2 = createMarshaller();
+ marsh = binaryMarshaller();
- BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(portableContext(marsh2),
+ // Checking the builder.
+ BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(portableContext(marsh),
"org.gridgain.foo.bar.TestClass");
builder.setField("a", "1");
@@ -2109,7 +1972,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testDuplicateName() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
Test1.Job job1 = new Test1().new Job();
Test2.Job job2 = new Test2().new Job();
@@ -2132,7 +1995,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClass() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
Class cls = BinaryMarshallerSelfTest.class;
@@ -2145,7 +2008,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassFieldsMarshalling() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
ObjectWithClassFields obj = new ObjectWithClassFields();
obj.cls1 = BinaryMarshallerSelfTest.class;
@@ -2168,7 +2031,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testMarshallingThroughJdk() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
InetSocketAddress addr = new InetSocketAddress("192.168.0.2", 4545);
@@ -2204,9 +2067,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testPredefinedTypeIds() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
- PortableContext pCtx = initializePortableContext(marsh);
+ PortableContext pCtx = portableContext(marsh);
Field field = pCtx.getClass().getDeclaredField("predefinedTypeNames");
@@ -2233,7 +2096,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testCyclicReferencesMarshalling() throws Exception {
- PortableMarshaller marsh = createMarshaller();
+ BinaryMarshaller marsh = binaryMarshaller();
SimpleObject obj = simpleObject();
@@ -2355,8 +2218,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @param obj Original object.
* @return Result object.
*/
- private <T> T marshalUnmarshal(T obj) throws Exception {
- return marshalUnmarshal(obj, createMarshaller());
+ private <T> T marshalUnmarshal(T obj) throws IgniteCheckedException {
+ return marshalUnmarshal(obj, binaryMarshaller());
}
/**
@@ -2364,9 +2227,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @param marsh Marshaller.
* @return Result object.
*/
- private <T> T marshalUnmarshal(Object obj, PortableMarshaller marsh) throws IgniteCheckedException {
- initializePortableContext(marsh);
-
+ private <T> T marshalUnmarshal(Object obj, BinaryMarshaller marsh) throws IgniteCheckedException {
byte[] bytes = marsh.marshal(obj);
return marsh.unmarshal(bytes, null);
@@ -2377,9 +2238,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @param marsh Marshaller.
* @return Portable object.
*/
- private <T> BinaryObjectImpl marshal(T obj, PortableMarshaller marsh) throws IgniteCheckedException {
- initializePortableContext(marsh);
-
+ private <T> BinaryObjectImpl marshal(T obj, BinaryMarshaller marsh) throws IgniteCheckedException {
byte[] bytes = marsh.marshal(obj);
return new BinaryObjectImpl(U.<GridPortableMarshaller>field(marsh, "impl").context(),
@@ -2387,54 +2246,83 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
/**
- * Create portable marshaller.
- *
- * @return Portable marshaller.
- * @throws Exception If failed.
+ * @return Whether to use compact footers or not.
*/
- private PortableMarshaller createMarshaller() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setCompactFooter(compactFooter());
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
+ * @param marsh Marshaller.
+ * @return Portable context.
+ */
+ protected PortableContext portableContext(BinaryMarshaller marsh) {
+ GridPortableMarshaller impl = U.field(marsh, "impl");
- initializePortableContext(marsh);
+ return impl.context();
+ }
- return marsh;
+ /**
+ *
+ */
+ protected BinaryMarshaller binaryMarshaller()
+ throws IgniteCheckedException {
+ return binaryMarshaller(null, null, null);
}
/**
- * @return Whether to use compact footers or not.
+ *
*/
- protected boolean compactFooter() {
- return true;
+ protected BinaryMarshaller binaryMarshaller(Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return binaryMarshaller(null, null, cfgs);
}
/**
- * Get portable context of the given marshaller.
*
- * @param marsh Marshaller.
- * @return Context.
- * @throws Exception If failed.
*/
- private PortableContext portableContext(PortableMarshaller marsh) throws Exception {
- GridPortableMarshaller marsh0 = IgniteUtils.field(marsh, "impl");
+ protected BinaryMarshaller binaryMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return binaryMarshaller(mapper, null, cfgs);
+ }
- return marsh0.context();
+ /**
+ *
+ */
+ protected BinaryMarshaller binaryMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return binaryMarshaller(null, serializer, cfgs);
}
/**
- * @return Portable context.
+ * @return Binary marshaller.
*/
- private PortableContext initializePortableContext(PortableMarshaller marsh) throws IgniteCheckedException {
+ protected BinaryMarshaller binaryMarshaller(
+ BinaryIdMapper mapper,
+ BinarySerializer serializer,
+ Collection<BinaryTypeConfiguration> cfgs
+ ) throws IgniteCheckedException {
IgniteConfiguration iCfg = new IgniteConfiguration();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setIdMapper(mapper);
+ bCfg.setSerializer(serializer);
+ bCfg.setCompactFooter(compactFooter());
+
+ bCfg.setTypeConfigurations(cfgs);
+
+ iCfg.setBinaryConfiguration(bCfg);
+
PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), iCfg);
+ BinaryMarshaller marsh = new BinaryMarshaller();
+
marsh.setContext(new MarshallerContextTestImpl(null));
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
- return ctx;
+ return marsh;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
index 0e31451..356a25b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
@@ -37,6 +37,7 @@ import java.util.Set;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
@@ -45,7 +46,7 @@ import org.apache.ignite.internal.portable.mutabletest.GridBinaryMarshalerAwareT
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.portable.IgniteBinaryImpl;
import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.binary.BinaryObject;
@@ -78,13 +79,13 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
cfg.setCacheConfiguration(cacheCfg);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setCompactFooter(compactFooter());
+ bCfg.setCompactFooter(compactFooter());
+
+ bCfg.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
- marsh.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
-
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
index 2dfa6d0..7f023f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
@@ -22,13 +22,18 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
@@ -39,12 +44,7 @@ import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.T
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import sun.misc.Unsafe;
@@ -63,17 +63,10 @@ public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setCompactFooter(compactFooter());
+ BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration();
- marsh.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName(),
- "org.gridgain.grid.internal.util.portable.mutabletest.*"));
-
- BinaryTypeConfiguration customIdMapper = new BinaryTypeConfiguration();
-
- customIdMapper.setClassName(CustomIdMapper.class.getName());
- customIdMapper.setIdMapper(new BinaryIdMapper() {
+ customTypeCfg.setTypeName(CustomIdMapper.class.getName());
+ customTypeCfg.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
return ~BinaryInternalIdMapper.defaultInstance().typeId(clsName);
}
@@ -83,9 +76,19 @@ public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Collections.singleton(customIdMapper));
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setCompactFooter(compactFooter());
+
+ bCfg.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration(Value.class.getName()),
+ new BinaryTypeConfiguration("org.gridgain.grid.internal.util.portable.mutabletest.*"),
+ customTypeCfg));
+
+ cfg.setBinaryConfiguration(bCfg);
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
index 748c423..9fb3a6f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableAffinityKeySelfTest.java
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.cache.CacheKeyConfiguration;
import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteKernal;
@@ -32,7 +33,7 @@ import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -61,17 +62,19 @@ public class GridPortableAffinityKeySelfTest extends GridCommonAbstractTest {
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
- typeCfg.setClassName(TestObject.class.getName());
+ typeCfg.setTypeName(TestObject.class.getName());
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setTypeConfigurations(Collections.singleton(typeCfg));
+ bCfg.setTypeConfigurations(Collections.singleton(typeCfg));
+
+ cfg.setBinaryConfiguration(bCfg);
CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(TestObject.class.getName(), "affKey");
cfg.setCacheKeyCfg(keyCfg);
- cfg.setMarshaller(marsh);
+ cfg.setMarshaller(new BinaryMarshaller());
if (!gridName.equals(getTestGridName(GRID_CNT))) {
CacheConfiguration cacheCfg = new CacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
index 9c0824e..917298a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
@@ -25,7 +25,7 @@ import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.MarshallerContextAdapter;
import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.io.Externalizable;
@@ -42,12 +42,14 @@ public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstrac
* @throws Exception If failed.
*/
public void testObjectExchange() throws Exception {
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryMarshaller marsh = new BinaryMarshaller();
marsh.setContext(new MarshallerContextWithNoStorage());
- PortableContext context = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
+ IgniteConfiguration cfg = new IgniteConfiguration();
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", context);
+ PortableContext context = new PortableContext(BinaryCachingMetadataHandler.create(), cfg);
+
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", context, cfg);
SimpleObject simpleObj = new SimpleObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
index 2a367a8..5c25d3b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -23,9 +23,10 @@ import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.binary.BinaryType;
@@ -46,11 +47,13 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
- PortableMarshaller marsh = new PortableMarshaller();
+ BinaryConfiguration bCfg = new BinaryConfiguration();
- marsh.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
+ bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
- cfg.setMarshaller(marsh);
+ cfg.setBinaryConfiguration(bCfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
CacheConfiguration ccfg = new CacheConfiguration();
@@ -148,8 +151,6 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testNoConfiguration() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1377");
-
portables().toBinary(new TestObject3());
assertNotNull(portables().metadata(TestObject3.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
index 52af867..a00ad75 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
@@ -17,12 +17,17 @@
package org.apache.ignite.internal.portable;
+import java.util.Collection;
+import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.util.Arrays;
@@ -33,36 +38,15 @@ import java.util.Map;
*/
public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
/**
- * @return Portable context.
- */
- private PortableContext portableContext() {
- return new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
- }
-
- /**
- * @return Portable marshaller.
- */
- private PortableMarshaller portableMarshaller() {
- PortableMarshaller marsh = new PortableMarshaller();
- marsh.setContext(new MarshallerContextTestImpl(null));
-
- return marsh;
- }
-
- /**
* @throws Exception If failed.
*/
public void testClassNames() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.internal.portable.test.*",
- "unknown.*"
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -77,11 +61,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassNamesWithMapper() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -97,14 +77,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.internal.portable.test.*",
- "unknown.*"
+ }, Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -119,16 +97,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurations() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -143,11 +117,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithGlobalMapper() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -163,14 +133,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -185,11 +153,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithNonGlobalMapper() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -205,14 +169,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -227,17 +189,9 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testOverride() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.internal.portable.test.*"
- ));
-
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
- typeCfg.setClassName("org.apache.ignite.internal.portable.test.GridPortableTestClass2");
+ typeCfg.setTypeName("org.apache.ignite.internal.portable.test.GridPortableTestClass2");
typeCfg.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
return 100;
@@ -248,9 +202,11 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.internal.portable.test.*"),
+ typeCfg));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -269,16 +225,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassNamesJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.portable.testjar.*",
- "unknown.*"
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -292,11 +244,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClassNamesWithMapperJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -310,14 +258,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.portable.testjar.*",
- "unknown.*"
+ }, Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -331,16 +277,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -354,11 +296,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithGlobalMapperJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -372,14 +310,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -393,11 +329,7 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setIdMapper(new BinaryIdMapper() {
+ BinaryMarshaller marsh = portableMarshaller(new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -411,14 +343,12 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
@Override public int fieldId(int typeId, String fieldName) {
return 0;
}
- });
-
- marsh.setTypeConfigurations(Arrays.asList(
+ }, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
new BinaryTypeConfiguration("unknown.*")
));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
@@ -432,14 +362,6 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testOverrideJar() throws Exception {
- PortableContext ctx = portableContext();
-
- PortableMarshaller marsh = portableMarshaller();
-
- marsh.setClassNames(Arrays.asList(
- "org.apache.ignite.portable.testjar.*"
- ));
-
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(
"org.apache.ignite.portable.testjar.GridPortableTestClass2");
@@ -453,9 +375,11 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
}
});
- marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+ BinaryMarshaller marsh = portableMarshaller(Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.portable.testjar.*"),
+ typeCfg));
- ctx.configure(marsh);
+ PortableContext ctx = portableContext(marsh);
Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
@@ -469,4 +393,73 @@ public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(100, typeMappers.get("GridPortableTestClass2").typeId("GridPortableTestClass2"));
}
+
+ /**
+ * @param marsh Marshaller.
+ * @return Portable context.
+ */
+ protected PortableContext portableContext(BinaryMarshaller marsh) {
+ GridPortableMarshaller impl = U.field(marsh, "impl");
+
+ return impl.context();
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller()
+ throws IgniteCheckedException {
+ return portableMarshaller(null, null, null);
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller(Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return portableMarshaller(null, null, cfgs);
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return portableMarshaller(mapper, null, cfgs);
+ }
+
+ /**
+ *
+ */
+ protected BinaryMarshaller portableMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
+ throws IgniteCheckedException {
+ return portableMarshaller(null, serializer, cfgs);
+ }
+
+ protected BinaryMarshaller portableMarshaller(
+ BinaryIdMapper mapper,
+ BinarySerializer serializer,
+ Collection<BinaryTypeConfiguration> cfgs
+ ) throws IgniteCheckedException {
+ IgniteConfiguration iCfg = new IgniteConfiguration();
+
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setIdMapper(mapper);
+ bCfg.setSerializer(serializer);
+
+ bCfg.setTypeConfigurations(cfgs);
+
+ iCfg.setBinaryConfiguration(bCfg);
+
+ PortableContext ctx = new PortableContext(BinaryNoopMetadataHandler.instance(), iCfg);
+
+ BinaryMarshaller marsh = new BinaryMarshaller();
+
+ marsh.setContext(new MarshallerContextTestImpl(null));
+
+ IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setPortableContext", ctx, iCfg);
+
+ return marsh;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
index 9e7619f..6c11938 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
@@ -17,11 +17,7 @@
package org.apache.ignite.internal.portable.noncompact;
-import org.apache.ignite.internal.portable.BinaryFieldsAbstractSelfTest;
import org.apache.ignite.internal.portable.BinaryFieldsHeapSelfTest;
-import org.apache.ignite.internal.portable.BinaryObjectEx;
-import org.apache.ignite.internal.portable.BinaryObjectImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
/**
* Field tests for heap-based portables with non-compact footer.
http://git-wip-us.apache.org/repos/asf/ignite/blob/c505f48a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
index 80c339c..c855c9d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java
@@ -24,7 +24,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractTest;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.marshaller.portable.BinaryMarshaller;
import org.apache.ignite.testframework.GridTestExternalClassLoader;
import org.apache.ignite.testframework.config.GridTestProperties;
@@ -65,7 +65,7 @@ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCach
* @throws Exception If failed.
*/
public void testUsersClassLoader() throws Exception {
- if (F.eq(GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME), PortableMarshaller.class.getName()))
+ if (F.eq(GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME), BinaryMarshaller.class.getName()))
fail("https://issues.apache.org/jira/browse/IGNITE-1272");
UsersClassLoader testClassLdr = (UsersClassLoader)grid(0).configuration().getClassLoader();
[27/55] [abbrv] ignite git commit: IGNITE-1917: Binary protocol
performance optimizations.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 6ff3047..6ba5981 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -24,9 +24,7 @@ import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
import org.apache.ignite.internal.portable.streams.PortableInputStream;
-import org.apache.ignite.internal.util.GridEnumCache;
import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -117,169 +115,166 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_AR
*/
@SuppressWarnings("unchecked")
public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, ObjectInput {
- /** */
+ /** Portable context. */
private final PortableContext ctx;
- /** */
+ /** Input stream. */
private final PortableInputStream in;
- /** */
- private final int start;
-
- /** */
- private final PortableReaderContext rCtx;
-
- /** */
+ /** Class loaded. */
private final ClassLoader ldr;
- /** */
- private PortableClassDescriptor desc;
+ /** Reader context which is constantly passed between objects. */
+ private final BinaryReaderHandles rCtx;
- /** Flag indicating that object header was parsed. */
- private boolean hdrParsed;
+ /** */
+ private final int start;
/** Type ID. */
- private int typeId;
+ private final int typeId;
/** Raw offset. */
- private int rawOff;
+ private final int rawOff;
/** */
- private int hdrLen;
+ private final int hdrLen;
/** Footer start. */
- private int footerStart;
+ private final int footerStart;
/** Footer end. */
- private int footerLen;
+ private final int footerLen;
/** ID mapper. */
- private BinaryIdMapper idMapper;
+ private final BinaryIdMapper idMapper;
/** Schema Id. */
- private int schemaId;
+ private final int schemaId;
/** Whether this is user type or not. */
- private boolean userType;
+ private final boolean userType;
/** Whether field IDs exist. */
- private int fieldIdLen;
+ private final int fieldIdLen;
/** Offset size in bytes. */
- private int fieldOffsetLen;
+ private final int fieldOffsetLen;
/** Object schema. */
- private PortableSchema schema;
+ private final PortableSchema schema;
- /**
- * @param ctx Context.
- * @param arr Array.
- * @param start Start.
- * @param ldr Class loader.
- */
- public BinaryReaderExImpl(PortableContext ctx, byte[] arr, int start, ClassLoader ldr) {
- this(ctx, new PortableHeapInputStream(arr), start, ldr, new PortableReaderContext());
- }
+ /** Whether passed IDs matches schema order. Reset to false as soon as a single mismatch detected. */
+ private boolean matching = true;
- /**
- * @param ctx Context.
- * @param in Input stream.
- * @param start Start.
- */
- BinaryReaderExImpl(PortableContext ctx, PortableInputStream in, int start, ClassLoader ldr) {
- this(ctx, in, start, ldr, new PortableReaderContext());
- }
+ /** Order of a field whose match is expected. */
+ private int matchingOrder;
/**
+ * Constructor.
+ *
* @param ctx Context.
* @param in Input stream.
- * @param start Start.
+ * @param ldr Class loader.
* @param rCtx Context.
*/
- BinaryReaderExImpl(PortableContext ctx, PortableInputStream in, int start, ClassLoader ldr,
- PortableReaderContext rCtx) {
+ public BinaryReaderExImpl(PortableContext ctx, PortableInputStream in, ClassLoader ldr, BinaryReaderHandles rCtx) {
+ // Initialize base members.
this.ctx = ctx;
this.in = in;
- this.start = start;
this.ldr = ldr;
this.rCtx = rCtx;
- in.position(start);
- }
+ start = in.position();
- /**
- * Preloads typeId from the input array.
- */
- private void parseHeaderIfNeeded() {
- if (hdrParsed)
- return;
+ // Parse header if possible.
+ byte hdr = in.readBytePositioned(start);
- int retPos = in.position();
+ if (hdr == GridPortableMarshaller.OBJ) {
+ // Skip header.
+ in.readByte();
- in.position(start);
+ // Ensure protocol is fine.
+ PortableUtils.checkProtocolVersion(in.readByte());
- byte hdr = in.readByte();
+ // Read and parse flags.
+ short flags = in.readShort();
- if (hdr != GridPortableMarshaller.OBJ)
- throw new BinaryObjectException("Invalid header [pos=" + retPos + "expected=" + GridPortableMarshaller.OBJ +
- ", actual=" + hdr + ']');
+ userType = PortableUtils.isUserType(flags);
- PortableUtils.checkProtocolVersion(in.readByte());
+ fieldIdLen = PortableUtils.fieldIdLength(flags);
+ fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
- short flags = in.readShort();
+ int typeId0 = in.readIntPositioned(start + GridPortableMarshaller.TYPE_ID_POS);
- userType = PortableUtils.isUserType(flags);
+ IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(in, start);
- fieldIdLen = PortableUtils.fieldIdLength(flags);
- fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
+ footerStart = footer.get1();
+ footerLen = footer.get2() - footerStart;
- typeId = in.readIntPositioned(start + GridPortableMarshaller.TYPE_ID_POS);
+ schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS);
- IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(in, start);
+ rawOff = PortableUtils.rawOffsetAbsolute(in, start);
- footerStart = footer.get1();
- footerLen = footer.get2() - footerStart;
+ if (typeId0 == UNREGISTERED_TYPE_ID) {
+ // Skip to the class name position.
+ in.position(start + GridPortableMarshaller.DFLT_HDR_LEN);
- schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS);
+ int off = in.position();
- rawOff = PortableUtils.rawOffsetAbsolute(in, start);
+ Class cls = doReadClass(typeId0);
- if (typeId == UNREGISTERED_TYPE_ID) {
- // Skip to the class name position.
- in.position(start + GridPortableMarshaller.DFLT_HDR_LEN);
+ // registers class by typeId, at least locally if the cache is not ready yet.
+ PortableClassDescriptor desc = ctx.descriptorForClass(cls);
- int off = in.position();
+ typeId = desc.typeId();
- Class cls = doReadClass(typeId);
+ int clsNameLen = in.position() - off;
- // registers class by typeId, at least locally if the cache is not ready yet.
- PortableClassDescriptor desc = ctx.descriptorForClass(cls);
+ hdrLen = DFLT_HDR_LEN + clsNameLen;
+ }
+ else {
+ typeId = typeId0;
- typeId = desc.typeId();
+ hdrLen = DFLT_HDR_LEN;
+ }
- int clsNameLen = in.position() - off;
+ idMapper = userType ? ctx.userTypeIdMapper(typeId) : null;
+ schema = PortableUtils.hasSchema(flags) ? getOrCreateSchema() : null;
- hdrLen = DFLT_HDR_LEN + clsNameLen;
+ in.position(start);
}
- else
- hdrLen = DFLT_HDR_LEN;
-
- // Restore state.
- in.position(retPos);
+ else {
+ typeId = 0;
+ rawOff = 0;
+ hdrLen = 0;
+ footerStart = 0;
+ footerLen = 0;
+ idMapper = null;
+ schemaId = 0;
+ userType = false;
+ fieldIdLen = 0;
+ fieldOffsetLen = 0;
+ schema = null;
+ }
+ }
- hdrParsed = true;
+ /**
+ * @return Handles.
+ */
+ public BinaryReaderHandles handles() {
+ return rCtx;
}
/**
* @return Descriptor.
*/
PortableClassDescriptor descriptor() {
- return desc;
+ return ctx.descriptorForTypeId(userType, typeId, ldr);
}
/**
* @return Unmarshalled value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@Nullable Object unmarshal() throws BinaryObjectException {
return unmarshal(false);
@@ -288,9 +283,12 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @param offset Offset in the array.
* @return Unmarshalled value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
public Object unmarshal(int offset) throws BinaryObjectException {
+ // Random reads prevent any further speculations.
+ matching = false;
+
in.position(offset);
return in.position() >= 0 ? unmarshal() : null;
@@ -299,7 +297,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @param fieldName Field name.
* @return Unmarshalled value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@Nullable Object unmarshalField(String fieldName) throws BinaryObjectException {
return hasField(fieldName) ? unmarshal() : null;
@@ -308,56 +306,41 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @param fieldId Field ID.
* @return Unmarshalled value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable Object unmarshalField(int fieldId) throws BinaryObjectException {
- parseHeaderIfNeeded();
-
- return hasField(fieldId) ? unmarshal() : null;
- }
-
- /**
- * Unmarshal field by absolute position.
- *
- * @param pos Absolute position.
- * @return Field value.
* @throws BinaryObjectException In case of error.
*/
- @Nullable Object unmarshalFieldByAbsolutePosition(int pos) throws BinaryObjectException {
- parseHeaderIfNeeded();
-
- in.position(pos);
-
- return unmarshal();
+ @Nullable Object unmarshalField(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? unmarshal() : null;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException On case of error.
*/
- @Nullable Byte readByte(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(BYTE) == Flag.NULL)
- return null;
+ @Nullable Map.Entry<?, ?> readMapEntry(int fieldId) throws BinaryObjectException {
+ if (findFieldById(fieldId)) {
+ Flag flag = checkFlag(MAP_ENTRY);
- return in.readByte();
+ if (flag == Flag.NORMAL)
+ return doReadMapEntry(true);
+ else if (flag == Flag.HANDLE)
+ return readHandleField();
}
- else
- return null;
+
+ return null;
}
/**
* @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @return Portable object.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Short readShort(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(SHORT) == Flag.NULL)
+ @Nullable BinaryObject readPortableObject(int fieldId) throws BinaryObjectException {
+ if (findFieldById(fieldId)) {
+ if (checkFlag(PORTABLE_OBJ) == Flag.NULL)
return null;
- return in.readShort();
+ return new BinaryObjectImpl(ctx, doReadByteArray(), in.readInt());
}
else
return null;
@@ -365,1100 +348,1038 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @return Field class.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Integer readInt(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(INT) == Flag.NULL)
+ @Nullable Class<?> readClass(int fieldId) throws BinaryObjectException {
+ if (findFieldById(fieldId)) {
+ if (checkFlag(CLASS) == Flag.NULL)
return null;
- return in.readInt();
+ return doReadClass();
}
- else
- return null;
+
+ return null;
}
/**
- * @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @param obj Object.
*/
- @Nullable Long readLong(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(LONG) == Flag.NULL)
- return null;
-
- return in.readLong();
- }
- else
- return null;
+ void setHandler(Object obj) {
+ rCtx.put(start, obj);
}
/**
- * @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @param obj Object.
+ * @param pos Position.
*/
- @Nullable Float readFloat(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(FLOAT) == Flag.NULL)
- return null;
-
- return in.readFloat();
- }
- else
- return null;
+ void setHandler(Object obj, int pos) {
+ rCtx.put(pos, obj);
}
/**
- * @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * Recreating field value from a handle.
+ *
+ * @param <T> Field type.
+ * @return Field.
*/
- @Nullable Double readDouble(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(DOUBLE) == Flag.NULL)
- return null;
+ private <T> T readHandleField() {
+ int handle = (in.position() - 1) - in.readInt();
- return in.readDouble();
- }
- else
- return null;
- }
+ int retPos = in.position();
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable Character readChar(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(CHAR) == Flag.NULL)
- return null;
+ Object obj = rCtx.get(handle);
+
+ if (obj == null) {
+ in.position(handle);
+
+ obj = doReadObject();
- return in.readChar();
+ in.position(retPos);
}
- else
- return null;
+
+ return (T)obj;
+ }
+ /** {@inheritDoc} */
+ @Override public byte readByte(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(BYTE) == Flag.NORMAL ? in.readByte() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException If failed.
*/
- @Nullable Boolean readBoolean(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(BOOLEAN) == Flag.NULL)
- return null;
-
- return in.readBoolean();
- }
- else
- return null;
+ byte readByte(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(BYTE) == Flag.NORMAL ? in.readByte() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable BigDecimal readDecimal(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(DECIMAL) == Flag.NULL)
- return null;
+ @Nullable Byte readByteNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(BYTE) == Flag.NORMAL ? in.readByte() : null;
+ }
- return doReadDecimal();
- }
- else
- return null;
+ /** {@inheritDoc} */
+ @Override public byte readByte() throws BinaryObjectException {
+ return in.readByte();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public byte[] readByteArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readByteArray() : null;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable String readString(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(STRING) == Flag.NULL)
- return null;
+ @Nullable byte[] readByteArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readByteArray() : null;
+ }
- return doReadString();
+ /** {@inheritDoc} */
+ @Nullable @Override public byte[] readByteArray() throws BinaryObjectException {
+ switch (checkFlag(BYTE_ARR)) {
+ case NORMAL:
+ return doReadByteArray();
+
+ case HANDLE:
+ return readHandleField();
+
+ default:
+ return null;
}
- else
- return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readBoolean(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(BOOLEAN) == Flag.NORMAL && in.readBoolean();
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException If failed.
*/
- @Nullable UUID readUuid(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(UUID) == Flag.NULL)
- return null;
-
- return doReadUuid();
- }
- else
- return null;
+ boolean readBoolean(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(BOOLEAN) == Flag.NORMAL && in.readBoolean();
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Date readDate(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(DATE) == Flag.NULL)
- return null;
+ @Nullable Boolean readBooleanNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(BOOLEAN) == Flag.NORMAL ? in.readBoolean() : null;
+ }
- return doReadDate();
- }
- else
- return null;
+ /** {@inheritDoc} */
+ @Override public boolean readBoolean() throws BinaryObjectException {
+ return in.readBoolean();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public boolean[] readBooleanArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readBooleanArray() : null;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Timestamp readTimestamp(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(TIMESTAMP) == Flag.NULL)
- return null;
+ @Nullable boolean[] readBooleanArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readBooleanArray() : null;
+ }
- return doReadTimestamp();
+ /** {@inheritDoc} */
+ @Nullable @Override public boolean[] readBooleanArray() throws BinaryObjectException {
+ switch (checkFlag(BOOLEAN_ARR)) {
+ case NORMAL:
+ return doReadBooleanArray();
+
+ case HANDLE:
+ return readHandleField();
+
+ default:
+ return null;
}
- else
- return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public short readShort(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(SHORT) == Flag.NORMAL ? in.readShort() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException If failed.
*/
- @Nullable Object readObject(int fieldId) throws BinaryObjectException {
- return hasField(fieldId) ? doReadObject() : null;
+ short readShort(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(SHORT) == Flag.NORMAL ? in.readShort() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable byte[] readByteArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(BYTE_ARR);
+ @Nullable Short readShortNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(SHORT) == Flag.NORMAL ? in.readShort() : null;
+ }
- if (flag == Flag.NORMAL)
- return doReadByteArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
+ /** {@inheritDoc} */
+ @Override public short readShort() throws BinaryObjectException {
+ return in.readShort();
+ }
- return null;
+ /** {@inheritDoc} */
+ @Nullable @Override public short[] readShortArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readShortArray() : null;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@Nullable short[] readShortArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(SHORT_ARR);
+ return findFieldById(fieldId) ? this.readShortArray() : null;
+ }
- if (flag == Flag.NORMAL)
+ /** {@inheritDoc} */
+ @Nullable @Override public short[] readShortArray() throws BinaryObjectException {
+ switch (checkFlag(SHORT_ARR)) {
+ case NORMAL:
return doReadShortArray();
- else if (flag == Flag.HANDLE)
+
+ case HANDLE:
return readHandleField();
+
+ default:
+ return null;
}
+ }
- return null;
+ /** {@inheritDoc} */
+ @Override public char readChar(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(CHAR) == Flag.NORMAL ? in.readChar() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException If failed.
*/
- @Nullable int[] readIntArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(INT_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadIntArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ char readChar(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(CHAR) == Flag.NORMAL ? in.readChar() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable long[] readLongArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(LONG_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadLongArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
+ @Nullable Character readCharNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(CHAR) == Flag.NORMAL ? in.readChar() : null;
+ }
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable float[] readFloatArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(FLOAT_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadFloatArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ /** {@inheritDoc} */
+ @Override public char readChar() throws BinaryObjectException {
+ return in.readChar();
}
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable double[] readDoubleArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(DOUBLE_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadDoubleArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ /** {@inheritDoc} */
+ @Nullable @Override public char[] readCharArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readCharArray() : null;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@Nullable char[] readCharArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(CHAR_ARR);
+ return findFieldById(fieldId) ? this.readCharArray() : null;
+ }
- if (flag == Flag.NORMAL)
+ /** {@inheritDoc} */
+ @Nullable @Override public char[] readCharArray() throws BinaryObjectException {
+ switch (checkFlag(CHAR_ARR)) {
+ case NORMAL:
return doReadCharArray();
- else if (flag == Flag.HANDLE)
+
+ case HANDLE:
return readHandleField();
+
+ default:
+ return null;
}
+ }
- return null;
+ /** {@inheritDoc} */
+ @Override public int readInt(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(INT) == Flag.NORMAL ? in.readInt() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException If failed.
*/
- @Nullable boolean[] readBooleanArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(BOOLEAN_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadBooleanArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ int readInt(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(INT) == Flag.NORMAL ? in.readInt() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable BigDecimal[] readDecimalArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(DECIMAL_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadDecimalArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
+ @Nullable Integer readIntNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(INT) == Flag.NORMAL ? in.readInt() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int readInt() throws BinaryObjectException {
+ return in.readInt();
+ }
- return null;
+ /** {@inheritDoc} */
+ @Nullable @Override public int[] readIntArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readIntArray() : null;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable String[] readStringArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(STRING_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadStringArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ @Nullable int[] readIntArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readIntArray() : null;
}
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable UUID[] readUuidArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(UUID_ARR);
+ /** {@inheritDoc} */
+ @Nullable @Override public int[] readIntArray() throws BinaryObjectException {
+ switch (checkFlag(INT_ARR)) {
+ case NORMAL:
+ return doReadIntArray();
- if (flag == Flag.NORMAL)
- return doReadUuidArray();
- else if (flag == Flag.HANDLE)
+ case HANDLE:
return readHandleField();
+
+ default:
+ return null;
}
+ }
- return null;
+ /** {@inheritDoc} */
+ @Override public long readLong(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(LONG) == Flag.NORMAL ? in.readLong() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException If failed.
*/
- @Nullable Date[] readDateArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(DATE_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadDateArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ long readLong(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(LONG) == Flag.NORMAL ? in.readLong() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Timestamp[] readTimestampArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(TIMESTAMP_ARR);
+ @Nullable Long readLongNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(LONG) == Flag.NORMAL ? in.readLong() : null;
+ }
- if (flag == Flag.NORMAL)
- return doReadTimestampArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
+ /** {@inheritDoc} */
+ @Override public long readLong() throws BinaryObjectException {
+ return in.readLong();
+ }
- return null;
+ /** {@inheritDoc} */
+ @Nullable @Override public long[] readLongArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readLongArray() : null;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Object[] readObjectArray(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(OBJ_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadObjectArray(true);
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ @Nullable long[] readLongArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readLongArray() : null;
}
- /**
- * @param fieldId Field ID.
- * @param cls Collection class.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable <T> Collection<T> readCollection(int fieldId, @Nullable Class<? extends Collection> cls)
- throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(COL);
+ /** {@inheritDoc} */
+ @Nullable @Override public long[] readLongArray() throws BinaryObjectException {
+ switch (checkFlag(LONG_ARR)) {
+ case NORMAL:
+ return doReadLongArray();
- if (flag == Flag.NORMAL)
- return (Collection<T>)doReadCollection(true, cls);
- else if (flag == Flag.HANDLE)
+ case HANDLE:
return readHandleField();
+
+ default:
+ return null;
}
+ }
- return null;
+ /** {@inheritDoc} */
+ @Override public float readFloat(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(FLOAT) == Flag.NORMAL ? in.readFloat() : 0;
}
/**
* @param fieldId Field ID.
- * @param cls Map class.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException If failed.
*/
- @Nullable Map<?, ?> readMap(int fieldId, @Nullable Class<? extends Map> cls)
- throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(MAP);
-
- if (flag == Flag.NORMAL)
- return doReadMap(true, cls);
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ float readFloat(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(FLOAT) == Flag.NORMAL ? in.readFloat() : 0;
}
/**
* @param fieldId Field ID.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException On case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Map.Entry<?, ?> readMapEntry(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(MAP_ENTRY);
-
- if (flag == Flag.NORMAL)
- return doReadMapEntry(true);
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
+ @Nullable Float readFloatNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(FLOAT) == Flag.NORMAL ? in.readFloat() : null;
}
- /**
- * @param fieldId Field ID.
- * @return Portable object.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable BinaryObject readPortableObject(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(PORTABLE_OBJ) == Flag.NULL)
- return null;
-
- return new BinaryObjectImpl(ctx, doReadByteArray(), in.readInt());
- }
- else
- return null;
+ /** {@inheritDoc} */
+ @Override public float readFloat() throws BinaryObjectException {
+ return in.readFloat();
}
- /**
- * @param fieldId Field ID.
- * @param cls Class.
- * @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable Enum<?> readEnum(int fieldId, @Nullable Class<?> cls) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(ENUM) == Flag.NULL)
- return null;
-
- // Revisit: why have we started writing Class for enums in their serialized form?
- if (cls == null)
- cls = doReadClass();
- else
- doReadClass();
-
- Object[] vals = GridEnumCache.get(cls);
-
- return (Enum<?>)vals[in.readInt()];
- }
- else
- return null;
+ /** {@inheritDoc} */
+ @Nullable @Override public float[] readFloatArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readFloatArray() : null;
}
/**
* @param fieldId Field ID.
- * @param cls Class.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
- @Nullable Object[] readEnumArray(int fieldId, @Nullable Class<?> cls) throws BinaryObjectException {
- if (hasField(fieldId)) {
- Flag flag = checkFlag(ENUM_ARR);
+ @Nullable float[] readFloatArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readFloatArray() : null;
+ }
- if (flag == Flag.NORMAL) {
- if (cls == null)
- cls = doReadClass();
- else
- doReadClass();
+ /** {@inheritDoc} */
+ @Nullable @Override public float[] readFloatArray() throws BinaryObjectException {
+ switch (checkFlag(FLOAT_ARR)) {
+ case NORMAL:
+ return doReadFloatArray();
- return doReadEnumArray(cls);
- }
- else if (flag == Flag.HANDLE)
+ case HANDLE:
return readHandleField();
- }
-
- return null;
- }
- /**
- * @param fieldId Field ID.
- * @return Field class.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
- */
- @Nullable Class<?> readClass(int fieldId) throws BinaryObjectException {
- if (hasField(fieldId)) {
- if (checkFlag(CLASS) == Flag.NULL)
+ default:
return null;
-
- return doReadClass();
}
-
- return null;
}
- /**
- * @param obj Object.
- */
- void setHandler(Object obj) {
- rCtx.setObjectHandler(start, obj);
+ /** {@inheritDoc} */
+ @Override public double readDouble(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) && checkFlagNoHandles(DOUBLE) == Flag.NORMAL ? in.readDouble() : 0;
}
/**
- * @param obj Object.
- * @param pos Position.
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
*/
- void setHandler(Object obj, int pos) {
- rCtx.setObjectHandler(pos, obj);
+ double readDouble(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(DOUBLE) == Flag.NORMAL ? in.readDouble() : 0;
}
/**
- * Recreating field value from a handle.
- *
- * @param <T> Field type.
- * @return Field.
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
*/
- private <T> T readHandleField() {
- int handle = (in.position() - 1) - in.readInt();
-
- Object obj = rCtx.getObjectByHandle(handle);
-
- if (obj == null) {
- in.position(handle);
-
- obj = doReadObject();
- }
-
- return (T)obj;
- }
- /** {@inheritDoc} */
- @Override public byte readByte(String fieldName) throws BinaryObjectException {
- Byte val = readByte(fieldId(fieldName));
-
- return val != null ? val : 0;
- }
-
- /** {@inheritDoc} */
- @Override public byte readByte() throws BinaryObjectException {
- return in.readByte();
+ @Nullable Double readDoubleNullable(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) && checkFlagNoHandles(DOUBLE) == Flag.NORMAL ? in.readDouble() : null;
}
/** {@inheritDoc} */
- @Override public short readShort(String fieldName) throws BinaryObjectException {
- Short val = readShort(fieldId(fieldName));
-
- return val != null ? val : 0;
- }
-
- /** {@inheritDoc} */
- @Override public short readShort() throws BinaryObjectException {
- return in.readShort();
+ @Override public double readDouble() throws BinaryObjectException {
+ return in.readDouble();
}
/** {@inheritDoc} */
- @Override public int readInt(String fieldName) throws BinaryObjectException {
- Integer val = readInt(fieldId(fieldName));
-
- return val != null ? val : 0;
+ @Nullable @Override public double[] readDoubleArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readDoubleArray() : null;
}
- /** {@inheritDoc} */
- @Override public int readInt() throws BinaryObjectException {
- return in.readInt();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable double[] readDoubleArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readDoubleArray() : null;
}
/** {@inheritDoc} */
- @Override public long readLong(String fieldName) throws BinaryObjectException {
- Long val = readLong(fieldId(fieldName));
+ @Nullable @Override public double[] readDoubleArray() throws BinaryObjectException {
+ switch (checkFlag(DOUBLE_ARR)) {
+ case NORMAL:
+ return doReadDoubleArray();
- return val != null ? val : 0;
- }
+ case HANDLE:
+ return readHandleField();
- /** {@inheritDoc} */
- @Override public long readLong() throws BinaryObjectException {
- return in.readLong();
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Override public float readFloat(String fieldName) throws BinaryObjectException {
- Float val = readFloat(fieldId(fieldName));
-
- return val != null ? val : 0;
+ @Override @Nullable public BigDecimal readDecimal(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readDecimal() : null;
}
- /** {@inheritDoc} */
- @Override public float readFloat() throws BinaryObjectException {
- return in.readFloat();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable BigDecimal readDecimal(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readDecimal() : null;
}
/** {@inheritDoc} */
- @Override public double readDouble(String fieldName) throws BinaryObjectException {
- Double val = readDouble(fieldId(fieldName));
-
- return val != null ? val : 0;
+ @Override @Nullable public BigDecimal readDecimal() throws BinaryObjectException {
+ return checkFlagNoHandles(DECIMAL) == Flag.NORMAL ? doReadDecimal() : null;
}
/** {@inheritDoc} */
- @Override public double readDouble() throws BinaryObjectException {
- return in.readDouble();
+ @Override @Nullable public BigDecimal[] readDecimalArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readDecimalArray() : null;
}
- /** {@inheritDoc} */
- @Override public char readChar(String fieldName) throws BinaryObjectException {
- Character val = readChar(fieldId(fieldName));
-
- return val != null ? val : 0;
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable BigDecimal[] readDecimalArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readDecimalArray() : null;
}
/** {@inheritDoc} */
- @Override public char readChar() throws BinaryObjectException {
- return in.readChar();
- }
+ @Override @Nullable public BigDecimal[] readDecimalArray() throws BinaryObjectException {
+ switch (checkFlag(DECIMAL_ARR)) {
+ case NORMAL:
+ return doReadDecimalArray();
- /** {@inheritDoc} */
- @Override public boolean readBoolean(String fieldName) throws BinaryObjectException {
- Boolean val = readBoolean(fieldId(fieldName));
+ case HANDLE:
+ return readHandleField();
- return val != null ? val : false;
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Override public boolean readBoolean() throws BinaryObjectException {
- return in.readBoolean();
+ @Override @Nullable public String readString(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readString() : null;
}
- /** {@inheritDoc} */
- @Override @Nullable public BigDecimal readDecimal(String fieldName) throws BinaryObjectException {
- return readDecimal(fieldId(fieldName));
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable String readString(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readString() : null;
}
/** {@inheritDoc} */
- @Override @Nullable public BigDecimal readDecimal() throws BinaryObjectException {
- if (checkFlag(DECIMAL) == Flag.NULL)
- return null;
-
- return doReadDecimal();
+ @Override @Nullable public String readString() throws BinaryObjectException {
+ return checkFlagNoHandles(STRING) == Flag.NORMAL ? doReadString() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public String readString(String fieldName) throws BinaryObjectException {
- return readString(fieldId(fieldName));
+ @Override @Nullable public String[] readStringArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readStringArray() : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public String readString() throws BinaryObjectException {
- if (checkFlag(STRING) == Flag.NULL)
- return null;
-
- return doReadString();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable String[] readStringArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readStringArray() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public UUID readUuid(String fieldName) throws BinaryObjectException {
- return readUuid(fieldId(fieldName));
- }
+ @Override @Nullable public String[] readStringArray() throws BinaryObjectException {
+ switch (checkFlag(STRING_ARR)) {
+ case NORMAL:
+ return doReadStringArray();
- /** {@inheritDoc} */
- @Nullable @Override public UUID readUuid() throws BinaryObjectException {
- if (checkFlag(UUID) == Flag.NULL)
- return null;
+ case HANDLE:
+ return readHandleField();
- return doReadUuid();
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Nullable @Override public Date readDate(String fieldName) throws BinaryObjectException {
- return readDate(fieldId(fieldName));
+ @Override @Nullable public UUID readUuid(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readUuid() : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public Date readDate() throws BinaryObjectException {
- if (checkFlag(DATE) == Flag.NULL)
- return null;
-
- return doReadDate();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable UUID readUuid(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readUuid() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public Timestamp readTimestamp(String fieldName) throws BinaryObjectException {
- return readTimestamp(fieldId(fieldName));
+ @Override @Nullable public UUID readUuid() throws BinaryObjectException {
+ return checkFlagNoHandles(UUID) == Flag.NORMAL ? doReadUuid() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public Timestamp readTimestamp() throws BinaryObjectException {
- if (checkFlag(TIMESTAMP) == Flag.NULL)
- return null;
-
- return doReadTimestamp();
+ @Override @Nullable public UUID[] readUuidArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readUuidArray() : null;
}
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Nullable @Override public <T> T readObject(String fieldName) throws BinaryObjectException {
- return (T)readObject(fieldId(fieldName));
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable UUID[] readUuidArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readUuidArray() : null;
}
/** {@inheritDoc} */
- @Override public Object readObject() throws BinaryObjectException {
- return doReadObject();
- }
+ @Override @Nullable public UUID[] readUuidArray() throws BinaryObjectException {
+ switch (checkFlag(UUID_ARR)) {
+ case NORMAL:
+ return doReadUuidArray();
- /** {@inheritDoc} */
- @Nullable @Override public Object readObjectDetached() throws BinaryObjectException {
- return unmarshal(true);
- }
+ case HANDLE:
+ return readHandleField();
- /** {@inheritDoc} */
- @Nullable @Override public byte[] readByteArray(String fieldName) throws BinaryObjectException {
- return readByteArray(fieldId(fieldName));
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Nullable @Override public byte[] readByteArray() throws BinaryObjectException {
- if (checkFlag(BYTE_ARR) == Flag.NULL)
- return null;
-
- return doReadByteArray();
+ @Override @Nullable public Date readDate(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readDate() : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public short[] readShortArray(String fieldName) throws BinaryObjectException {
- return readShortArray(fieldId(fieldName));
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Date readDate(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readDate() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public short[] readShortArray() throws BinaryObjectException {
- if (checkFlag(SHORT_ARR) == Flag.NULL)
- return null;
-
- return doReadShortArray();
+ @Override @Nullable public Date readDate() throws BinaryObjectException {
+ return checkFlagNoHandles(DATE) == Flag.NORMAL ? doReadDate() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public int[] readIntArray(String fieldName) throws BinaryObjectException {
- return readIntArray(fieldId(fieldName));
+ @Override @Nullable public Date[] readDateArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readDateArray() : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public int[] readIntArray() throws BinaryObjectException {
- if (checkFlag(INT_ARR) == Flag.NULL)
- return null;
-
- return doReadIntArray();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Date[] readDateArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readDateArray() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public long[] readLongArray(String fieldName) throws BinaryObjectException {
- return readLongArray(fieldId(fieldName));
- }
+ @Override @Nullable public Date[] readDateArray() throws BinaryObjectException {
+ switch (checkFlag(DATE_ARR)) {
+ case NORMAL:
+ return doReadDateArray();
- /** {@inheritDoc} */
- @Nullable @Override public long[] readLongArray() throws BinaryObjectException {
- if (checkFlag(LONG_ARR) == Flag.NULL)
- return null;
+ case HANDLE:
+ return readHandleField();
- return doReadLongArray();
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Nullable @Override public float[] readFloatArray(String fieldName) throws BinaryObjectException {
- return readFloatArray(fieldId(fieldName));
+ @Override @Nullable public Timestamp readTimestamp(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readTimestamp() : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public float[] readFloatArray() throws BinaryObjectException {
- if (checkFlag(FLOAT_ARR) == Flag.NULL)
- return null;
-
- return doReadFloatArray();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Timestamp readTimestamp(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readTimestamp() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public double[] readDoubleArray(String fieldName) throws BinaryObjectException {
- return readDoubleArray(fieldId(fieldName));
+ @Override @Nullable public Timestamp readTimestamp() throws BinaryObjectException {
+ return checkFlagNoHandles(TIMESTAMP) == Flag.NORMAL ? doReadTimestamp() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public double[] readDoubleArray() throws BinaryObjectException {
- if (checkFlag(DOUBLE_ARR) == Flag.NULL)
- return null;
-
- return doReadDoubleArray();
+ @Override @Nullable public Timestamp[] readTimestampArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readTimestampArray() : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public char[] readCharArray(String fieldName) throws BinaryObjectException {
- return readCharArray(fieldId(fieldName));
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Timestamp[] readTimestampArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readTimestampArray() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public char[] readCharArray() throws BinaryObjectException {
- if (checkFlag(CHAR_ARR) == Flag.NULL)
- return null;
+ @Override @Nullable public Timestamp[] readTimestampArray() throws BinaryObjectException {
+ switch (checkFlag(TIMESTAMP_ARR)) {
+ case NORMAL:
+ return doReadTimestampArray();
- return doReadCharArray();
- }
+ case HANDLE:
+ return readHandleField();
- /** {@inheritDoc} */
- @Nullable @Override public boolean[] readBooleanArray(String fieldName) throws BinaryObjectException {
- return readBooleanArray(fieldId(fieldName));
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Nullable @Override public boolean[] readBooleanArray() throws BinaryObjectException {
- if (checkFlag(BOOLEAN_ARR) == Flag.NULL)
- return null;
-
- return doReadBooleanArray();
+ @SuppressWarnings("unchecked")
+ @Nullable @Override public <T> T readObject(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? (T)doReadObject() : null;
}
- /** {@inheritDoc} */
- @Override @Nullable public BigDecimal[] readDecimalArray(String fieldName) throws BinaryObjectException {
- return readDecimalArray(fieldId(fieldName));
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Object readObject(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? doReadObject() : null;
}
/** {@inheritDoc} */
- @Override @Nullable public BigDecimal[] readDecimalArray() throws BinaryObjectException {
- if (checkFlag(DECIMAL_ARR) == Flag.NULL)
- return null;
-
- return doReadDecimalArray();
+ @Override public Object readObject() throws BinaryObjectException {
+ return doReadObject();
}
/** {@inheritDoc} */
- @Nullable @Override public String[] readStringArray(String fieldName) throws BinaryObjectException {
- return readStringArray(fieldId(fieldName));
+ @Nullable @Override public Object readObjectDetached() throws BinaryObjectException {
+ return unmarshal(true);
}
/** {@inheritDoc} */
- @Nullable @Override public String[] readStringArray() throws BinaryObjectException {
- if (checkFlag(STRING_ARR) == Flag.NULL)
- return null;
-
- return doReadStringArray();
+ @Nullable @Override public Object[] readObjectArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readObjectArray() : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public UUID[] readUuidArray(String fieldName) throws BinaryObjectException {
- return readUuidArray(fieldId(fieldName));
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Object[] readObjectArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readObjectArray() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public UUID[] readUuidArray() throws BinaryObjectException {
- if (checkFlag(UUID_ARR) == Flag.NULL)
- return null;
+ @Nullable @Override public Object[] readObjectArray() throws BinaryObjectException {
+ switch (checkFlag(OBJ_ARR)) {
+ case NORMAL:
+ return doReadObjectArray(true);
- return doReadUuidArray();
+ case HANDLE:
+ return readHandleField();
+
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Nullable @Override public Date[] readDateArray(String fieldName) throws BinaryObjectException {
- return readDateArray(fieldId(fieldName));
+ @Nullable @Override public <T extends Enum<?>> T readEnum(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? (T)readEnum0(null) : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public Timestamp[] readTimestampArray(String fieldName) throws BinaryObjectException {
- return readTimestampArray(fieldId(fieldName));
+ /**
+ * @param fieldId Field ID.
+ * @param cls Class.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Enum<?> readEnum(int fieldId, @Nullable Class<?> cls) throws BinaryObjectException {
+ return findFieldById(fieldId) ? readEnum0(cls) : null;
}
/** {@inheritDoc} */
- @Nullable @Override public Date[] readDateArray() throws BinaryObjectException {
- if (checkFlag(DATE_ARR) == Flag.NULL)
- return null;
+ @Nullable @Override public <T extends Enum<?>> T readEnum() throws BinaryObjectException {
+ return (T)readEnum0(null);
+ }
+
+ /**
+ * Internal routine to read enum for named field.
+ *
+ * @param cls Class.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ private Enum<?> readEnum0(@Nullable Class<?> cls) throws BinaryObjectException {
+ if (checkFlagNoHandles(ENUM) == Flag.NORMAL) {
+ // Read class even if we know it in advance to set correct stream position.
+ Class<?> cls0 = doReadClass();
- return doReadDateArray();
+ if (cls == null)
+ cls = cls0;
+
+ return doReadEnum(cls);
+ }
+ else
+ return null;
}
/** {@inheritDoc} */
- @Nullable @Override public Timestamp[] readTimestampArray() throws BinaryObjectException {
- if (checkFlag(TIMESTAMP_ARR) == Flag.NULL)
- return null;
+ @Nullable @Override public <T extends Enum<?>> T[] readEnumArray(String fieldName)
+ throws BinaryObjectException {
+ return findFieldByName(fieldName) ? (T[])readEnumArray0(null) : null;
+ }
- return doReadTimestampArray();
+ /**
+ * @param fieldId Field ID.
+ * @param cls Class.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Object[] readEnumArray(int fieldId, @Nullable Class<?> cls) throws BinaryObjectException {
+ return findFieldById(fieldId) ? readEnumArray0(cls) : null;
}
/** {@inheritDoc} */
- @Nullable @Override public Object[] readObjectArray(String fieldName) throws BinaryObjectException {
- return readObjectArray(fieldId(fieldName));
+ @Nullable @Override public <T extends Enum<?>> T[] readEnumArray() throws BinaryObjectException {
+ return (T[])readEnumArray0(null);
}
- /** {@inheritDoc} */
- @Nullable @Override public Object[] readObjectArray() throws BinaryObjectException {
- if (checkFlag(OBJ_ARR) == Flag.NULL)
- return null;
+ /**
+ * Internal routine to read enum for named field.
+ *
+ * @param cls Class.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ private Object[] readEnumArray0(@Nullable Class<?> cls) throws BinaryObjectException {
+ switch (checkFlag(ENUM_ARR)) {
+ case NORMAL:
+ // Read class even if we know it in advance to set correct stream position.
+ Class<?> cls0 = doReadClass();
+
+ if (cls == null)
+ cls = cls0;
+
+ return doReadEnumArray(cls);
+
+ case HANDLE:
+ return readHandleField();
- return doReadObjectArray(true);
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
@Nullable @Override public <T> Collection<T> readCollection(String fieldName) throws BinaryObjectException {
- return readCollection(fieldId(fieldName), null);
+ return findFieldByName(fieldName) ? (Collection<T>)readCollection0(null) : null;
}
/** {@inheritDoc} */
- @Nullable @Override public <T> Collection<T> readCollection() throws BinaryObjectException {
- if (checkFlag(COL) == Flag.NULL)
- return null;
+ @Nullable @Override public <T> Collection<T> readCollection(String fieldName,
+ Class<? extends Collection<T>> colCls) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? readCollection0(colCls) : null;
+ }
- return (Collection<T>)doReadCollection(true, null);
+ /**
+ * @param fieldId Field ID.
+ * @param colCls Collection class.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable <T> Collection<T> readCollection(int fieldId, @Nullable Class<? extends Collection> colCls)
+ throws BinaryObjectException {
+ return findFieldById(fieldId) ? (Collection<T>)readCollection0(colCls) : null;
}
/** {@inheritDoc} */
- @Nullable @Override public <T> Collection<T> readCollection(String fieldName,
- Class<? extends Collection<T>> colCls) throws BinaryObjectException {
- return readCollection(fieldId(fieldName), colCls);
+ @Nullable @Override public <T> Collection<T> readCollection() throws BinaryObjectException {
+ return readCollection0(null);
}
/** {@inheritDoc} */
@Nullable @Override public <T> Collection<T> readCollection(Class<? extends Collection<T>> colCls)
throws BinaryObjectException {
- if (checkFlag(COL) == Flag.NULL)
- return null;
-
- return (Collection<T>)doReadCollection(true, colCls);
+ return readCollection0(colCls);
}
- /** {@inheritDoc} */
- @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName) throws BinaryObjectException {
- return (Map<K, V>)readMap(fieldId(fieldName), null);
- }
+ /**
+ * Internal read collection routine.
+ *
+ * @param cls Collection class.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
+ */
+ private Collection readCollection0(@Nullable Class<? extends Collection> cls)
+ throws BinaryObjectException {
+ switch (checkFlag(COL)) {
+ case NORMAL:
+ return (Collection)doReadCollection(true, cls);
- /** {@inheritDoc} */
- @Nullable @Override public <K, V> Map<K, V> readMap() throws BinaryObjectException {
- if (checkFlag(MAP) == Flag.NULL)
- return null;
+ case HANDLE:
+ return readHandleField();
- return (Map<K, V>)doReadMap(true, null);
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
- @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName, Class<? extends Map<K, V>> mapCls)
- throws BinaryObjectException {
- return (Map<K, V>)readMap(fieldId(fieldName), mapCls);
+ @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? (Map<K, V>)readMap0(null) : null;
}
/** {@inheritDoc} */
- @Nullable @Override public <K, V> Map<K, V> readMap(Class<? extends Map<K, V>> mapCls)
+ @Nullable @Override public <K, V> Map<K, V> readMap(String fieldName, Class<? extends Map<K, V>> mapCls)
throws BinaryObjectException {
- if (checkFlag(MAP) == Flag.NULL)
- return null;
-
- return (Map<K, V>)doReadMap(true, mapCls);
+ return findFieldByName(fieldName) ? readMap0(mapCls) : null;
}
- /** {@inheritDoc} */
- @Nullable @Override public <T extends Enum<?>> T readEnum(String fieldName)
- throws BinaryObjectException {
- return (T)readEnum(fieldId(fieldName), null);
+ /**
+ * @param fieldId Field ID.
+ * @param mapCls Map class.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable Map<?, ?> readMap(int fieldId, @Nullable Class<? extends Map> mapCls) throws BinaryObjectException {
+ return findFieldById(fieldId) ? readMap0(mapCls) : null;
}
/** {@inheritDoc} */
- @Nullable @Override public <T extends Enum<?>> T readEnum() throws BinaryObjectException {
- if (checkFlag(ENUM) == Flag.NULL)
- return null;
-
- Class cls = doReadClass();
-
- return (T)doReadEnum(cls);
+ @Nullable @Override public <K, V> Map<K, V> readMap() throws BinaryObjectException {
+ return readMap0(null);
}
/** {@inheritDoc} */
- @Nullable @Override public <T extends Enum<?>> T[] readEnumArray(String fieldName)
+ @Nullable @Override public <K, V> Map<K, V> readMap(Class<? extends Map<K, V>> mapCls)
throws BinaryObjectException {
- return (T[])readEnumArray(fieldId(fieldName), null);
+ return readMap0(mapCls);
}
- /** {@inheritDoc} */
- @Nullable @Override public <T extends Enum<?>> T[] readEnumArray() throws BinaryObjectException {
- if (checkFlag(ENUM_ARR) == Flag.NULL)
- return null;
+ /**
+ * Internal read map routine.
+ *
+ * @param cls Map class.
+ * @return Value.
+ * @throws BinaryObjectException If failed.
+ */
+ private Map readMap0(@Nullable Class<? extends Map> cls) throws BinaryObjectException {
+ switch (checkFlag(MAP)) {
+ case NORMAL:
+ return (Map)doReadMap(true, cls);
- Class cls = doReadClass();
+ case HANDLE:
+ return readHandleField();
- return (T[])doReadEnumArray(cls);
+ default:
+ return null;
+ }
}
/**
- * Ensure that type flag is either null or contains expected value.
+ * Ensure that type flag is either null, handle or contains expected value.
*
* @param expFlag Expected value.
- * @return Flag.
- * @throws org.apache.ignite.binary.BinaryObjectException If flag is neither null, nor expected.
+ * @return Flag mode.
+ * @throws BinaryObjectException If flag is neither null, nor handle or expected.
*/
private Flag checkFlag(byte expFlag) {
byte flag = in.readByte();
- if (flag == NULL)
+ if (flag == expFlag)
+ return Flag.NORMAL;
+ else if (flag == NULL)
return Flag.NULL;
else if (flag == HANDLE)
return Flag.HANDLE;
- else if (flag != expFlag) {
- int pos = in.position() - 1;
- throw new BinaryObjectException("Unexpected flag value [pos=" + pos + ", expected=" + expFlag +
- ", actual=" + flag + ']');
- }
+ int pos = positionForHandle();
- return Flag.NORMAL;
+ throw new BinaryObjectException("Unexpected flag value [pos=" + pos + ", expected=" + expFlag +
+ ", actual=" + flag + ']');
}
/**
- * @param fieldName Field name.
- * @return {@code True} if field is set.
+ * Ensure that type flag is either null or contains expected value.
+ *
+ * @param expFlag Expected value.
+ * @return Flag mode.
+ * @throws BinaryObjectException If flag is neither null, nor expected.
*/
- public boolean hasField(String fieldName) {
- return hasField(fieldId(fieldName));
+ private Flag checkFlagNoHandles(byte expFlag) {
+ byte flag = in.readByte();
+
+ if (flag == expFlag)
+ return Flag.NORMAL;
+ else if (flag == NULL)
+ return Flag.NULL;
+
+ int pos = positionForHandle();
+
+ throw new BinaryObjectException("Unexpected flag value [pos=" + pos + ", expected=" + expFlag +
+ ", actual=" + flag + ']');
}
/**
- * @param fieldId Field ID.
+ * @param fieldName Field name.
* @return {@code True} if field is set.
*/
- private boolean hasField(int fieldId) {
- return fieldOffset(fieldId) != 0;
+ public boolean hasField(String fieldName) {
+ return findFieldById(fieldId(fieldName));
}
/** {@inheritDoc} */
@@ -1470,7 +1391,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @return Unmarshalled value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@Nullable private Object unmarshal(boolean detach) throws BinaryObjectException {
int start = in.position();
@@ -1484,7 +1405,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
case HANDLE:
int handle = start - in.readInt();
- BinaryObject handledPo = rCtx.getPortableByHandle(handle);
+ BinaryObject handledPo = rCtx.get(handle);
if (handledPo != null)
return handledPo;
@@ -1513,7 +1434,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
in.remaining() + in.position())
: new BinaryObjectImpl(ctx, in.array(), start);
- rCtx.setPortableHandler(start, po);
+ rCtx.put(start, po);
in.position(start + po.length());
@@ -1672,7 +1593,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
String res = new String(in.array(), strOff, strLen, UTF_8);
- in.position(in.position() + strLen);
+ in.position(strOff + strLen);
return res;
}
@@ -1709,17 +1630,17 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @return Object.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@Nullable private Object doReadObject() throws BinaryObjectException {
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, in, in.position(), ldr, rCtx);
+ BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, in, ldr, rCtx);
return reader.deserialize();
}
/**
* @return Deserialized object.
- * @throws org.apache.ignite.binary.BinaryObjectException If failed.
+ * @throws BinaryObjectException If failed.
*/
@Nullable Object deserialize() throws BinaryObjectException {
Object obj;
@@ -1735,7 +1656,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
case HANDLE:
int handle = start - in.readInt();
- obj = rCtx.getObjectByHandle(handle);
+ obj = rCtx.get(handle);
if (obj == null) {
int retPos = in.position();
@@ -1750,20 +1671,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
break;
case OBJ:
- parseHeaderIfNeeded();
-
- assert typeId != UNREGISTERED_TYPE_ID;
-
- PortableUtils.checkProtocolVersion(in.readByte());
-
- boolean userType = PortableUtils.isUserType(this.readShort());
-
- // Skip typeId and hash code.
- in.position(in.position() + 8);
-
- desc = ctx.descriptorForTypeId(userType, typeId, ldr);
-
- int len = in.readInt();
+ PortableClassDescriptor desc = ctx.descriptorForTypeId(userType, typeId, ldr);
in.position(start + hdrLen);
@@ -1772,7 +1680,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
obj = desc.read(this);
- in.position(start + len);
+ in.position(footerStart + footerLen);
break;
@@ -1978,7 +1886,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private byte[] doReadByteArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -1993,7 +1901,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private short[] doReadShortArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2008,7 +1916,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private int[] doReadIntArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2023,7 +1931,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private long[] doReadLongArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2038,7 +1946,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private float[] doReadFloatArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2053,7 +1961,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private double[] doReadDoubleArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2068,7 +1976,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private char[] doReadCharArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2083,7 +1991,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
*/
private boolean[] doReadBooleanArray() {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2096,10 +2004,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private BigDecimal[] doReadDecimalArray() throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2125,10 +2033,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private String[] doReadStringArray() throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2151,13 +2059,13 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
return arr;
}
-
+
/**
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private UUID[] doReadUuidArray() throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2183,10 +2091,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private Date[] doReadDateArray() throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2212,10 +2120,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private Timestamp[] doReadTimestampArray() throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int len = in.readInt();
@@ -2242,10 +2150,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @param deep Deep flag.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private Object[] doReadObjectArray(boolean deep) throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
Class compType = doReadClass();
@@ -2265,12 +2173,12 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @param deep Deep flag.
* @param cls Collection class.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@SuppressWarnings("unchecked")
private Collection<?> doReadCollection(boolean deep, @Nullable Class<? extends Collection> cls)
throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int size = in.readInt();
@@ -2353,12 +2261,12 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @param deep Deep flag.
* @param cls Map class.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
@SuppressWarnings("unchecked")
private Map<?, ?> doReadMap(boolean deep, @Nullable Class<? extends Map> cls)
throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
int size = in.readInt();
@@ -2430,10 +2338,10 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/**
* @param deep Deep flag.
* @return Value.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private Map.Entry<?, ?> doReadMapEntry(boolean deep) throws BinaryObjectException {
- int hPos = in.position() - 1;
+ int hPos = positionForHandle();
Object val1 = deep ? doReadObject() : unmarshal();
Object val2 = deep ? doReadObject() : unmarshal();
@@ -2469,16 +2377,20 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/**
+ * Having target class in place we simply read ordinal and create final representation.
+ *
* @param cls Enum class.
* @return Value.
*/
private Enum<?> doReadEnum(Class<?> cls) throws BinaryObjectException {
+ assert cls != null;
+
if (!cls.isEnum())
throw new BinaryObjectException("Class does not represent enum type: " + cls.getName());
int ord = in.readInt();
- return ord >= 0 ? (Enum<?>)GridEnumCache.get(cls)[ord] : null;
+ return BinaryEnumCache.get(cls, ord);
}
/**
@@ -2544,19 +2456,21 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/**
+ * Get position to be used for handle. We assume here that the hdr byte was read, hence subtract -1.
+ *
+ * @return Position for handle.
+ */
+ int positionForHandle() {
+ return in.position() - 1;
+ }
+
+ /**
* @param name Field name.
* @return Field offset.
*/
private int fieldId(String name) {
assert name != null;
- parseHeaderIfNeeded();
-
- assert typeId != UNREGISTERED_TYPE_ID;
-
- if (idMapper == null)
- idMapper = ctx.userTypeIdMapper(typeId);
-
return idMapper.fieldId(typeId, name);
}
@@ -2566,8 +2480,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Schema.
*/
public PortableSchema getOrCreateSchema() {
- parseHeaderIfNeeded();
-
PortableSchema schema = ctx.schemaRegistry(typeId).schema(schemaId);
if (schema == null) {
@@ -2626,71 +2538,162 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/**
- * @param id Field ID.
- * @return Field offset.
+ * Try finding the field by name.
+ *
+ * @param name Field name.
+ * @return Offset.
*/
- private int fieldOffset(int id) {
+ private boolean findFieldByName(String name) {
assert hdrLen != 0;
if (footerLen == 0)
- return 0;
+ return false;
- int searchPos = footerStart;
- int searchTail = searchPos + footerLen;
+ if (userType) {
+ int order;
- if (!userType || (fieldIdLen != 0 && hasLowFieldsCount(footerLen))) {
- while (true) {
- if (searchPos >= searchTail)
- return 0;
+ if (matching) {
+ int expOrder = matchingOrder++;
- int id0 = in.readIntPositioned(searchPos);
+ PortableSchema.Confirmation confirm = schema.confirmOrder(expOrder, name);
- if (id0 == id) {
- int pos = start + PortableUtils.fieldOffsetRelative(in, searchPos + PortableUtils.FIELD_ID_LEN,
- fieldOffsetLen);
+ switch (confirm) {
+ case CONFIRMED:
+ // The best case: got order without ID calculation and (ID -> order) lookup.
+ order = expOrder;
- in.position(pos);
+ break;
- return pos;
- }
+
<TRUNCATED>
[04/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index cb582b7..68616ab 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -39,8 +39,8 @@ namespace Apache.Ignite.Core.Tests.Compute
/** Echo task name. */
private const string EchoTask = "org.apache.ignite.platform.PlatformComputeEchoTask";
- /** Portable argument task name. */
- private const string PortableArgTask = "org.apache.ignite.platform.PlatformComputePortableArgTask";
+ /** Binary argument task name. */
+ private const string BinaryArgTask = "org.apache.ignite.platform.PlatformComputeBinarizableArgTask";
/** Broadcast task name. */
private const string BroadcastTask = "org.apache.ignite.platform.PlatformComputeBroadcastTask";
@@ -48,8 +48,8 @@ namespace Apache.Ignite.Core.Tests.Compute
/** Broadcast task name. */
private const string DecimalTask = "org.apache.ignite.platform.PlatformComputeDecimalTask";
- /** Java portable class name. */
- private const string JavaPortableCls = "GridInteropComputeJavaPortable";
+ /** Java binary class name. */
+ private const string JavaBinaryCls = "PlatformComputeJavaBinarizable";
/** Echo type: null. */
private const int EchoTypeNull = 0;
@@ -87,17 +87,17 @@ namespace Apache.Ignite.Core.Tests.Compute
/** Echo type: map. */
private const int EchoTypeMap = 11;
- /** Echo type: portable. */
- private const int EchoTypePortable = 12;
+ /** Echo type: binarizable. */
+ private const int EchoTypeBinarizable = 12;
- /** Echo type: portable (Java only). */
- private const int EchoTypePortableJava = 13;
+ /** Echo type: binary (Java only). */
+ private const int EchoTypeBinarizableJava = 13;
/** Type: object array. */
private const int EchoTypeObjArray = 14;
- /** Type: portable object array. */
- private const int EchoTypePortableArray = 15;
+ /** Type: binary object array. */
+ private const int EchoTypeBinarizableArray = 15;
/** Type: enum. */
private const int EchoTypeEnum = 16;
@@ -799,34 +799,34 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test echo task returning portable object.
+ /// Test echo task returning binary object.
/// </summary>
[Test]
- public void TestEchoTaskPortable()
+ public void TestEchoTaskBinarizable()
{
- PlatformComputePortable res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable>(EchoTask, EchoTypePortable);
+ var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputeBinarizable>(EchoTask, EchoTypeBinarizable);
Assert.AreEqual(1, res.Field);
}
/// <summary>
- /// Test echo task returning portable object with no corresponding class definition.
+ /// Test echo task returning binary object with no corresponding class definition.
/// </summary>
[Test]
- public void TestEchoTaskPortableNoClass()
+ public void TestEchoTaskBinarizableNoClass()
{
ICompute compute = _grid1.GetCompute();
compute.WithKeepBinary();
- IBinaryObject res = compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypePortableJava);
+ IBinaryObject res = compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava);
Assert.AreEqual(1, res.GetField<int>("field"));
- // This call must fail because "keepPortable" flag is reset.
+ // This call must fail because "keepBinary" flag is reset.
Assert.Catch(typeof(BinaryObjectException), () =>
{
- compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypePortableJava);
+ compute.ExecuteJavaTask<IBinaryObject>(EchoTask, EchoTypeBinarizableJava);
});
}
@@ -842,17 +842,17 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Tests the echo task returning portable array.
+ /// Tests the echo task returning binary array.
/// </summary>
[Test]
- public void TestEchoTaskPortableArray()
+ public void TestEchoTaskBinarizableArray()
{
- var res = _grid1.GetCompute().ExecuteJavaTask<object[]>(EchoTask, EchoTypePortableArray);
+ var res = _grid1.GetCompute().ExecuteJavaTask<object[]>(EchoTask, EchoTypeBinarizableArray);
Assert.AreEqual(3, res.Length);
for (var i = 0; i < res.Length; i++)
- Assert.AreEqual(i + 1, ((PlatformComputePortable) res[i]).Field);
+ Assert.AreEqual(i + 1, ((PlatformComputeBinarizable) res[i]).Field);
}
/// <summary>
@@ -883,20 +883,20 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test for portable argument in Java.
+ /// Test for binary argument in Java.
/// </summary>
[Test]
- public void TestPortableArgTask()
+ public void TestBinarizableArgTask()
{
ICompute compute = _grid1.GetCompute();
compute.WithKeepBinary();
- PlatformComputeNetPortable arg = new PlatformComputeNetPortable();
+ PlatformComputeNetBinarizable arg = new PlatformComputeNetBinarizable();
arg.Field = 100;
- int res = compute.ExecuteJavaTask<int>(PortableArgTask, arg);
+ int res = compute.ExecuteJavaTask<int>(BinaryArgTask, arg);
Assert.AreEqual(arg.Field, res);
}
@@ -1109,9 +1109,9 @@ namespace Apache.Ignite.Core.Tests.Compute
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputePortable)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputeNetPortable)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(JavaPortableCls));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputeBinarizable)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PlatformComputeNetBinarizable)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(JavaBinaryCls));
portCfg.TypeConfigurations = portTypeCfgs;
@@ -1127,7 +1127,7 @@ namespace Apache.Ignite.Core.Tests.Compute
}
}
- class PlatformComputePortable
+ class PlatformComputeBinarizable
{
public int Field
{
@@ -1136,7 +1136,7 @@ namespace Apache.Ignite.Core.Tests.Compute
}
}
- class PlatformComputeNetPortable : PlatformComputePortable
+ class PlatformComputeNetBinarizable : PlatformComputeBinarizable
{
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
index 044b5a6..34a1573 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
@@ -73,10 +73,10 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test for GridComputeJobFailoverException with portable job.
+ /// Test for GridComputeJobFailoverException with binary job.
/// </summary>
[Test]
- public void TestTaskAdapterFailoverExceptionPortable()
+ public void TestTaskAdapterFailoverExceptionBinarizable()
{
TestTaskAdapterFailoverException(false);
}
@@ -111,9 +111,9 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestPortableJob)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestBinarizableJob)));
}
/// <summary>
@@ -138,7 +138,7 @@ namespace Apache.Ignite.Core.Tests.Compute
if (serializable)
job = new TestSerializableJob();
else
- job = new TestPortableJob();
+ job = new TestBinarizableJob();
foreach (IClusterNode node in subgrid) {
bool add = local ? node.IsLocal : !node.IsLocal;
@@ -172,7 +172,7 @@ namespace Apache.Ignite.Core.Tests.Compute
class TestClosure : IComputeFunc<int>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
public int Invoke()
@@ -188,7 +188,7 @@ namespace Apache.Ignite.Core.Tests.Compute
class TestSerializableJob : IComputeJob<int>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
public int Execute()
@@ -206,10 +206,10 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
///
/// </summary>
- class TestPortableJob : IComputeJob<int>
+ class TestBinarizableJob : IComputeJob<int>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
public int Execute()
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs
new file mode 100644
index 0000000..315bbbe
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedBinarizableClosureTaskTest.cs
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Compute.Forked
+{
+ /// <summary>
+ /// Forked closure execution tests for binary objects.
+ /// </summary>
+ public class ForkedBinarizableClosureTaskTest : BinarizableClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public ForkedBinarizableClosureTaskTest() : base(true) { }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
deleted file mode 100644
index 4ce917b..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedPortableClosureTaskTest.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute.Forked
-{
- /// <summary>
- /// Forked closure execution tests for portable objects.
- /// </summary>
- public class ForkedPortableClosureTaskTest : PortableClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public ForkedPortableClosureTaskTest() : base(true) { }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
index 84c1ba2..a16db03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedResourceTaskTest.cs
@@ -17,12 +17,9 @@
namespace Apache.Ignite.Core.Tests.Compute.Forked
{
- using NUnit.Framework;
-
/// <summary>
/// Forked resource task test.
/// </summary>
- [Ignore("IGNITE-1381")]
public class ForkedResourceTaskTest : ResourceTaskTest
{
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
index 0324125..c6582ad 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/Forked/ForkedSerializableClosureTaskTest.cs
@@ -17,12 +17,9 @@
namespace Apache.Ignite.Core.Tests.Compute.Forked
{
- using NUnit.Framework;
-
/// <summary>
/// Forked closure execution tests for serializable objects.
/// </summary>
- [Ignore("IGNITE-1381")]
public class ForkedSerializableClosureTaskTest : SerializableClosureTaskTest
{
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
deleted file mode 100644
index bca5ab6..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableClosureTaskTest.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System;
- using System.Collections.Generic;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Compute;
- using NUnit.Framework;
-
- /// <summary>
- /// Closure execution tests for portable objects.
- /// </summary>
- public class PortableClosureTaskTest : ClosureTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public PortableClosureTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected PortableClosureTaskTest(bool fork) : base(fork) { }
-
- /** <inheritDoc /> */
- protected override void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableOutFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableException)));
- }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object> OutFunc(bool err)
- {
- return new PortableOutFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override IComputeFunc<object, object> Func(bool err)
- {
- return new PortableFunc(err);
- }
-
- /** <inheritDoc /> */
- protected override void CheckResult(object res)
- {
- Assert.IsTrue(res != null);
-
- PortableResult res0 = res as PortableResult;
-
- Assert.IsTrue(res0 != null);
- Assert.AreEqual(1, res0.Res);
- }
-
- /** <inheritDoc /> */
- protected override void CheckError(Exception err)
- {
- Assert.IsTrue(err != null);
-
- PortableException err0 = err as PortableException;
-
- Assert.IsTrue(err0 != null);
- Assert.AreEqual(ErrMsg, err0.Msg);
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableOutFunc : IComputeFunc<object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public PortableOutFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public PortableOutFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke()
- {
- if (_err)
- throw new PortableException(ErrMsg);
- return new PortableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableFunc : IComputeFunc<object, object>
- {
- /** Error. */
- private bool _err;
-
- /// <summary>
- ///
- /// </summary>
- public PortableFunc()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="err"></param>
- public PortableFunc(bool err)
- {
- _err = err;
- }
-
- /** <inheritDoc /> */
- public object Invoke(object arg)
- {
- if (_err)
- throw new PortableException(ErrMsg);
- return new PortableResult(1);
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableException : Exception, IBinarizable
- {
- /** */
- public string Msg;
-
- /// <summary>
- ///
- /// </summary>
- public PortableException()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="msg"></param>
- public PortableException(string msg) : this()
- {
- Msg = msg;
- }
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.GetRawWriter().WriteString(Msg);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- Msg = reader.GetRawReader().ReadString();
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- private class PortableResult
- {
- /** */
- public int Res;
-
- /// <summary>
- ///
- /// </summary>
- public PortableResult()
- {
- // No-op.
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="res"></param>
- public PortableResult(int res)
- {
- Res = res;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
deleted file mode 100644
index 40a0f72..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Tests.Compute
-{
- using System.Collections.Generic;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Resource;
- using NUnit.Framework;
-
- /// <summary>
- /// Task test result.
- /// </summary>
- public class PortableTaskTest : AbstractTaskTest
- {
- /// <summary>
- /// Constructor.
- /// </summary>
- public PortableTaskTest() : base(false) { }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="fork">Fork flag.</param>
- protected PortableTaskTest(bool fork) : base(fork) { }
-
- /// <summary>
- /// Test for task result.
- /// </summary>
- [Test]
- public void TestPortableObjectInTask()
- {
- var taskArg = new PortableWrapper {Item = ToPortable(Grid1, new PortableTaskArgument(100))};
-
- TestTask task = new TestTask(Grid1, taskArg);
-
- var res = Grid1.GetCompute().Execute(task, taskArg).Item;
-
- Assert.NotNull(res);
-
- Assert.AreEqual(400, res.GetField<int>("val"));
-
- PortableTaskResult resObj = res.Deserialize<PortableTaskResult>();
-
- Assert.AreEqual(400, resObj.Val);
- }
-
- private static IBinaryObject ToPortable(IIgnite grid, object obj)
- {
- var cache = grid.GetCache<object, object>(Cache1Name).WithKeepBinary<object, object>();
-
- cache.Put(1, obj);
-
- return (IBinaryObject) cache.Get(1);
- }
-
- /** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
- {
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJobArgument)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJobResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTaskArgument)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTaskResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJob)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableWrapper)));
- }
-
- /// <summary>
- /// Test task.
- /// </summary>
- class TestTask : ComputeTaskAdapter<PortableWrapper, PortableWrapper, PortableWrapper>
- {
- /** */
- private readonly IIgnite _grid;
-
- private readonly PortableWrapper _taskArgField;
-
- public TestTask(IIgnite grid, PortableWrapper taskArgField)
- {
- _grid = grid;
- _taskArgField = taskArgField;
- }
-
- /** <inheritDoc /> */
- override public IDictionary<IComputeJob<PortableWrapper>, IClusterNode> Map(IList<IClusterNode> subgrid, PortableWrapper arg)
- {
- Assert.AreEqual(3, subgrid.Count);
- Assert.NotNull(_grid);
-
- var taskArg = arg;
-
- CheckTaskArgument(taskArg);
-
- CheckTaskArgument(_taskArgField);
-
- var jobs = new Dictionary<IComputeJob<PortableWrapper>, IClusterNode>();
-
-
- foreach (IClusterNode node in subgrid)
- {
- if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
- {
- var job = new PortableJob
- {
- Arg = new PortableWrapper {Item = ToPortable(_grid, new PortableJobArgument(200))}
- };
-
- jobs.Add(job, node);
- }
- }
-
- Assert.AreEqual(2, jobs.Count);
-
- return jobs;
- }
-
- private void CheckTaskArgument(PortableWrapper arg)
- {
- Assert.IsNotNull(arg);
-
- var taskArg = arg.Item;
-
- Assert.IsNotNull(taskArg);
-
- Assert.AreEqual(100, taskArg.GetField<int>("val"));
-
- PortableTaskArgument taskArgObj = taskArg.Deserialize<PortableTaskArgument>();
-
- Assert.AreEqual(100, taskArgObj.Val);
- }
-
- /** <inheritDoc /> */
- override public PortableWrapper Reduce(IList<IComputeJobResult<PortableWrapper>> results)
- {
- Assert.NotNull(_grid);
-
- Assert.AreEqual(2, results.Count);
-
- foreach (var res in results)
- {
- var jobRes = res.Data.Item;
-
- Assert.NotNull(jobRes);
-
- Assert.AreEqual(300, jobRes.GetField<int>("val"));
-
- PortableJobResult jobResObj = jobRes.Deserialize<PortableJobResult>();
-
- Assert.AreEqual(300, jobResObj.Val);
- }
-
- return new PortableWrapper {Item = ToPortable(_grid, new PortableTaskResult(400))};
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJobArgument
- {
- /** */
- public int Val;
-
- public PortableJobArgument(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJobResult
- {
- /** */
- public int Val;
-
- public PortableJobResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableTaskArgument
- {
- /** */
- public int Val;
-
- public PortableTaskArgument(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableTaskResult
- {
- /** */
- public int Val;
-
- public PortableTaskResult(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- class PortableJob : IComputeJob<PortableWrapper>
- {
- [InstanceResource]
- private IIgnite _grid = null;
-
- /** */
- public PortableWrapper Arg;
-
- /** <inheritDoc /> */
-
- public PortableWrapper Execute()
- {
- Assert.IsNotNull(Arg);
-
- var arg = Arg.Item;
-
- Assert.IsNotNull(arg);
-
- Assert.AreEqual(200, arg.GetField<int>("val"));
-
- PortableJobArgument argObj = arg.Deserialize<PortableJobArgument>();
-
- Assert.AreEqual(200, argObj.Val);
-
- return new PortableWrapper {Item = ToPortable(_grid, new PortableJobResult(300))};
- }
-
- public void Cancel()
- {
- // No-op.
- }
- }
-
- class PortableWrapper
- {
- public IBinaryObject Item { get; set; }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
index 57e23b8..8418306 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
@@ -88,7 +88,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/// Test for job adapter.
/// </summary>
[Test]
- public void TestPortableJobAdapter()
+ public void TestBinarizableJobAdapter()
{
for (int i = 0; i < 10; i++)
{
@@ -99,9 +99,9 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableJob)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJob)));
}
/// <summary>
@@ -158,7 +158,7 @@ namespace Apache.Ignite.Core.Tests.Compute
if (serializable)
jobs.Add(new SerializableJob(100, "str"));
else
- jobs.Add(new PortableJob(100, "str"));
+ jobs.Add(new BinarizableJob(100, "str"));
return jobs;
}
@@ -236,14 +236,14 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Test portable job.
+ /// Test binary job.
/// </summary>
- public class PortableJob : ComputeJobAdapter<bool>
+ public class BinarizableJob : ComputeJobAdapter<bool>
{
[InstanceResource]
private IIgnite _grid = null;
- public PortableJob(params object[] args) : base(args)
+ public BinarizableJob(params object[] args) : base(args)
{
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
index 20b19a1..4bf1e21 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
@@ -99,19 +99,19 @@ namespace Apache.Ignite.Core.Tests.Compute
/// Test for task result.
/// </summary>
[Test]
- public void TestTaskResultPortable()
+ public void TestTaskResultBinarizable()
{
- TestTask<PortableResult> task = new TestTask<PortableResult>();
+ TestTask<BinarizableResult> task = new TestTask<BinarizableResult>();
- PortableResult val = new PortableResult(100);
+ BinarizableResult val = new BinarizableResult(100);
- PortableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(true, val));
+ BinarizableResult res = Grid1.GetCompute().Execute(task, new Tuple<bool, BinarizableResult>(true, val));
Assert.AreEqual(val.Val, res.Val);
val.Val = 101;
- res = Grid1.GetCompute().Execute(task, new Tuple<bool, PortableResult>(false, val));
+ res = Grid1.GetCompute().Execute(task, new Tuple<bool, BinarizableResult>(false, val));
Assert.AreEqual(val.Val, res.Val);
}
@@ -156,18 +156,18 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override protected void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableResult)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestPortableJob)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableOutFunc)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableResult)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestBinarizableJob)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableOutFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFunc)));
}
[Test]
public void TestOutFuncResultPrimitive1()
{
- ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableOutFunc());
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new BinarizableOutFunc());
Assert.AreEqual(3, res.Count);
@@ -189,7 +189,7 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestFuncResultPrimitive1()
{
- ICollection<int> res = Grid1.GetCompute().Broadcast(new PortableFunc(), 10);
+ ICollection<int> res = Grid1.GetCompute().Broadcast(new BinarizableFunc(), 10);
Assert.AreEqual(3, res.Count);
@@ -216,7 +216,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
/// Test function.
/// </summary>
- public class PortableFunc : IComputeFunc<int, int>, IUserInterface<int, int>
+ public class BinarizableFunc : IComputeFunc<int, int>, IUserInterface<int, int>
{
int IComputeFunc<int, int>.Invoke(int arg)
{
@@ -252,7 +252,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
/// Test function.
/// </summary>
- public class PortableOutFunc : IComputeFunc<int>
+ public class BinarizableOutFunc : IComputeFunc<int>
{
public int Invoke()
{
@@ -291,9 +291,9 @@ namespace Apache.Ignite.Core.Tests.Compute
IComputeJob<T> job;
- if (res is PortableResult)
+ if (res is BinarizableResult)
{
- TestPortableJob job0 = new TestPortableJob();
+ TestBinarizableJob job0 = new TestBinarizableJob();
job0.SetArguments(res);
@@ -365,12 +365,12 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
///
/// </summary>
- class PortableResult
+ class BinarizableResult
{
/** */
public int Val;
- public PortableResult(int val)
+ public BinarizableResult(int val)
{
Val = val;
}
@@ -398,7 +398,7 @@ namespace Apache.Ignite.Core.Tests.Compute
class TestJob<T> : ComputeJobAdapter<T>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
override public T Execute()
@@ -416,19 +416,19 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
///
/// </summary>
- class TestPortableJob : ComputeJobAdapter<PortableResult>
+ class TestBinarizableJob : ComputeJobAdapter<BinarizableResult>
{
[InstanceResource]
- private IIgnite _grid = null;
+ private readonly IIgnite _grid = null;
/** <inheritDoc /> */
- override public PortableResult Execute()
+ override public BinarizableResult Execute()
{
Assert.IsNotNull(_grid);
_gridName = _grid.Name;
- PortableResult res = GetArgument<PortableResult>(0);
+ BinarizableResult res = GetArgument<BinarizableResult>(0);
return res;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
index 0ad0070..e373b89 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
@@ -67,16 +67,16 @@
</bean>
</property>
- <!-- Portable marshaller configuration -->
+ <!-- Binary marshaller configuration -->
<property name="marshaller">
<bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
<property name="typeConfigurations">
<list>
<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputePortable"/>
+ <property name="className" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
</bean>
<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
- <property name="className" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
+ <property name="className" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
</bean>
<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
<property name="className" value="org.apache.ignite.platform.PlatformComputeEnum"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
index 6447b4e..ddedf40 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-standalone.xml
@@ -61,20 +61,20 @@
<list>
<value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfiguration</value>
<value>Apache.Ignite.Core.Tests.ExecutableTest+RemoteConfigurationClosure</value>
- <value>Apache.Ignite.Core.Tests.Compute.TaskAdapterTest+PortableJob</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableOutFunc</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableFunc</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableResult</value>
- <value>Apache.Ignite.Core.Tests.Compute.PortableClosureTaskTest+PortableException</value>
+ <value>Apache.Ignite.Core.Tests.Compute.TaskAdapterTest+BinarizableJob</value>
+ <value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableOutFunc</value>
+ <value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableFunc</value>
+ <value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableResult</value>
+ <value>Apache.Ignite.Core.Tests.Compute.BinarizableClosureTaskTest+BinarizableException</value>
</list>
</property>
<property name="typesConfiguration">
<list>
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration">
- <property name="typeName" value="org.apache.ignite.platform.PlatformComputePortable"/>
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
</bean>
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration">
- <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaPortable"/>
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
</bean>
</list>
</property>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml
new file mode 100644
index 0000000..f013749
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/binary.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="gridName" value="grid"/>
+
+ <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsLogFrequency" value="0"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml
new file mode 100644
index 0000000..a31a450
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-binarizables.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="platformConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
+ <property name="binaryConfiguration">
+ <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
+ <property name="types">
+ <list>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Type]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Collections.Generic.List[System.Tuple[System.Int64,System.String]]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,Apache.Ignite.Core.Tests.TestGenericBinarizable[System.String]]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,System.Type]</value>
+ <value>Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,Apache.Ignite.Core.Tests.TestGenericBinarizable[System.Int64,System.String,System.Type]]</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+
+ <property name="includeEventTypes">
+ <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
+ </property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" />
+ </list>
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47501</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
deleted file mode 100644
index 26bf87b..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-portables.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="platformConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration">
- <property name="binaryConfiguration">
- <bean class="org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration">
- <property name="types">
- <list>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Type]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Collections.Generic.List[System.Tuple[System.Int64,System.String]]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,Apache.Ignite.Core.Tests.TestGenericPortable[System.String]]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]</value>
- <value>Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,Apache.Ignite.Core.Tests.TestGenericPortable[System.Int64,System.String,System.Type]]</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
-
- <property name="includeEventTypes">
- <util:constant static-field="org.apache.ignite.events.EventType.EVTS_CACHE"/>
- </property>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration" />
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47501</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
index 7f9ce40..86a46e4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/cache-query-continuous.xml
@@ -40,7 +40,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
@@ -70,7 +70,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
@@ -100,7 +100,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
@@ -130,7 +130,7 @@
<property name="typeMetadata">
<list>
<bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="PortableEntry"/>
+ <property name="valueType" value="BinarizableEntry"/>
<property name="ascendingFields">
<map>
<entry key="val" value="java.lang.Integer"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
new file mode 100644
index 0000000..11b87bd
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+
+ <property name="marshaller">
+ <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller" />
+ </property>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500..47502</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
deleted file mode 100644
index 753fad1..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-portable.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
index 6845a3c..c2bf78c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
@@ -36,7 +36,7 @@
<property name="cacheConfiguration">
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="portable_store"/>
+ <property name="name" value="binary_store"/>
<property name="cacheMode" value="LOCAL"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeThrough" value="true"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
index c48e867..d8d4553 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache.xml
@@ -139,56 +139,5 @@
<property name="swapEnabled" value="true"/>
<property name="backups" value="1"/>
<property name="eagerTtl" value="true"/>
-
- <!--
- <property name="typeMetadata">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- <property name="textFields">
- <list>
- <value>address</value>
- </list>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridImplicitPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="valueType" value="GridNoDefPortablePerson"/>
- <property name="ascendingFields">
- <map>
- <entry key="age" value="java.lang.Integer"/>
- </map>
- </property>
- <property name="queryFields">
- <map>
- <entry key="name" value="java.lang.String"/>
- </map>
- </property>
- </bean>
- </list>
- </property>
- -->
</bean>
</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
deleted file mode 100644
index f013749..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/portable.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="localHost" value="127.0.0.1"/>
- <property name="connectorConfiguration"><null/></property>
-
- <property name="gridName" value="grid"/>
-
- <property name="metricsUpdateFrequency" value="1000"/>
- <property name="metricsLogFrequency" value="0"/>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="cache"/>
- </bean>
- </list>
- </property>
-
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <!-- In distributed environment, replace with actual host IP address. -->
- <value>127.0.0.1:47500..47502</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
index 2f9f6c9..20ae629 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -383,7 +383,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
[Test]
public void TestStreamReceiver()
{
- TestStreamReceiver(new StreamReceiverPortable());
+ TestStreamReceiver(new StreamReceiverBinarizable());
TestStreamReceiver(new StreamReceiverSerializable());
}
@@ -403,7 +403,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
public void TestStreamTransformer()
{
TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorSerializable()));
- TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorPortable()));
+ TestStreamReceiver(new StreamTransformer<int, int, int, int>(new EntryProcessorBinarizable()));
}
/// <summary>
@@ -415,7 +415,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
{
ldr.AllowOverwrite = true;
- ldr.Receiver = new StreamReceiverPortable();
+ ldr.Receiver = new StreamReceiverBinarizable();
ldr.Receiver = receiver; // check double assignment
@@ -432,23 +432,23 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Tests the stream receiver in keepPortable mode.
+ /// Tests the stream receiver in keepBinary mode.
/// </summary>
[Test]
- public void TestStreamReceiverKeepPortable()
+ public void TestStreamReceiverKeepBinary()
{
// ReSharper disable once LocalVariableHidesMember
- var cache = _grid.GetCache<int, PortableEntry>(CacheName);
+ var cache = _grid.GetCache<int, BinarizableEntry>(CacheName);
using (var ldr0 = _grid.GetDataStreamer<int, int>(CacheName))
using (var ldr = ldr0.WithKeepBinary<int, IBinaryObject>())
{
- ldr.Receiver = new StreamReceiverKeepPortable();
+ ldr.Receiver = new StreamReceiverKeepBinary();
ldr.AllowOverwrite = true;
for (var i = 0; i < 100; i++)
- ldr.AddData(i, _grid.GetBinary().ToBinary<IBinaryObject>(new PortableEntry {Val = i}));
+ ldr.AddData(i, _grid.GetBinary().ToBinary<IBinaryObject>(new BinarizableEntry {Val = i}));
ldr.Flush();
@@ -474,9 +474,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
{
new BinaryTypeConfiguration(typeof (CacheTestKey)),
new BinaryTypeConfiguration(typeof (TestReferenceObject)),
- new BinaryTypeConfiguration(typeof (StreamReceiverPortable)),
- new BinaryTypeConfiguration(typeof (EntryProcessorPortable)),
- new BinaryTypeConfiguration(typeof (PortableEntry))
+ new BinaryTypeConfiguration(typeof (StreamReceiverBinarizable)),
+ new BinaryTypeConfiguration(typeof (EntryProcessorBinarizable)),
+ new BinaryTypeConfiguration(typeof (BinarizableEntry))
}
},
JvmOptions = TestUtils.TestJavaOptions().Concat(new[]
@@ -497,9 +497,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Test portable receiver.
+ /// Test binarizable receiver.
/// </summary>
- private class StreamReceiverPortable : IStreamReceiver<int, int>
+ private class StreamReceiverBinarizable : IStreamReceiver<int, int>
{
/** <inheritdoc /> */
public void Receive(ICache<int, int> cache, ICollection<ICacheEntry<int, int>> entries)
@@ -509,20 +509,20 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Test portable receiver.
+ /// Test binary receiver.
/// </summary>
[Serializable]
- private class StreamReceiverKeepPortable : IStreamReceiver<int, IBinaryObject>
+ private class StreamReceiverKeepBinary : IStreamReceiver<int, IBinaryObject>
{
/** <inheritdoc /> */
public void Receive(ICache<int, IBinaryObject> cache, ICollection<ICacheEntry<int, IBinaryObject>> entries)
{
- var portables = cache.Ignite.GetBinary();
+ var binary = cache.Ignite.GetBinary();
cache.PutAll(entries.ToDictionary(x => x.Key, x =>
- portables.ToBinary<IBinaryObject>(new PortableEntry
+ binary.ToBinary<IBinaryObject>(new BinarizableEntry
{
- Val = x.Value.Deserialize<PortableEntry>().Val + 1
+ Val = x.Value.Deserialize<BinarizableEntry>().Val + 1
})));
}
}
@@ -558,7 +558,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
/// <summary>
/// Test entry processor.
/// </summary>
- private class EntryProcessorPortable : ICacheEntryProcessor<int, int, int, int>, IBinarizable
+ private class EntryProcessorBinarizable : ICacheEntryProcessor<int, int, int, int>, IBinarizable
{
/** <inheritdoc /> */
public int Process(IMutableCacheEntry<int, int> entry, int arg)
@@ -582,9 +582,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
}
/// <summary>
- /// Portablecache entry.
+ /// Binarizable entry.
/// </summary>
- private class PortableEntry
+ private class BinarizableEntry
{
public int Val { get; set; }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index 403f8a7..9f22355 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -365,7 +365,7 @@ namespace Apache.Ignite.Core.Tests
[Test]
public void TestRemoteListen(
[Values(true, false)] bool async,
- [Values(true, false)] bool portable,
+ [Values(true, false)] bool binarizable,
[Values(true, false)] bool autoUnsubscribe)
{
foreach (var g in _grids)
@@ -378,8 +378,8 @@ namespace Apache.Ignite.Core.Tests
var expectedType = EventType.JobStarted;
- var remoteFilter = portable
- ? (IEventFilter<IEvent>) new RemoteEventPortableFilter(expectedType)
+ var remoteFilter = binary
+ ? (IEventFilter<IEvent>) new RemoteEventBinarizableFilter(expectedType)
: new RemoteEventFilter(expectedType);
var localListener = EventsTestHelper.GetListener();
@@ -616,7 +616,7 @@ namespace Apache.Ignite.Core.Tests
{
TypeConfigurations = new List<BinaryTypeConfiguration>
{
- new BinaryTypeConfiguration(typeof (RemoteEventPortableFilter))
+ new BinaryTypeConfiguration(typeof (RemoteEventBinarizableFilter))
}
}
};
@@ -882,18 +882,18 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
- /// Portable remote event filter.
+ /// Binary remote event filter.
/// </summary>
- public class RemoteEventPortableFilter : IEventFilter<IEvent>, IBinarizable
+ public class RemoteEventBinarizableFilter : IEventFilter<IEvent>, IBinarizable
{
/** */
private int _type;
/// <summary>
- /// Initializes a new instance of the <see cref="RemoteEventPortableFilter"/> class.
+ /// Initializes a new instance of the <see cref="RemoteEventBinarizableFilter"/> class.
/// </summary>
/// <param name="type">The event type.</param>
- public RemoteEventPortableFilter(int type)
+ public RemoteEventBinarizableFilter(int type)
{
_type = type;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index 196d8ae..79297da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -107,18 +107,18 @@ namespace Apache.Ignite.Core.Tests
TestPartialUpdateException(false, (x, g) => x);
// User type
- TestPartialUpdateException(false, (x, g) => new PortableEntry(x));
+ TestPartialUpdateException(false, (x, g) => new BinarizableEntry(x));
}
/// <summary>
- /// Tests CachePartialUpdateException keys propagation in portable mode.
+ /// Tests CachePartialUpdateException keys propagation in binary mode.
/// </summary>
[Test]
[Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateExceptionPortable()
+ public void TestPartialUpdateExceptionBinarizable()
{
// User type
- TestPartialUpdateException(false, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new PortableEntry(x)));
+ TestPartialUpdateException(false, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new BinarizableEntry(x)));
}
/// <summary>
@@ -195,17 +195,17 @@ namespace Apache.Ignite.Core.Tests
TestPartialUpdateException(true, (x, g) => x);
// User type
- TestPartialUpdateException(true, (x, g) => new PortableEntry(x));
+ TestPartialUpdateException(true, (x, g) => new BinarizableEntry(x));
}
/// <summary>
- /// Tests CachePartialUpdateException keys propagation in portable mode.
+ /// Tests CachePartialUpdateException keys propagation in binary mode.
/// </summary>
[Test]
[Category(TestUtils.CategoryIntensive)]
- public void TestPartialUpdateExceptionAsyncPortable()
+ public void TestPartialUpdateExceptionAsyncBinarizable()
{
- TestPartialUpdateException(true, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new PortableEntry(x)));
+ TestPartialUpdateException(true, (x, g) => g.GetBinary().ToBinary<IBinaryObject>(new BinarizableEntry(x)));
}
/// <summary>
@@ -295,16 +295,16 @@ namespace Apache.Ignite.Core.Tests
{
TypeConfigurations = new[]
{
- new BinaryTypeConfiguration(typeof (PortableEntry))
+ new BinaryTypeConfiguration(typeof (BinarizableEntry))
}
}
});
}
/// <summary>
- /// Portable entry.
+ /// Binarizable entry.
/// </summary>
- private class PortableEntry
+ private class BinarizableEntry
{
/** Value. */
private readonly int _val;
@@ -319,7 +319,7 @@ namespace Apache.Ignite.Core.Tests
/// Constructor.
/// </summary>
/// <param name="val">Value.</param>
- public PortableEntry(int val)
+ public BinarizableEntry(int val)
{
_val = val;
}
@@ -327,12 +327,12 @@ namespace Apache.Ignite.Core.Tests
/** <inheritDoc /> */
public override bool Equals(object obj)
{
- return obj is PortableEntry && ((PortableEntry)obj)._val == _val;
+ return obj is BinarizableEntry && ((BinarizableEntry)obj)._val == _val;
}
}
/// <summary>
- /// Portable entry.
+ /// Serializable entry.
/// </summary>
[Serializable]
private class SerializableEntry
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
index e32f49a..f18be8c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
@@ -52,7 +52,7 @@ namespace Apache.Ignite.Core.Tests
BinaryConfiguration = new BinaryConfiguration
{
TypeConfigurations =
- new List<BinaryTypeConfiguration> { new BinaryTypeConfiguration(typeof(Portable)) }
+ new List<BinaryTypeConfiguration> { new BinaryTypeConfiguration(typeof(Binarizable)) }
}
});
@@ -107,7 +107,7 @@ namespace Apache.Ignite.Core.Tests
TestType(18m); // decimal
- TestType(new Portable { A = 10, B = "foo" });
+ TestType(new Binarizable { A = 10, B = "foo" });
}
/// <summary>
@@ -123,9 +123,9 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
- /// Portable test class.
+ /// Binary test class.
/// </summary>
- private class Portable : IBinarizable
+ private class Binarizable : IBinarizable
{
public int A;
public string B;
@@ -156,7 +156,7 @@ namespace Apache.Ignite.Core.Tests
if (obj.GetType() != GetType())
return false;
- var other = (Portable)obj;
+ var other = (Binarizable)obj;
return A == other.A && string.Equals(B, other.B);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
index d3af288..541de0c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
@@ -27,7 +27,7 @@ namespace Apache.Ignite.Core.Tests
{
/// <summary>
/// Tests the default marhsaller.
- /// By default, portable marshaller is used.
+ /// By default, binary marshaller is used.
/// </summary>
[Test]
public void TestDefaultMarhsaller()
@@ -43,13 +43,13 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
- /// Tests the portable marhsaller.
- /// PortableMarshaller can be specified explicitly in config.
+ /// Tests the binary marhsaller.
+ /// Marshaller can be specified explicitly in config.
/// </summary>
[Test]
- public void TestPortableMarhsaller()
+ public void TestExplicitMarhsaller()
{
- using (var grid = Ignition.Start("config\\marshaller-portable.xml"))
+ using (var grid = Ignition.Start("config\\marshaller-explicit.xml"))
{
var cache = grid.GetOrCreateCache<int, int>(null);
[17/55] [abbrv] ignite git commit: IGNITE-1816: Implemented compact
footers.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
new file mode 100644
index 0000000..0e31451
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderAdditionalSelfTest.java
@@ -0,0 +1,1291 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
+import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.portable.mutabletest.GridBinaryMarshalerAwareTestClass;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.processors.cache.portable.IgniteBinaryImpl;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Assert;
+
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Address;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.AddressBook;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Company;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectArrayList;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectContainer;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectEnum;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectInner;
+import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectOuter;
+
+/**
+ *
+ */
+public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg = new CacheConfiguration();
+
+ cacheCfg.setCacheMode(REPLICATED);
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setCompactFooter(compactFooter());
+
+ marsh.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
+
+ cfg.setMarshaller(marsh);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrids(1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ jcache(0).clear();
+ }
+
+ /**
+ * @return Compact footer.
+ */
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
+ * @return Portables API.
+ */
+ protected IgniteBinary portables() {
+ return grid(0).binary();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimpleTypeFieldRead() throws Exception {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilder mutPo = wrap(exp);
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
+ Object expVal = field.get(exp);
+ Object actVal = mutPo.getField(field.getName());
+
+ switch (field.getName()) {
+ case "anEnum":
+ assertEquals(((PortableBuilderEnum)actVal).getOrdinal(), ((Enum)expVal).ordinal());
+ break;
+
+ case "enumArr": {
+ PortableBuilderEnum[] actArr = (PortableBuilderEnum[])actVal;
+ Enum[] expArr = (Enum[])expVal;
+
+ assertEquals(expArr.length, actArr.length);
+
+ for (int i = 0; i < actArr.length; i++)
+ assertEquals(expArr[i].ordinal(), actArr[i].getOrdinal());
+
+ break;
+ }
+
+ case "entry":
+ assertEquals(((Map.Entry)expVal).getKey(), ((Map.Entry)actVal).getKey());
+ assertEquals(((Map.Entry)expVal).getValue(), ((Map.Entry)actVal).getValue());
+ break;
+
+ default:
+ assertTrue(field.getName(), Objects.deepEquals(expVal, actVal));
+ break;
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public void testSimpleTypeFieldSerialize() {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilderImpl mutPo = wrap(exp);
+
+ TestObjectAllTypes res = mutPo.build().deserialize();
+
+ GridTestUtils.deepEquals(exp, res);
+ }
+
+ /**
+ * @throws Exception If any error occurs.
+ */
+ public void testSimpleTypeFieldOverride() throws Exception {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilderImpl mutPo = wrap(new TestObjectAllTypes());
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields())
+ mutPo.setField(field.getName(), field.get(exp));
+
+ TestObjectAllTypes res = mutPo.build().deserialize();
+
+ GridTestUtils.deepEquals(exp, res);
+ }
+
+ /**
+ * @throws Exception If any error occurs.
+ */
+ public void testSimpleTypeFieldSetNull() throws Exception {
+ TestObjectAllTypes exp = new TestObjectAllTypes();
+
+ exp.setDefaultData();
+
+ BinaryObjectBuilderImpl mutPo = wrap(exp);
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
+ if (!field.getType().isPrimitive())
+ mutPo.setField(field.getName(), null);
+ }
+
+ TestObjectAllTypes res = mutPo.build().deserialize();
+
+ for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
+ if (!field.getType().isPrimitive())
+ assertNull(field.getName(), field.get(res));
+ }
+ }
+
+ /**
+ * @throws IgniteCheckedException If any error occurs.
+ */
+ public void testMakeCyclicDependency() throws IgniteCheckedException {
+ TestObjectOuter outer = new TestObjectOuter();
+ outer.inner = new TestObjectInner();
+
+ BinaryObjectBuilderImpl mutOuter = wrap(outer);
+
+ BinaryObjectBuilderImpl mutInner = mutOuter.getField("inner");
+
+ mutInner.setField("outer", mutOuter);
+ mutInner.setField("foo", mutInner);
+
+ TestObjectOuter res = mutOuter.build().deserialize();
+
+ assertEquals(res, res.inner.outer);
+ assertEquals(res.inner, res.inner.foo);
+ }
+
+ /**
+ *
+ */
+ public void testDateArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.dateArr = new Date[] {new Date(11111), new Date(11111), new Date(11111)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Date[] arr = mutObj.getField("dateArr");
+ arr[0] = new Date(22222);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Date[] {new Date(22222), new Date(11111), new Date(11111)}, res.dateArr);
+ }
+
+ /**
+ *
+ */
+ public void testTimestampArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.tsArr = new Timestamp[] {new Timestamp(111222333), new Timestamp(222333444)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Timestamp[] arr = mutObj.getField("tsArr");
+ arr[0] = new Timestamp(333444555);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Timestamp[] {new Timestamp(333444555), new Timestamp(222333444)}, res.tsArr);
+ }
+
+ /**
+ *
+ */
+ public void testUUIDArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.uuidArr = new UUID[] {new UUID(1, 1), new UUID(1, 1), new UUID(1, 1)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ UUID[] arr = mutObj.getField("uuidArr");
+ arr[0] = new UUID(2, 2);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new UUID[] {new UUID(2, 2), new UUID(1, 1), new UUID(1, 1)}, res.uuidArr);
+ }
+
+ /**
+ *
+ */
+ public void testDecimalArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.bdArr = new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ BigDecimal[] arr = mutObj.getField("bdArr");
+ arr[0] = new BigDecimal(2000);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)},
+ res.bdArr);
+ }
+
+ /**
+ *
+ */
+ public void testBooleanArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.zArr = new boolean[] {false, false, false};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ boolean[] arr = mutObj.getField("zArr");
+ arr[0] = true;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ boolean[] expected = new boolean[] {true, false, false};
+
+ assertEquals(expected.length, res.zArr.length);
+
+ for (int i = 0; i < expected.length; i++)
+ assertEquals(expected[i], res.zArr[i]);
+ }
+
+ /**
+ *
+ */
+ public void testCharArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.cArr = new char[] {'a', 'a', 'a'};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ char[] arr = mutObj.getField("cArr");
+ arr[0] = 'b';
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new char[] {'b', 'a', 'a'}, res.cArr);
+ }
+
+ /**
+ *
+ */
+ public void testDoubleArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.dArr = new double[] {1.0, 1.0, 1.0};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ double[] arr = mutObj.getField("dArr");
+ arr[0] = 2.0;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new double[] {2.0, 1.0, 1.0}, res.dArr, 0);
+ }
+
+ /**
+ *
+ */
+ public void testFloatArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.fArr = new float[] {1.0f, 1.0f, 1.0f};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ float[] arr = mutObj.getField("fArr");
+ arr[0] = 2.0f;
+
+ BinaryObject resBinary = mutObj.build();
+
+ TestObjectAllTypes res = resBinary.deserialize();
+
+ Assert.assertArrayEquals(new float[] {2.0f, 1.0f, 1.0f}, res.fArr, 0);
+ }
+
+ /**
+ *
+ */
+ public void testLongArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.lArr = new long[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ long[] arr = mutObj.getField("lArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new long[] {2, 1, 1}, res.lArr);
+ }
+
+ /**
+ *
+ */
+ public void testIntArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.iArr = new int[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ int[] arr = mutObj.getField("iArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new int[] {2, 1, 1}, res.iArr);
+ }
+
+ /**
+ *
+ */
+ public void testShortArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.sArr = new short[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ short[] arr = mutObj.getField("sArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new short[] {2, 1, 1}, res.sArr);
+ }
+
+ /**
+ *
+ */
+ public void testByteArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.bArr = new byte[] {1, 1, 1};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ byte[] arr = mutObj.getField("bArr");
+ arr[0] = 2;
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new byte[] {2, 1, 1}, res.bArr);
+ }
+
+ /**
+ *
+ */
+ public void testStringArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.strArr = new String[] {"a", "a", "a"};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ String[] arr = mutObj.getField("strArr");
+ arr[0] = "b";
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new String[] {"b", "a", "a"}, res.strArr);
+ }
+
+ /**
+ *
+ */
+ public void testModifyObjectArray() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = new Object[] {"a"};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Object[] arr = mutObj.getField("foo");
+
+ Assert.assertArrayEquals(new Object[] {"a"}, arr);
+
+ arr[0] = "b";
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Object[] {"b"}, (Object[])res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testOverrideObjectArrayField() {
+ BinaryObjectBuilderImpl mutObj = wrap(new TestObjectContainer());
+
+ Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
+
+ mutObj.setField("foo", createdArr.clone());
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ createdArr[0] = res;
+
+ assertTrue(Objects.deepEquals(createdArr, res.foo));
+ }
+
+ /**
+ *
+ */
+ public void testDeepArray() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = new Object[] {new Object[] {"a", obj}};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Object[] arr = (Object[])mutObj.<Object[]>getField("foo")[0];
+
+ assertEquals("a", arr[0]);
+ assertSame(mutObj, arr[1]);
+
+ arr[0] = mutObj;
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ arr = (Object[])((Object[])res.foo)[0];
+
+ assertSame(arr[0], res);
+ assertSame(arr[0], arr[1]);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList(obj, "a");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<Object> list = mutObj.getField("foo");
+
+ assert list.equals(Lists.newArrayList(mutObj, "a"));
+ }
+
+ /**
+ *
+ */
+ public void testArrayListOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ ArrayList<Object> list = Lists.newArrayList(mutObj, "a", Lists.newArrayList(1, 2));
+
+ mutObj.setField("foo", list);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ list.set(0, res);
+
+ assertNotSame(list, res.foo);
+ assertEquals(list, res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList("a", "b", "c");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<String> list = mutObj.getField("foo");
+
+ list.add("!"); // "a", "b", "c", "!"
+ list.add(0, "_"); // "_", "a", "b", "c", "!"
+
+ String s = list.remove(1); // "_", "b", "c", "!"
+ assertEquals("a", s);
+
+ assertEquals(Arrays.asList("c", "!"), list.subList(2, 4));
+ assertEquals(1, list.indexOf("b"));
+ assertEquals(1, list.lastIndexOf("b"));
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertTrue(res.foo instanceof ArrayList);
+ assertEquals(Arrays.asList("_", "b", "c", "!"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListClear() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList("a", "b", "c");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<String> list = mutObj.getField("foo");
+
+ list.clear();
+
+ assertEquals(Collections.emptyList(), mutObj.build().<TestObjectContainer>deserialize().foo);
+ }
+
+ /**
+ *
+ */
+ public void testArrayListWriteUnmodifiable() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ ArrayList<Object> src = Lists.newArrayList(obj, "a", "b", "c");
+
+ obj.foo = src;
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ TestObjectContainer deserialized = mutObj.build().deserialize();
+
+ List<Object> res = (List<Object>)deserialized.foo;
+
+ src.set(0, deserialized);
+
+ assertEquals(src, res);
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newLinkedList(Arrays.asList(obj, "a"));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<Object> list = mutObj.getField("foo");
+
+ assert list.equals(Lists.newLinkedList(Arrays.asList(mutObj, "a")));
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<Object> list = Lists.newLinkedList(Arrays.asList(mutObj, "a", Lists.newLinkedList(Arrays.asList(1, 2))));
+
+ mutObj.setField("foo", list);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ list.set(0, res);
+
+ assertNotSame(list, res.foo);
+ assertEquals(list, res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newLinkedList(Arrays.asList("a", "b", "c"));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ List<String> list = mutObj.getField("foo");
+
+ list.add("!"); // "a", "b", "c", "!"
+ list.add(0, "_"); // "_", "a", "b", "c", "!"
+
+ String s = list.remove(1); // "_", "b", "c", "!"
+ assertEquals("a", s);
+
+ assertEquals(Arrays.asList("c", "!"), list.subList(2, 4));
+ assertEquals(1, list.indexOf("b"));
+ assertEquals(1, list.lastIndexOf("b"));
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertTrue(res.foo instanceof LinkedList);
+ assertEquals(Arrays.asList("_", "b", "c", "!"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testLinkedListWriteUnmodifiable() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ LinkedList<Object> src = Lists.newLinkedList(Arrays.asList(obj, "a", "b", "c"));
+
+ obj.foo = src;
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ TestObjectContainer deserialized = mutObj.build().deserialize();
+
+ List<Object> res = (List<Object>)deserialized.foo;
+
+ src.set(0, deserialized);
+
+ assertEquals(src, res);
+ }
+
+ /**
+ *
+ */
+ public void testHashSetRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Sets.newHashSet(obj, "a");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Set<Object> set = mutObj.getField("foo");
+
+ assert set.equals(Sets.newHashSet(mutObj, "a"));
+ }
+
+ /**
+ *
+ */
+ public void testHashSetOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Set<Object> c = Sets.newHashSet(mutObj, "a", Sets.newHashSet(1, 2));
+
+ mutObj.setField("foo", c);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ c.remove(mutObj);
+ c.add(res);
+
+ assertNotSame(c, res.foo);
+ assertEquals(c, res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testHashSetModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Sets.newHashSet("a", "b", "c");
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Set<String> set = mutObj.getField("foo");
+
+ set.remove("b");
+ set.add("!");
+
+ assertEquals(Sets.newHashSet("a", "!", "c"), set);
+ assertTrue(set.contains("a"));
+ assertTrue(set.contains("!"));
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertTrue(res.foo instanceof HashSet);
+ assertEquals(Sets.newHashSet("a", "!", "c"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testHashSetWriteUnmodifiable() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ Set<Object> src = Sets.newHashSet(obj, "a", "b", "c");
+
+ obj.foo = src;
+
+ TestObjectContainer deserialized = wrap(obj).build().deserialize();
+
+ Set<Object> res = (Set<Object>)deserialized.foo;
+
+ src.remove(obj);
+ src.add(deserialized);
+
+ assertEquals(src, res);
+ }
+
+ /**
+ *
+ */
+ public void testMapRead() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Maps.newHashMap(ImmutableMap.of(obj, "a", "b", obj));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Map<Object, Object> map = mutObj.getField("foo");
+
+ assert map.equals(ImmutableMap.of(mutObj, "a", "b", mutObj));
+ }
+
+ /**
+ *
+ */
+ public void testMapOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Map<Object, Object> map = Maps.newHashMap(ImmutableMap.of(mutObj, "a", "b", mutObj));
+
+ mutObj.setField("foo", map);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertEquals(ImmutableMap.of(res, "a", "b", res), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMapModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Maps.newHashMap(ImmutableMap.of(1, "a", 2, "b"));
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ Map<Object, Object> map = mutObj.getField("foo");
+
+ map.put(3, mutObj);
+ Object rmv = map.remove(1);
+
+ assertEquals("a", rmv);
+
+ TestObjectContainer res = mutObj.build().deserialize();
+
+ assertEquals(ImmutableMap.of(2, "b", 3, res), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testEnumArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.enumArr = new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B};
+
+ BinaryObjectBuilderImpl mutObj = wrap(obj);
+
+ PortableBuilderEnum[] arr = mutObj.getField("enumArr");
+ arr[0] = new PortableBuilderEnum(mutObj.typeId(), TestObjectEnum.B);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B}, res.enumArr);
+ }
+
+ /**
+ *
+ */
+ public void testEditObjectWithRawData() {
+ GridBinaryMarshalerAwareTestClass obj = new GridBinaryMarshalerAwareTestClass();
+
+ obj.s = "a";
+ obj.sRaw = "aa";
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ mutableObj.setField("s", "z");
+
+ GridBinaryMarshalerAwareTestClass res = mutableObj.build().deserialize();
+ assertEquals("z", res.s);
+ assertEquals("aa", res.sRaw);
+ }
+
+ /**
+ *
+ */
+ public void testHashCode() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(obj.hashCode(), mutableObj.build().hashCode());
+
+ mutableObj.hashCode(25);
+
+ assertEquals(25, mutableObj.build().hashCode());
+ }
+
+ /**
+ *
+ */
+ public void testCollectionsInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = Lists.newArrayList(
+ Lists.newArrayList(1, 2),
+ Lists.newLinkedList(Arrays.asList(1, 2)),
+ Sets.newHashSet("a", "b"),
+ Sets.newLinkedHashSet(Arrays.asList("a", "b")),
+ Maps.newHashMap(ImmutableMap.of(1, "a", 2, "b")));
+
+ TestObjectContainer deserialized = wrap(obj).build().deserialize();
+
+ assertEquals(obj.foo, deserialized.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMapEntryModification() {
+ TestObjectContainer obj = new TestObjectContainer();
+ obj.foo = ImmutableMap.of(1, "a").entrySet().iterator().next();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ Map.Entry<Object, Object> entry = mutableObj.getField("foo");
+
+ assertEquals(1, entry.getKey());
+ assertEquals("a", entry.getValue());
+
+ entry.setValue("b");
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(new GridMapEntry<>(1, "b"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMapEntryOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ mutableObj.setField("foo", new GridMapEntry<>(1, "a"));
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(new GridMapEntry<>(1, "a"), res.foo);
+ }
+
+ /**
+ *
+ */
+ public void testMetadataChangingDoublePut() {
+ BinaryObjectBuilderImpl mutableObj = wrap(new TestObjectContainer());
+
+ mutableObj.setField("xx567", "a");
+ mutableObj.setField("xx567", "b");
+
+ mutableObj.build();
+
+ BinaryType metadata = portables().metadata(TestObjectContainer.class);
+
+ assertEquals("String", metadata.fieldTypeName("xx567"));
+ }
+
+ /**
+ *
+ */
+ public void testMetadataChangingDoublePut2() {
+ BinaryObjectBuilderImpl mutableObj = wrap(new TestObjectContainer());
+
+ mutableObj.setField("xx567", "a");
+ mutableObj.setField("xx567", "b");
+
+ mutableObj.build();
+
+ BinaryType metadata = portables().metadata(TestObjectContainer.class);
+
+ assertEquals("String", metadata.fieldTypeName("xx567"));
+ }
+
+ /**
+ *
+ */
+ public void testMetadataChanging() {
+ TestObjectContainer c = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(c);
+
+ mutableObj.setField("intField", 1);
+ mutableObj.setField("intArrField", new int[] {1});
+ mutableObj.setField("arrField", new String[] {"1"});
+ mutableObj.setField("strField", "1");
+ mutableObj.setField("colField", Lists.newArrayList("1"));
+ mutableObj.setField("mapField", Maps.newHashMap(ImmutableMap.of(1, "1")));
+ mutableObj.setField("enumField", TestObjectEnum.A);
+ mutableObj.setField("enumArrField", new Enum[] {TestObjectEnum.A});
+
+ mutableObj.build();
+
+ BinaryType metadata = portables().metadata(c.getClass());
+
+ assertTrue(metadata.fieldNames().containsAll(Arrays.asList("intField", "intArrField", "arrField", "strField",
+ "colField", "mapField", "enumField", "enumArrField")));
+
+ assertEquals("int", metadata.fieldTypeName("intField"));
+ assertEquals("int[]", metadata.fieldTypeName("intArrField"));
+ assertEquals("String[]", metadata.fieldTypeName("arrField"));
+ assertEquals("String", metadata.fieldTypeName("strField"));
+ assertEquals("Collection", metadata.fieldTypeName("colField"));
+ assertEquals("Map", metadata.fieldTypeName("mapField"));
+ assertEquals("Enum", metadata.fieldTypeName("enumField"));
+ assertEquals("Enum[]", metadata.fieldTypeName("enumArrField"));
+ }
+
+ /**
+ *
+ */
+ public void testDateInObjectField() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = new Date();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Date.class, mutableObj.getField("foo").getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInObjectField() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = new Timestamp(100020003);
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Timestamp.class, mutableObj.getField("foo").getClass());
+ }
+
+ /**
+ *
+ */
+ public void testDateInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newArrayList(new Date());
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Date.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newArrayList(new Timestamp(100020003));
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ assertEquals(Timestamp.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
+ public void testDateArrayOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ Date[] arr = { new Date() };
+
+ mutableObj.setField("foo", arr);
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(Date[].class, res.foo.getClass());
+ assertTrue(Objects.deepEquals(arr, res.foo));
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
+ public void testTimestampArrayOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl mutableObj = wrap(obj);
+
+ Timestamp[] arr = { new Timestamp(100020003) };
+
+ mutableObj.setField("foo", arr);
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(Timestamp[].class, res.foo.getClass());
+ assertTrue(Objects.deepEquals(arr, res.foo));
+ }
+
+ /**
+ *
+ */
+ public void testChangeMap() {
+ AddressBook addrBook = new AddressBook();
+
+ addrBook.addCompany(new Company(1, "Google inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 53), "occupation"));
+ addrBook.addCompany(new Company(2, "Apple inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 54), "occupation"));
+ addrBook.addCompany(new Company(3, "Microsoft", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 55), "occupation"));
+ addrBook.addCompany(new Company(4, "Oracle", 100, new Address("Saint-Petersburg", "Nevskiy", 1, 1), "occupation"));
+
+ BinaryObjectBuilderImpl mutableObj = wrap(addrBook);
+
+ Map<String, List<BinaryObjectBuilderImpl>> map = mutableObj.getField("companyByStreet");
+
+ List<BinaryObjectBuilderImpl> list = map.get("Torzhkovskya");
+
+ BinaryObjectBuilderImpl company = list.get(0);
+
+ assert "Google inc".equals(company.<String>getField("name"));
+
+ list.remove(0);
+
+ AddressBook res = mutableObj.build().deserialize();
+
+ assertEquals(Arrays.asList("Nevskiy", "Torzhkovskya"), new ArrayList<>(res.getCompanyByStreet().keySet()));
+
+ List<Company> torzhkovskyaCompanies = res.getCompanyByStreet().get("Torzhkovskya");
+
+ assertEquals(2, torzhkovskyaCompanies.size());
+ assertEquals("Apple inc", torzhkovskyaCompanies.get(0).name);
+ }
+
+ /**
+ *
+ */
+ public void testSavingObjectWithNotZeroStart() {
+ TestObjectOuter out = new TestObjectOuter();
+ TestObjectInner inner = new TestObjectInner();
+
+ out.inner = inner;
+ inner.outer = out;
+
+ BinaryObjectBuilderImpl builder = wrap(out);
+
+ BinaryObjectBuilderImpl innerBuilder = builder.getField("inner");
+
+ TestObjectInner res = innerBuilder.build().deserialize();
+
+ assertSame(res, res.outer.inner);
+ }
+
+ /**
+ *
+ */
+ public void testPortableObjectField() {
+ TestObjectContainer container = new TestObjectContainer(toPortable(new TestObjectArrayList()));
+
+ BinaryObjectBuilderImpl wrapper = wrap(container);
+
+ assertTrue(wrapper.getField("foo") instanceof BinaryObject);
+
+ TestObjectContainer deserialized = wrapper.build().deserialize();
+ assertTrue(deserialized.foo instanceof BinaryObject);
+ }
+
+ /**
+ *
+ */
+ public void testAssignPortableObject() {
+ TestObjectContainer container = new TestObjectContainer();
+
+ BinaryObjectBuilderImpl wrapper = wrap(container);
+
+ wrapper.setField("foo", toPortable(new TestObjectArrayList()));
+
+ TestObjectContainer deserialized = wrapper.build().deserialize();
+ assertTrue(deserialized.foo instanceof TestObjectArrayList);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromNewObject() {
+ BinaryObjectBuilderImpl wrapper = newWrapper(TestObjectAllTypes.class);
+
+ wrapper.setField("str", "a");
+
+ wrapper.removeField("str");
+
+ assertNull(wrapper.build().<TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromExistingObject() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+ obj.setDefaultData();
+
+ BinaryObjectBuilderImpl wrapper = wrap(toPortable(obj));
+
+ wrapper.removeField("str");
+
+ assertNull(wrapper.build().<TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ public void testCyclicArrays() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ Object[] arr1 = new Object[1];
+ Object[] arr2 = new Object[] {arr1};
+
+ arr1[0] = arr2;
+
+ obj.foo = arr1;
+
+ TestObjectContainer res = toPortable(obj).deserialize();
+
+ Object[] resArr = (Object[])res.foo;
+
+ assertSame(((Object[])resArr[0])[0], resArr);
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("TypeMayBeWeakened")
+ public void testCyclicArrayList() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ List<Object> arr1 = new ArrayList<>();
+ List<Object> arr2 = new ArrayList<>();
+
+ arr1.add(arr2);
+ arr2.add(arr1);
+
+ obj.foo = arr1;
+
+ TestObjectContainer res = toPortable(obj).deserialize();
+
+ List<?> resArr = (List<?>)res.foo;
+
+ assertSame(((List<Object>)resArr.get(0)).get(0), resArr);
+ }
+
+ /**
+ * @param obj Object.
+ * @return Object in portable format.
+ */
+ private BinaryObject toPortable(Object obj) {
+ return portables().toBinary(obj);
+ }
+
+ /**
+ * @param obj Object.
+ * @return GridMutablePortableObject.
+ */
+ private BinaryObjectBuilderImpl wrap(Object obj) {
+ return BinaryObjectBuilderImpl.wrap(toPortable(obj));
+ }
+
+ /**
+ * @param aCls Class.
+ * @return Wrapper.
+ */
+ private BinaryObjectBuilderImpl newWrapper(Class<?> aCls) {
+ CacheObjectBinaryProcessorImpl processor = (CacheObjectBinaryProcessorImpl)(
+ (IgniteBinaryImpl)portables()).processor();
+
+ return new BinaryObjectBuilderImpl(processor.portableContext(), processor.typeId(aCls.getName()),
+ aCls.getSimpleName());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
new file mode 100644
index 0000000..e88db99
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryObjectBuilderSelfTest.java
@@ -0,0 +1,1066 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
+import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectContainer;
+import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectInner;
+import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectOuter;
+import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectPlainPortable;
+import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import sun.misc.Unsafe;
+
+/**
+ * Portable builder test.
+ */
+public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final Unsafe UNSAFE = GridUnsafe.unsafe();
+
+ /** */
+ protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setCompactFooter(compactFooter());
+
+ marsh.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName(),
+ "org.gridgain.grid.internal.util.portable.mutabletest.*"));
+
+ BinaryTypeConfiguration customIdMapper = new BinaryTypeConfiguration();
+
+ customIdMapper.setClassName(CustomIdMapper.class.getName());
+ customIdMapper.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return ~PortableContext.DFLT_ID_MAPPER.typeId(clsName);
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return typeId + ~PortableContext.DFLT_ID_MAPPER.fieldId(typeId, fieldName);
+ }
+ });
+
+ marsh.setTypeConfigurations(Collections.singleton(customIdMapper));
+
+ cfg.setMarshaller(marsh);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrids(1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @return Whether to use compact footer.
+ */
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
+ *
+ */
+ public void testAllFieldsSerialization() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+ obj.setDefaultData();
+ obj.enumArr = null;
+
+ TestObjectAllTypes deserialized = builder(toPortable(obj)).build().deserialize();
+
+ GridTestUtils.deepEquals(obj, deserialized);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByteField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("byteField", (byte)1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("shortField", (short)1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals((short)1, po.<Short>field("shortField").shortValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("intField", 1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1, po.<Integer>field("intField").intValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("longField", 1L);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1L, po.<Long>field("longField").longValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("floatField", 1.0f);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("doubleField", 1.0d);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("charField", (char)1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals((char)1, po.<Character>field("charField").charValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBooleanField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("booleanField", true);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(po.<Boolean>field("booleanField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDecimalField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("decimalField", BigDecimal.TEN);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(BigDecimal.TEN, po.<String>field("decimalField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStringField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("stringField", "str");
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals("str", po.<String>field("stringField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDateField() throws Exception {
+ Date date = new Date();
+
+ assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampField() throws Exception {
+ Timestamp ts = new Timestamp(new Date().getTime());
+ ts.setNanos(1000);
+
+ assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUuidField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ UUID uuid = UUID.randomUUID();
+
+ builder.setField("uuidField", uuid);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(uuid, po.<UUID>field("uuidField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByteArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("byteArrayField", new byte[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new byte[] {1, 2, 3}, po.<byte[]>field("byteArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("shortArrayField", new short[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new short[] {1, 2, 3}, po.<short[]>field("shortArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("intArrayField", new int[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("intArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("longArrayField", new long[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new long[] {1, 2, 3}, po.<long[]>field("longArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("floatArrayField", new float[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new float[] {1, 2, 3}, po.<float[]>field("floatArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("doubleArrayField", new double[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new double[] {1, 2, 3}, po.<double[]>field("doubleArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("charArrayField", new char[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new char[] {1, 2, 3}, po.<char[]>field("charArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBooleanArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("booleanArrayField", new boolean[] {true, false});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ boolean[] arr = po.field("booleanArrayField");
+
+ assertEquals(2, arr.length);
+
+ assertTrue(arr[0]);
+ assertFalse(arr[1]);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDecimalArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("decimalArrayField", new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN}, po.<String[]>field("decimalArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStringArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("stringArrayField", new String[] {"str1", "str2", "str3"});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new String[] {"str1", "str2", "str3"}, po.<String[]>field("stringArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDateArrayField() throws Exception {
+ Date date1 = new Date();
+ Date date2 = new Date(date1.getTime() + 1000);
+
+ Date[] dateArr = new Date[] { date1, date2 };
+
+ assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampArrayField() throws Exception {
+ Timestamp ts1 = new Timestamp(new Date().getTime());
+ Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
+
+ ts1.setNanos(1000);
+ ts2.setNanos(2000);
+
+ Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
+
+ assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUuidArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID()};
+
+ builder.setField("uuidArrayField", arr);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testObjectField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("objectField", new Value(1));
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testObjectArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("objectArrayField", new Value[] {new Value(1), new Value(2)});
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ Object[] arr = po.field("objectArrayField");
+
+ assertEquals(2, arr.length);
+
+ assertEquals(1, ((BinaryObject)arr[0]).<Value>deserialize().i);
+ assertEquals(2, ((BinaryObject)arr[1]).<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCollectionField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ List<BinaryObject> list = po.field("collectionField");
+
+ assertEquals(2, list.size());
+
+ assertEquals(1, list.get(0).<Value>deserialize().i);
+ assertEquals(2, list.get(1).<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMapField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ Map<BinaryObject, BinaryObject> map = po.field("mapField");
+
+ assertEquals(2, map.size());
+
+ for (Map.Entry<BinaryObject, BinaryObject> e : map.entrySet())
+ assertEquals(e.getKey().<Key>deserialize().i, e.getValue().<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSeveralFields() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("i", 111);
+ builder.setField("f", 111.111f);
+ builder.setField("iArr", new int[] {1, 2, 3});
+ builder.setField("obj", new Key(1));
+ builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ assertEquals("class".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(111, po.<Integer>field("i").intValue());
+ assertEquals(111.111f, po.<Float>field("f").floatValue(), 0);
+ assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("iArr")));
+ assertEquals(1, po.<BinaryObject>field("obj").<Key>deserialize().i);
+
+ List<BinaryObject> list = po.field("col");
+
+ assertEquals(2, list.size());
+
+ assertEquals(1, list.get(0).<Value>deserialize().i);
+ assertEquals(2, list.get(1).<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOffheapPortable() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("i", 111);
+ builder.setField("f", 111.111f);
+ builder.setField("iArr", new int[] {1, 2, 3});
+ builder.setField("obj", new Key(1));
+ builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
+
+ long ptr = UNSAFE.allocateMemory(arr.length + 5);
+
+ try {
+ long ptr0 = ptr;
+
+ UNSAFE.putBoolean(null, ptr0++, false);
+
+ UNSAFE.putInt(ptr0, arr.length);
+
+ UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
+
+ BinaryObject offheapObj = (BinaryObject)
+ ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
+
+ assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
+
+ assertEquals("class".hashCode(), offheapObj.typeId());
+ assertEquals(100, offheapObj.hashCode());
+
+ assertEquals(111, offheapObj.<Integer>field("i").intValue());
+ assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
+ assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
+ assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);
+
+ List<BinaryObject> list = offheapObj.field("col");
+
+ assertEquals(2, list.size());
+
+ assertEquals(1, list.get(0).<Value>deserialize().i);
+ assertEquals(2, list.get(1).<Value>deserialize().i);
+
+ assertEquals(po, offheapObj);
+ assertEquals(offheapObj, po);
+ }
+ finally {
+ UNSAFE.freeMemory(ptr);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBuildAndDeserialize() throws Exception {
+ BinaryObjectBuilder builder = builder(Value.class.getName());
+
+ builder.hashCode(100);
+
+ builder.setField("i", 1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals("value".hashCode(), po.typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1, po.<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMetaData2() throws Exception {
+ BinaryObjectBuilder builder = builder("org.test.MetaTest2");
+
+ builder.setField("objectField", "a", Object.class);
+
+ BinaryObject po = builder.build();
+
+ BinaryType meta = po.type();
+
+ assertEquals("MetaTest2", meta.typeName());
+ assertEquals("Object", meta.fieldTypeName("objectField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMetaData() throws Exception {
+ BinaryObjectBuilder builder = builder("org.test.MetaTest");
+
+ builder.hashCode(100);
+
+ builder.setField("intField", 1);
+ builder.setField("byteArrayField", new byte[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ BinaryType meta = po.type();
+
+ assertEquals("MetaTest", meta.typeName());
+
+ Collection<String> fields = meta.fieldNames();
+
+ assertEquals(2, fields.size());
+
+ assertTrue(fields.contains("intField"));
+ assertTrue(fields.contains("byteArrayField"));
+
+ assertEquals("int", meta.fieldTypeName("intField"));
+ assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
+
+ builder = builder("org.test.MetaTest");
+
+ builder.hashCode(100);
+
+ builder.setField("intField", 2);
+ builder.setField("uuidField", UUID.randomUUID());
+
+ po = builder.build();
+
+ meta = po.type();
+
+ assertEquals("MetaTest", meta.typeName());
+
+ fields = meta.fieldNames();
+
+ assertEquals(3, fields.size());
+
+ assertTrue(fields.contains("intField"));
+ assertTrue(fields.contains("byteArrayField"));
+ assertTrue(fields.contains("uuidField"));
+
+ assertEquals("int", meta.fieldTypeName("intField"));
+ assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
+ assertEquals("UUID", meta.fieldTypeName("uuidField"));
+ }
+
+ /**
+ *
+ */
+ public void testGetFromCopiedObj() {
+ BinaryObject objStr = builder(TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
+
+ BinaryObjectBuilderImpl builder = builder(objStr);
+ assertEquals("aaa", builder.getField("str"));
+
+ builder.setField("str", "bbb");
+ assertEquals("bbb", builder.getField("str"));
+
+ assertNull(builder.getField("i_"));
+ assertEquals("bbb", builder.build().<TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ public void testCopyFromInnerObjects() {
+ ArrayList<Object> list = new ArrayList<>();
+ list.add(new TestObjectAllTypes());
+ list.add(list.get(0));
+
+ TestObjectContainer c = new TestObjectContainer(list);
+
+ BinaryObjectBuilderImpl builder = builder(toPortable(c));
+ builder.<List>getField("foo").add("!!!");
+
+ BinaryObject res = builder.build();
+
+ TestObjectContainer deserialized = res.deserialize();
+
+ List deserializedList = (List)deserialized.foo;
+
+ assertSame(deserializedList.get(0), deserializedList.get(1));
+ assertEquals("!!!", deserializedList.get(2));
+ assertTrue(deserializedList.get(0) instanceof TestObjectAllTypes);
+ }
+
+ /**
+ *
+ */
+ public void testSetPortableObject() {
+ BinaryObject portableObj = builder(TestObjectContainer.class.getName())
+ .setField("foo", toPortable(new TestObjectAllTypes()))
+ .build();
+
+ assertTrue(portableObj.<TestObjectContainer>deserialize().foo instanceof TestObjectAllTypes);
+ }
+
+ /**
+ *
+ */
+ public void testPlainPortableObjectCopyFrom() {
+ TestObjectPlainPortable obj = new TestObjectPlainPortable(toPortable(new TestObjectAllTypes()));
+
+ BinaryObjectBuilderImpl builder = builder(toPortable(obj));
+ assertTrue(builder.getField("plainPortable") instanceof BinaryObject);
+
+ TestObjectPlainPortable deserialized = builder.build().deserialize();
+ assertTrue(deserialized.plainPortable instanceof BinaryObject);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromNewObject() {
+ BinaryObjectBuilder builder = builder(TestObjectAllTypes.class.getName());
+
+ builder.setField("str", "a");
+
+ builder.removeField("str");
+
+ assertNull(builder.build().<TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromExistingObject() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+ obj.setDefaultData();
+ obj.enumArr = null;
+
+ BinaryObjectBuilder builder = builder(toPortable(obj));
+
+ builder.removeField("str");
+
+ BinaryObject binary = builder.build();
+
+ TestObjectAllTypes deserialzied = binary.deserialize();
+
+ assertNull(deserialzied.str);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromExistingObjectAfterGet() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+ obj.setDefaultData();
+ obj.enumArr = null;
+
+ BinaryObjectBuilderImpl builder = builder(toPortable(obj));
+
+ builder.getField("i_");
+
+ builder.removeField("str");
+
+ assertNull(builder.build().<TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ * @throws IgniteCheckedException If any error occurs.
+ */
+ public void testDontBrokeCyclicDependency() throws IgniteCheckedException {
+ TestObjectOuter outer = new TestObjectOuter();
+ outer.inner = new TestObjectInner();
+ outer.inner.outer = outer;
+ outer.foo = "a";
+
+ BinaryObjectBuilder builder = builder(toPortable(outer));
+
+ builder.setField("foo", "b");
+
+ TestObjectOuter res = builder.build().deserialize();
+
+ assertEquals("b", res.foo);
+ assertSame(res, res.inner.outer);
+ }
+
+ /**
+ * @return Portables.
+ */
+ private IgniteBinary portables() {
+ return grid(0).binary();
+ }
+
+ /**
+ * @param obj Object.
+ * @return Portable object.
+ */
+ private BinaryObject toPortable(Object obj) {
+ return portables().toBinary(obj);
+ }
+
+ /**
+ * @return Builder.
+ */
+ private <T> BinaryObjectBuilder builder(String clsName) {
+ return portables().builder(clsName);
+ }
+
+ /**
+ * @return Builder.
+ */
+ private <T> BinaryObjectBuilderImpl builder(BinaryObject obj) {
+ return (BinaryObjectBuilderImpl)portables().builder(obj);
+ }
+
+ /**
+ *
+ */
+ private static class CustomIdMapper {
+ /** */
+ private String str = "a";
+
+ /** */
+ private int i = 10;
+ }
+
+ /**
+ */
+ private static class Key {
+ /** */
+ private int i;
+
+ /**
+ */
+ private Key() {
+ // No-op.
+ }
+
+ /**
+ * @param i Index.
+ */
+ private Key(int i) {
+ this.i = i;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Key key = (Key)o;
+
+ return i == key.i;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return i;
+ }
+ }
+
+ /**
+ */
+ private static class Value {
+ /** */
+ private int i;
+
+ /**
+ */
+ private Value() {
+ // No-op.
+ }
+
+ /**
+ * @param i Index.
+ */
+ private Value(int i) {
+ this.i = i;
+ }
+ }
+}
\ No newline at end of file
[21/55] [abbrv] ignite git commit: ignite-1282 - test added
Posted by ag...@apache.org.
ignite-1282 - test added
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7b22f83
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7b22f83
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7b22f83
Branch: refs/heads/ignite-1.5
Commit: a7b22f8387c95931b0aa407eb951b9d2bc54c33c
Parents: 0b4a8f8
Author: S.Vladykin <sv...@gridgain.com>
Authored: Wed Nov 18 20:08:02 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Wed Nov 18 20:08:02 2015 +0300
----------------------------------------------------------------------
.../query/IgniteSqlSplitterSelfTest.java | 54 ++++++++++++++++++++
1 file changed, 54 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7b22f83/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index 75112fd..0868fe6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -227,6 +227,39 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
}
/**
+ *
+ */
+ public void testFunctionNpe() {
+ // TODO IGNITE-1886
+ IgniteCache<Integer, User> userCache = ignite(0).createCache(
+ cacheConfig("UserCache", true, Integer.class, User.class));
+ IgniteCache<Integer, UserOrder> userOrderCache = ignite(0).createCache(
+ cacheConfig("UserOrderCache", true, Integer.class, UserOrder.class));
+ IgniteCache<Integer, OrderGood> orderGoodCache = ignite(0).createCache(
+ cacheConfig("OrderGoodCache", true, Integer.class, OrderGood.class));
+
+ try {
+ String sql =
+ "SELECT a.* FROM (" +
+ "SELECT CASE WHEN u.id < 100 THEN u.id ELSE ug.id END id " +
+ "FROM \"UserCache\".User u, UserOrder ug " +
+ "WHERE u.id = ug.userId" +
+ ") a, (" +
+ "SELECT CASE WHEN og.goodId < 5 THEN 100 ELSE og.goodId END id " +
+ "FROM UserOrder ug, \"OrderGoodCache\".OrderGood og " +
+ "WHERE ug.id = og.orderId) b " +
+ "WHERE a.id = b.id";
+
+ userOrderCache.query(new SqlFieldsQuery(sql)).getAll();
+ }
+ finally {
+ userCache.destroy();
+ userOrderCache.destroy();
+ orderGoodCache.destroy();
+ }
+ }
+
+ /**
* Test value.
*/
private static class GroupIndexTestValue implements Serializable {
@@ -245,4 +278,25 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
this.b = b;
}
}
+
+ private static class User implements Serializable {
+ @QuerySqlField
+ private int id;
+ }
+
+ private static class UserOrder implements Serializable {
+ @QuerySqlField
+ private int id;
+
+ @QuerySqlField
+ private int userId;
+ }
+
+ private static class OrderGood implements Serializable {
+ @QuerySqlField
+ private int orderId;
+
+ @QuerySqlField
+ private int goodId;
+ }
}
\ No newline at end of file
[53/55] [abbrv] ignite git commit: Fixing tests.
Posted by ag...@apache.org.
Fixing tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/802d48b5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/802d48b5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/802d48b5
Branch: refs/heads/ignite-1.5
Commit: 802d48b5e8d3664db6be36f32c5e4c39d8eee966
Parents: 3d8c4c0
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Sat Nov 21 15:01:20 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Sat Nov 21 15:01:20 2015 +0300
----------------------------------------------------------------------
.../resources/META-INF/classnames.properties | 62 +++++++----
.../CacheVersionedEntryAbstractTest.java | 2 +-
.../continuous/GridEventConsumeSelfTest.java | 111 ++++++++++---------
3 files changed, 101 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/802d48b5/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 96be534..8ac3278 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -259,6 +259,8 @@ org.apache.ignite.internal.cluster.IgniteKillTask
org.apache.ignite.internal.cluster.IgniteKillTask$IgniteKillJob
org.apache.ignite.internal.compute.ComputeTaskCancelledCheckedException
org.apache.ignite.internal.compute.ComputeTaskTimeoutCheckedException
+org.apache.ignite.internal.direct.DirectMessageReader$1
+org.apache.ignite.internal.direct.DirectMessageWriter$1
org.apache.ignite.internal.events.DiscoveryCustomEvent
org.apache.ignite.internal.executor.GridExecutorService
org.apache.ignite.internal.executor.GridExecutorService$1
@@ -297,9 +299,10 @@ org.apache.ignite.internal.portable.BinaryObjectEx
org.apache.ignite.internal.portable.BinaryObjectImpl
org.apache.ignite.internal.portable.BinaryObjectOffheapImpl
org.apache.ignite.internal.portable.BinaryReaderExImpl$Flag
-org.apache.ignite.internal.portable.PortableClassDescriptor$Mode
+org.apache.ignite.internal.portable.BinaryWriteMode
org.apache.ignite.internal.portable.PortableContext
org.apache.ignite.internal.portable.PortableSchema
+org.apache.ignite.internal.portable.PortableSchema$Confirmation
org.apache.ignite.internal.portable.builder.PortableLazyMap$1$1$1
org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion
org.apache.ignite.internal.processors.affinity.GridAffinityAssignment
@@ -355,8 +358,7 @@ org.apache.ignite.internal.processors.cache.GridCacheAdapter$67
org.apache.ignite.internal.processors.cache.GridCacheAdapter$67$1
org.apache.ignite.internal.processors.cache.GridCacheAdapter$68
org.apache.ignite.internal.processors.cache.GridCacheAdapter$69
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$7
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$70
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$8
org.apache.ignite.internal.processors.cache.GridCacheAdapter$9
org.apache.ignite.internal.processors.cache.GridCacheAdapter$AsyncOpRetryFuture$1
org.apache.ignite.internal.processors.cache.GridCacheAdapter$AsyncOpRetryFuture$1$1
@@ -526,6 +528,8 @@ org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishR
org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxFinishResponse
org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxMapping
org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest
+org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest$1
+org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest$2
org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareResponse
org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxRemoteAdapter
org.apache.ignite.internal.processors.cache.distributed.GridDistributedUnlockRequest
@@ -537,6 +541,7 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter$5
+org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter$6
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter$PartitionEntryIterator
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry$2
@@ -547,7 +552,6 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartit
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$2
-org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockRequest
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockResponse
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState
@@ -555,6 +559,8 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionsRes
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$10
+org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$10$1
+org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$11
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$4
@@ -563,9 +569,7 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactional
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$7
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$8
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$9
-org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTransactionalCacheAdapter$9$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishFuture$1
-org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishRequest
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxFinishResponse
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal
@@ -578,7 +582,6 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFutu
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$4
-org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture$5
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareResponse
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxRemote
@@ -586,11 +589,13 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnlockRequest
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnreservedPartitionException
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$2
-org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$3$1
+org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture$1
+org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture$2
+org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$10
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$11
@@ -604,6 +609,9 @@ org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomic
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$19
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$2
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$20
+org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$21
+org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$22
+org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$23
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$3
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$4
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$5
@@ -624,14 +632,15 @@ org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomi
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$2
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$3
-org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$5
-org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$6
+org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$4
+org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$5$1
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$7
+org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$8
+org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache$9
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedLockFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedLockFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedLockFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedLockFuture$4
-org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedLockFuture$5
org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedLockFuture$MiniFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysRequest
@@ -645,9 +654,9 @@ org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPar
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$1
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$SupplyContextPhase
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage
@@ -681,7 +690,6 @@ org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapte
org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter$EntrySet$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetFuture$2
-org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetFuture$3
org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetFuture$MiniFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetFuture$MiniFuture$2
org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetFuture$MiniFuture$3
@@ -691,30 +699,27 @@ org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockFuture$2
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockFuture$3
-org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockFuture$4
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockFuture$MiniFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockRequest
org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticSerializableTxPrepareFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticSerializableTxPrepareFuture$2
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticSerializableTxPrepareFuture$3
-org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticSerializableTxPrepareFuture$4
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticSerializableTxPrepareFuture$ClientRemapFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticSerializableTxPrepareFuture$MiniFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticSerializableTxPrepareFuture$MiniFuture$1$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticTxPrepareFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticTxPrepareFuture$2
-org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticTxPrepareFuture$3
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticTxPrepareFuture$MiniFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearOptimisticTxPrepareFutureAdapter$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearPessimisticTxPrepareFuture$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearPessimisticTxPrepareFuture$2
-org.apache.ignite.internal.processors.cache.distributed.near.GridNearPessimisticTxPrepareFuture$3
+org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest
+org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache$2
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture$1
-org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture$2
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishRequest
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishResponse
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal
@@ -725,6 +730,7 @@ org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal$4
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal$5
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal$6
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal$7
+org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal$8
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareFutureAdapter$1
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse
@@ -788,11 +794,16 @@ org.apache.ignite.internal.processors.cache.query.GridCacheQueryType
org.apache.ignite.internal.processors.cache.query.GridCacheSqlIndexMetadata
org.apache.ignite.internal.processors.cache.query.GridCacheSqlMetadata
org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryBatchAck
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryEntry
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryEvent
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$1$1
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$1$2
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$2
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$3
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$DeployableObject
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$1
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$JCacheQueryRemoteFilter
org.apache.ignite.internal.processors.cache.query.jdbc.GridCacheQueryJdbcMetadataTask
org.apache.ignite.internal.processors.cache.query.jdbc.GridCacheQueryJdbcMetadataTask$JdbcDriverMetadataJob
@@ -836,7 +847,7 @@ org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$15
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$2
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$4
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$5
-org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$7
+org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$8
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$9
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$FinishClosure
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$PLC1
@@ -897,6 +908,8 @@ org.apache.ignite.internal.processors.continuous.GridContinuousHandler
org.apache.ignite.internal.processors.continuous.GridContinuousHandler$RegisterStatus
org.apache.ignite.internal.processors.continuous.GridContinuousMessage
org.apache.ignite.internal.processors.continuous.GridContinuousMessageType
+org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$10$1
+org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$9
org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$DiscoveryData
org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$DiscoveryDataItem
org.apache.ignite.internal.processors.continuous.GridContinuousProcessor$LocalRoutineInfo
@@ -924,15 +937,17 @@ org.apache.ignite.internal.processors.datastreamer.DataStreamerResponse
org.apache.ignite.internal.processors.datastreamer.DataStreamerUpdateJob$1
org.apache.ignite.internal.processors.datastructures.CacheDataStructuresCacheKey
org.apache.ignite.internal.processors.datastructures.CacheDataStructuresConfigurationKey
-org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$1
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$10
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$11
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$12
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$13
+org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$14
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$15
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$16
-org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$17
+org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$18
+org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$19
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$2
+org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$20
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$3
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$4
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$5
@@ -974,6 +989,8 @@ org.apache.ignite.internal.processors.datastructures.GridCacheQueueHeader
org.apache.ignite.internal.processors.datastructures.GridCacheQueueHeaderKey
org.apache.ignite.internal.processors.datastructures.GridCacheQueueItemKey
org.apache.ignite.internal.processors.datastructures.GridCacheQueueProxy
+org.apache.ignite.internal.processors.datastructures.GridCacheSemaphoreImpl
+org.apache.ignite.internal.processors.datastructures.GridCacheSemaphoreState
org.apache.ignite.internal.processors.datastructures.GridCacheSetHeader
org.apache.ignite.internal.processors.datastructures.GridCacheSetHeaderKey
org.apache.ignite.internal.processors.datastructures.GridCacheSetImpl$CollocatedItemKey
@@ -1294,6 +1311,7 @@ org.apache.ignite.internal.util.IgniteUtils$6
org.apache.ignite.internal.util.IgniteUtils$7
org.apache.ignite.internal.util.IgniteUtils$8
org.apache.ignite.internal.util.IgniteUtils$9
+org.apache.ignite.internal.util.UUIDCollectionMessage
org.apache.ignite.internal.util.future.GridCompoundFuture$1
org.apache.ignite.internal.util.future.GridCompoundFuture$Listener
org.apache.ignite.internal.util.future.GridEmbeddedFuture$1
@@ -1673,8 +1691,8 @@ org.apache.ignite.spi.collision.priorityqueue.PriorityQueueCollisionSpi$Priority
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$1
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$2$ConnectClosure
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$2$ConnectClosure$1
-org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$7
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$8
+org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$9
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$HandshakeClosure
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$HandshakeMessage
org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi$HandshakeTimeoutException
http://git-wip-us.apache.org/repos/asf/ignite/blob/802d48b5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
index 7e23863..37cf26d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
@@ -155,7 +155,7 @@ public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractS
});
assert ver1.version().compareTo(ver2.version()) < 0;
- assert ver1.updateTime() < ver2.updateTime();
+ assert ver1.updateTime() <= ver2.updateTime();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/802d48b5/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
index 8f5e07b..8f28aef 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
@@ -116,7 +116,7 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
include = true;
- startGridsMultiThreaded(GRID_CNT - 1);
+ startGrids(GRID_CNT - 1);
include = false;
@@ -878,33 +878,37 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testMasterNodeLeave() throws Exception {
- Ignite g = startGrid("anotherGrid");
-
- final UUID nodeId = g.cluster().localNode().id();
final CountDownLatch latch = new CountDownLatch(GRID_CNT);
- for (int i = 0; i < GRID_CNT; i++) {
- grid(i).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- if (nodeId.equals(((DiscoveryEvent) evt).eventNode().id()))
- latch.countDown();
+ Ignite g = startGrid("anotherGrid");
- return true;
- }
- }, EVT_NODE_LEFT, EVT_NODE_FAILED);
- }
+ try {
+ final UUID nodeId = g.cluster().localNode().id();
+ for (int i = 0; i < GRID_CNT; i++) {
+ grid(i).events().localListen(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event evt) {
+ if (nodeId.equals(((DiscoveryEvent)evt).eventNode().id()))
+ latch.countDown();
- g.events().remoteListen(
- null,
- new P1<Event>() {
- @Override public boolean apply(Event evt) {
- return true;
- }
- },
- EVTS_ALL
- );
+ return true;
+ }
+ }, EVT_NODE_LEFT, EVT_NODE_FAILED);
+ }
- stopGrid("anotherGrid");
+ g.events().remoteListen(
+ null,
+ new P1<Event>() {
+ @Override public boolean apply(Event evt) {
+ return true;
+ }
+ },
+ EVTS_ALL
+ );
+
+ }
+ finally {
+ stopGrid("anotherGrid");
+ }
assert latch.await(3000, MILLISECONDS);
}
@@ -915,42 +919,47 @@ public class GridEventConsumeSelfTest extends GridCommonAbstractTest {
public void testMasterNodeLeaveNoAutoUnsubscribe() throws Exception {
Ignite g = startGrid("anotherGrid");
- final UUID nodeId = g.cluster().localNode().id();
- final CountDownLatch discoLatch = new CountDownLatch(GRID_CNT);
+ final CountDownLatch discoLatch;
- for (int i = 0; i < GRID_CNT; i++) {
- grid(0).events().localListen(new IgnitePredicate<Event>() {
- @Override public boolean apply(Event evt) {
- if (nodeId.equals(((DiscoveryEvent) evt).eventNode().id()))
- discoLatch.countDown();
+ try {
+ final UUID nodeId = g.cluster().localNode().id();
+ discoLatch = new CountDownLatch(GRID_CNT);
- return true;
- }
- }, EVT_NODE_LEFT);
- }
+ for (int i = 0; i < GRID_CNT; i++) {
+ grid(0).events().localListen(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event evt) {
+ if (nodeId.equals(((DiscoveryEvent) evt).eventNode().id()))
+ discoLatch.countDown();
- consumeLatch = new CountDownLatch(GRID_CNT * 2 + 1);
- consumeCnt = new AtomicInteger();
+ return true;
+ }
+ }, EVT_NODE_LEFT);
+ }
- noAutoUnsubscribe = true;
+ consumeLatch = new CountDownLatch(GRID_CNT * 2 + 1);
+ consumeCnt = new AtomicInteger();
- g.events().remoteListen(
- 1, 0, false,
- null,
- new P1<Event>() {
- @Override public boolean apply(Event evt) {
- consumeLatch.countDown();
- consumeCnt.incrementAndGet();
+ noAutoUnsubscribe = true;
- return true;
- }
- },
- EVT_JOB_STARTED
- );
+ g.events().remoteListen(
+ 1, 0, false,
+ null,
+ new P1<Event>() {
+ @Override public boolean apply(Event evt) {
+ consumeLatch.countDown();
+ consumeCnt.incrementAndGet();
- grid(0).compute().broadcast(F.noop());
+ return true;
+ }
+ },
+ EVT_JOB_STARTED
+ );
- stopGrid("anotherGrid");
+ grid(0).compute().broadcast(F.noop());
+ }
+ finally {
+ stopGrid("anotherGrid");
+ }
discoLatch.await(3000, MILLISECONDS);
[18/55] [abbrv] ignite git commit: IGNITE-1816: Implemented compact
footers.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
new file mode 100644
index 0000000..9809a7e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -0,0 +1,3795 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import junit.framework.Assert;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.MarshallerContextTestImpl;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jsr166.ConcurrentHashMap8;
+import sun.misc.Unsafe;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetSocketAddress;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
+
+import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Portable marshaller tests.
+ */
+@SuppressWarnings({"OverlyStrongTypeCast", "ArrayHashCode", "ConstantConditions"})
+public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final Unsafe UNSAFE = GridUnsafe.unsafe();
+
+ /** */
+ protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNull() throws Exception {
+ assertNull(marshalUnmarshal(null));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByte() throws Exception {
+ assertEquals((byte)100, marshalUnmarshal((byte)100).byteValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShort() throws Exception {
+ assertEquals((short)100, marshalUnmarshal((short)100).shortValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInt() throws Exception {
+ assertEquals(100, marshalUnmarshal(100).intValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLong() throws Exception {
+ assertEquals(100L, marshalUnmarshal(100L).longValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloat() throws Exception {
+ assertEquals(100.001f, marshalUnmarshal(100.001f).floatValue(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDouble() throws Exception {
+ assertEquals(100.001d, marshalUnmarshal(100.001d).doubleValue(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testChar() throws Exception {
+ assertEquals((char)100, marshalUnmarshal((char)100).charValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBoolean() throws Exception {
+ assertEquals(true, marshalUnmarshal(true).booleanValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDecimal() throws Exception {
+ BigDecimal val;
+
+ assertEquals((val = BigDecimal.ZERO), marshalUnmarshal(val));
+ assertEquals((val = BigDecimal.valueOf(Long.MAX_VALUE, 0)), marshalUnmarshal(val));
+ assertEquals((val = BigDecimal.valueOf(Long.MIN_VALUE, 0)), marshalUnmarshal(val));
+ assertEquals((val = BigDecimal.valueOf(Long.MAX_VALUE, 8)), marshalUnmarshal(val));
+ assertEquals((val = BigDecimal.valueOf(Long.MIN_VALUE, 8)), marshalUnmarshal(val));
+
+ assertEquals((val = new BigDecimal(new BigInteger("-79228162514264337593543950336"))), marshalUnmarshal(val));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testString() throws Exception {
+ assertEquals("str", marshalUnmarshal("str"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUuid() throws Exception {
+ UUID uuid = UUID.randomUUID();
+
+ assertEquals(uuid, marshalUnmarshal(uuid));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDate() throws Exception {
+ Date date = new Date();
+
+ Date val = marshalUnmarshal(date);
+
+ assertEquals(date, val);
+ assertEquals(Date.class, val.getClass());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestamp() throws Exception {
+ Timestamp ts = new Timestamp(System.currentTimeMillis());
+
+ ts.setNanos(999999999);
+
+ assertEquals(ts, marshalUnmarshal(ts));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByteArray() throws Exception {
+ byte[] arr = new byte[] {10, 20, 30};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortArray() throws Exception {
+ short[] arr = new short[] {10, 20, 30};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntArray() throws Exception {
+ int[] arr = new int[] {10, 20, 30};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongArray() throws Exception {
+ long[] arr = new long[] {10, 20, 30};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatArray() throws Exception {
+ float[] arr = new float[] {10.1f, 20.1f, 30.1f};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleArray() throws Exception {
+ double[] arr = new double[] {10.1d, 20.1d, 30.1d};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharArray() throws Exception {
+ char[] arr = new char[] {10, 20, 30};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBooleanArray() throws Exception {
+ boolean[] arr = new boolean[] {true, false, true};
+
+ assertBooleanArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDecimalArray() throws Exception {
+ BigDecimal[] arr = new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.TEN } ;
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStringArray() throws Exception {
+ String[] arr = new String[] {"str1", "str2", "str3"};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUuidArray() throws Exception {
+ UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDateArray() throws Exception {
+ Date[] arr = new Date[] {new Date(11111), new Date(22222), new Date(33333)};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testObjectArray() throws Exception {
+ Object[] arr = new Object[] {1, 2, 3};
+
+ assertArrayEquals(arr, marshalUnmarshal(arr));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCollection() throws Exception {
+ testCollection(new ArrayList<Integer>(3));
+ testCollection(new LinkedHashSet<Integer>());
+ testCollection(new HashSet<Integer>());
+ testCollection(new TreeSet<Integer>());
+ testCollection(new ConcurrentSkipListSet<Integer>());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testCollection(Collection<Integer> col) throws Exception {
+ col.add(1);
+ col.add(2);
+ col.add(3);
+
+ assertEquals(col, marshalUnmarshal(col));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMap() throws Exception {
+ testMap(new HashMap<Integer, String>());
+ testMap(new LinkedHashMap());
+ testMap(new TreeMap<Integer, String>());
+ testMap(new ConcurrentHashMap8<Integer, String>());
+ testMap(new ConcurrentHashMap<Integer, String>());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testMap(Map<Integer, String> map) throws Exception {
+ map.put(1, "str1");
+ map.put(2, "str2");
+ map.put(3, "str3");
+
+ assertEquals(map, marshalUnmarshal(map));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMapEntry() throws Exception {
+ Map.Entry<Integer, String> e = new GridMapEntry<>(1, "str1");
+
+ assertEquals(e, marshalUnmarshal(e));
+
+ Map<Integer, String> map = new HashMap<>(1);
+
+ map.put(2, "str2");
+
+ e = F.firstEntry(map);
+
+ Map.Entry<Integer, String> e0 = marshalUnmarshal(e);
+
+ assertEquals(2, e0.getKey().intValue());
+ assertEquals("str2", e0.getValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBinaryObject() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject po0 = marshalUnmarshal(po, marsh);
+
+ assertTrue(po.hasField("b"));
+ assertTrue(po.hasField("s"));
+ assertTrue(po.hasField("i"));
+ assertTrue(po.hasField("l"));
+ assertTrue(po.hasField("f"));
+ assertTrue(po.hasField("d"));
+ assertTrue(po.hasField("c"));
+ assertTrue(po.hasField("bool"));
+
+ assertFalse(po.hasField("no_such_field"));
+
+ assertEquals(obj, po.deserialize());
+ assertEquals(obj, po0.deserialize());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEnum() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setClassNames(Arrays.asList(TestEnum.class.getName()));
+
+ assertEquals(TestEnum.B, marshalUnmarshal(TestEnum.B, marsh));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDateAndTimestampInSingleObject() throws Exception {
+ BinaryTypeConfiguration cfg1 = new BinaryTypeConfiguration(DateClass1.class.getName());
+
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(cfg1));
+
+ Date date = new Date();
+ Timestamp ts = new Timestamp(System.currentTimeMillis());
+
+ DateClass1 obj1 = new DateClass1();
+ obj1.date = date;
+ obj1.ts = ts;
+
+ BinaryObject po1 = marshal(obj1, marsh);
+
+ assertEquals(date, po1.field("date"));
+ assertEquals(Date.class, po1.field("date").getClass());
+ assertEquals(ts, po1.field("ts"));
+ assertEquals(Timestamp.class, po1.field("ts").getClass());
+
+ obj1 = po1.deserialize();
+ assertEquals(date, obj1.date);
+ assertEquals(ts, obj1.ts);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimpleObject() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ assertEquals(obj.hashCode(), po.hashCode());
+
+ assertEquals(obj, po.deserialize());
+
+ assertEquals(obj.b, (byte)po.field("b"));
+ assertEquals(obj.s, (short)po.field("s"));
+ assertEquals(obj.i, (int)po.field("i"));
+ assertEquals(obj.l, (long)po.field("l"));
+ assertEquals(obj.f, (float)po.field("f"), 0);
+ assertEquals(obj.d, (double)po.field("d"), 0);
+ assertEquals(obj.c, (char)po.field("c"));
+ assertEquals(obj.bool, (boolean)po.field("bool"));
+ assertEquals(obj.str, po.field("str"));
+ assertEquals(obj.uuid, po.field("uuid"));
+ assertEquals(obj.date, po.field("date"));
+ assertEquals(Date.class, obj.date.getClass());
+ assertEquals(obj.ts, po.field("ts"));
+ assertArrayEquals(obj.bArr, (byte[])po.field("bArr"));
+ assertArrayEquals(obj.sArr, (short[])po.field("sArr"));
+ assertArrayEquals(obj.iArr, (int[])po.field("iArr"));
+ assertArrayEquals(obj.lArr, (long[])po.field("lArr"));
+ assertArrayEquals(obj.fArr, (float[])po.field("fArr"), 0);
+ assertArrayEquals(obj.dArr, (double[])po.field("dArr"), 0);
+ assertArrayEquals(obj.cArr, (char[])po.field("cArr"));
+ assertBooleanArrayEquals(obj.boolArr, (boolean[])po.field("boolArr"));
+ assertArrayEquals(obj.strArr, (String[])po.field("strArr"));
+ assertArrayEquals(obj.uuidArr, (UUID[])po.field("uuidArr"));
+ assertArrayEquals(obj.dateArr, (Date[])po.field("dateArr"));
+ assertArrayEquals(obj.objArr, (Object[])po.field("objArr"));
+ assertEquals(obj.col, po.field("col"));
+ assertEquals(obj.map, po.field("map"));
+ assertEquals(new Integer(obj.enumVal.ordinal()), new Integer(((Enum<?>)po.field("enumVal")).ordinal()));
+ assertArrayEquals(ordinals(obj.enumArr), ordinals((Enum<?>[])po.field("enumArr")));
+ assertNull(po.field("unknown"));
+
+ BinaryObject innerPo = po.field("inner");
+
+ assertEquals(obj.inner, innerPo.deserialize());
+
+ assertEquals(obj.inner.b, (byte)innerPo.field("b"));
+ assertEquals(obj.inner.s, (short)innerPo.field("s"));
+ assertEquals(obj.inner.i, (int)innerPo.field("i"));
+ assertEquals(obj.inner.l, (long)innerPo.field("l"));
+ assertEquals(obj.inner.f, (float)innerPo.field("f"), 0);
+ assertEquals(obj.inner.d, (double)innerPo.field("d"), 0);
+ assertEquals(obj.inner.c, (char)innerPo.field("c"));
+ assertEquals(obj.inner.bool, (boolean)innerPo.field("bool"));
+ assertEquals(obj.inner.str, innerPo.field("str"));
+ assertEquals(obj.inner.uuid, innerPo.field("uuid"));
+ assertEquals(obj.inner.date, innerPo.field("date"));
+ assertEquals(Date.class, obj.inner.date.getClass());
+ assertEquals(obj.inner.ts, innerPo.field("ts"));
+ assertArrayEquals(obj.inner.bArr, (byte[])innerPo.field("bArr"));
+ assertArrayEquals(obj.inner.sArr, (short[])innerPo.field("sArr"));
+ assertArrayEquals(obj.inner.iArr, (int[])innerPo.field("iArr"));
+ assertArrayEquals(obj.inner.lArr, (long[])innerPo.field("lArr"));
+ assertArrayEquals(obj.inner.fArr, (float[])innerPo.field("fArr"), 0);
+ assertArrayEquals(obj.inner.dArr, (double[])innerPo.field("dArr"), 0);
+ assertArrayEquals(obj.inner.cArr, (char[])innerPo.field("cArr"));
+ assertBooleanArrayEquals(obj.inner.boolArr, (boolean[])innerPo.field("boolArr"));
+ assertArrayEquals(obj.inner.strArr, (String[])innerPo.field("strArr"));
+ assertArrayEquals(obj.inner.uuidArr, (UUID[])innerPo.field("uuidArr"));
+ assertArrayEquals(obj.inner.dateArr, (Date[])innerPo.field("dateArr"));
+ assertArrayEquals(obj.inner.objArr, (Object[])innerPo.field("objArr"));
+ assertEquals(obj.inner.col, innerPo.field("col"));
+ assertEquals(obj.inner.map, innerPo.field("map"));
+ assertEquals(new Integer(obj.inner.enumVal.ordinal()),
+ new Integer(((Enum<?>)innerPo.field("enumVal")).ordinal()));
+ assertArrayEquals(ordinals(obj.inner.enumArr), ordinals((Enum<?>[])innerPo.field("enumArr")));
+ assertNull(innerPo.field("inner"));
+ assertNull(innerPo.field("unknown"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortable() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName()),
+ new BinaryTypeConfiguration(TestBinary.class.getName())
+ ));
+
+ TestBinary obj = binaryObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ assertEquals(obj.hashCode(), po.hashCode());
+
+ assertEquals(obj, po.deserialize());
+
+ assertEquals(obj.b, (byte)po.field("_b"));
+ assertEquals(obj.s, (short)po.field("_s"));
+ assertEquals(obj.i, (int)po.field("_i"));
+ assertEquals(obj.l, (long)po.field("_l"));
+ assertEquals(obj.f, (float)po.field("_f"), 0);
+ assertEquals(obj.d, (double)po.field("_d"), 0);
+ assertEquals(obj.c, (char)po.field("_c"));
+ assertEquals(obj.bool, (boolean)po.field("_bool"));
+ assertEquals(obj.str, po.field("_str"));
+ assertEquals(obj.uuid, po.field("_uuid"));
+ assertEquals(obj.date, po.field("_date"));
+ assertEquals(obj.ts, po.field("_ts"));
+ assertArrayEquals(obj.bArr, (byte[])po.field("_bArr"));
+ assertArrayEquals(obj.sArr, (short[])po.field("_sArr"));
+ assertArrayEquals(obj.iArr, (int[])po.field("_iArr"));
+ assertArrayEquals(obj.lArr, (long[])po.field("_lArr"));
+ assertArrayEquals(obj.fArr, (float[])po.field("_fArr"), 0);
+ assertArrayEquals(obj.dArr, (double[])po.field("_dArr"), 0);
+ assertArrayEquals(obj.cArr, (char[])po.field("_cArr"));
+ assertBooleanArrayEquals(obj.boolArr, (boolean[])po.field("_boolArr"));
+ assertArrayEquals(obj.strArr, (String[])po.field("_strArr"));
+ assertArrayEquals(obj.uuidArr, (UUID[])po.field("_uuidArr"));
+ assertArrayEquals(obj.dateArr, (Date[])po.field("_dateArr"));
+ assertArrayEquals(obj.objArr, (Object[])po.field("_objArr"));
+ assertEquals(obj.col, po.field("_col"));
+ assertEquals(obj.map, po.field("_map"));
+ assertEquals(new Integer(obj.enumVal.ordinal()), new Integer(((Enum<?>)po.field("_enumVal")).ordinal()));
+ assertArrayEquals(ordinals(obj.enumArr), ordinals((Enum<?>[])po.field("_enumArr")));
+ assertNull(po.field("unknown"));
+
+ BinaryObject simplePo = po.field("_simple");
+
+ assertEquals(obj.simple, simplePo.deserialize());
+
+ assertEquals(obj.simple.b, (byte)simplePo.field("b"));
+ assertEquals(obj.simple.s, (short)simplePo.field("s"));
+ assertEquals(obj.simple.i, (int)simplePo.field("i"));
+ assertEquals(obj.simple.l, (long)simplePo.field("l"));
+ assertEquals(obj.simple.f, (float)simplePo.field("f"), 0);
+ assertEquals(obj.simple.d, (double)simplePo.field("d"), 0);
+ assertEquals(obj.simple.c, (char)simplePo.field("c"));
+ assertEquals(obj.simple.bool, (boolean)simplePo.field("bool"));
+ assertEquals(obj.simple.str, simplePo.field("str"));
+ assertEquals(obj.simple.uuid, simplePo.field("uuid"));
+ assertEquals(obj.simple.date, simplePo.field("date"));
+ assertEquals(Date.class, obj.simple.date.getClass());
+ assertEquals(obj.simple.ts, simplePo.field("ts"));
+ assertArrayEquals(obj.simple.bArr, (byte[])simplePo.field("bArr"));
+ assertArrayEquals(obj.simple.sArr, (short[])simplePo.field("sArr"));
+ assertArrayEquals(obj.simple.iArr, (int[])simplePo.field("iArr"));
+ assertArrayEquals(obj.simple.lArr, (long[])simplePo.field("lArr"));
+ assertArrayEquals(obj.simple.fArr, (float[])simplePo.field("fArr"), 0);
+ assertArrayEquals(obj.simple.dArr, (double[])simplePo.field("dArr"), 0);
+ assertArrayEquals(obj.simple.cArr, (char[])simplePo.field("cArr"));
+ assertBooleanArrayEquals(obj.simple.boolArr, (boolean[])simplePo.field("boolArr"));
+ assertArrayEquals(obj.simple.strArr, (String[])simplePo.field("strArr"));
+ assertArrayEquals(obj.simple.uuidArr, (UUID[])simplePo.field("uuidArr"));
+ assertArrayEquals(obj.simple.dateArr, (Date[])simplePo.field("dateArr"));
+ assertArrayEquals(obj.simple.objArr, (Object[])simplePo.field("objArr"));
+ assertEquals(obj.simple.col, simplePo.field("col"));
+ assertEquals(obj.simple.map, simplePo.field("map"));
+ assertEquals(new Integer(obj.simple.enumVal.ordinal()),
+ new Integer(((Enum<?>)simplePo.field("enumVal")).ordinal()));
+ assertArrayEquals(ordinals(obj.simple.enumArr), ordinals((Enum<?>[])simplePo.field("enumArr")));
+ assertNull(simplePo.field("simple"));
+ assertNull(simplePo.field("portable"));
+ assertNull(simplePo.field("unknown"));
+
+ BinaryObject portablePo = po.field("_portable");
+
+ assertEquals(obj.portable, portablePo.deserialize());
+
+ assertEquals(obj.portable.b, (byte)portablePo.field("_b"));
+ assertEquals(obj.portable.s, (short)portablePo.field("_s"));
+ assertEquals(obj.portable.i, (int)portablePo.field("_i"));
+ assertEquals(obj.portable.l, (long)portablePo.field("_l"));
+ assertEquals(obj.portable.f, (float)portablePo.field("_f"), 0);
+ assertEquals(obj.portable.d, (double)portablePo.field("_d"), 0);
+ assertEquals(obj.portable.c, (char)portablePo.field("_c"));
+ assertEquals(obj.portable.bool, (boolean)portablePo.field("_bool"));
+ assertEquals(obj.portable.str, portablePo.field("_str"));
+ assertEquals(obj.portable.uuid, portablePo.field("_uuid"));
+ assertEquals(obj.portable.date, portablePo.field("_date"));
+ assertEquals(obj.portable.ts, portablePo.field("_ts"));
+ assertArrayEquals(obj.portable.bArr, (byte[])portablePo.field("_bArr"));
+ assertArrayEquals(obj.portable.sArr, (short[])portablePo.field("_sArr"));
+ assertArrayEquals(obj.portable.iArr, (int[])portablePo.field("_iArr"));
+ assertArrayEquals(obj.portable.lArr, (long[])portablePo.field("_lArr"));
+ assertArrayEquals(obj.portable.fArr, (float[])portablePo.field("_fArr"), 0);
+ assertArrayEquals(obj.portable.dArr, (double[])portablePo.field("_dArr"), 0);
+ assertArrayEquals(obj.portable.cArr, (char[])portablePo.field("_cArr"));
+ assertBooleanArrayEquals(obj.portable.boolArr, (boolean[])portablePo.field("_boolArr"));
+ assertArrayEquals(obj.portable.strArr, (String[])portablePo.field("_strArr"));
+ assertArrayEquals(obj.portable.uuidArr, (UUID[])portablePo.field("_uuidArr"));
+ assertArrayEquals(obj.portable.dateArr, (Date[])portablePo.field("_dateArr"));
+ assertArrayEquals(obj.portable.objArr, (Object[])portablePo.field("_objArr"));
+ assertEquals(obj.portable.col, portablePo.field("_col"));
+ assertEquals(obj.portable.map, portablePo.field("_map"));
+ assertEquals(new Integer(obj.portable.enumVal.ordinal()),
+ new Integer(((Enum<?>)portablePo.field("_enumVal")).ordinal()));
+ assertArrayEquals(ordinals(obj.portable.enumArr), ordinals((Enum<?>[])portablePo.field("_enumArr")));
+ assertNull(portablePo.field("_simple"));
+ assertNull(portablePo.field("_portable"));
+ assertNull(portablePo.field("unknown"));
+ }
+
+ /**
+ * @param obj Simple object.
+ * @param po Portable object.
+ */
+ private void checkSimpleObjectData(SimpleObject obj, BinaryObject po) {
+ assertEquals(obj.b, (byte)po.field("b"));
+ assertEquals(obj.s, (short)po.field("s"));
+ assertEquals(obj.i, (int)po.field("i"));
+ assertEquals(obj.l, (long)po.field("l"));
+ assertEquals(obj.f, (float)po.field("f"), 0);
+ assertEquals(obj.d, (double)po.field("d"), 0);
+ assertEquals(obj.c, (char)po.field("c"));
+ assertEquals(obj.bool, (boolean)po.field("bool"));
+ assertEquals(obj.str, po.field("str"));
+ assertEquals(obj.uuid, po.field("uuid"));
+ assertEquals(obj.date, po.field("date"));
+ assertEquals(Date.class, obj.date.getClass());
+ assertEquals(obj.ts, po.field("ts"));
+ assertArrayEquals(obj.bArr, (byte[])po.field("bArr"));
+ assertArrayEquals(obj.sArr, (short[])po.field("sArr"));
+ assertArrayEquals(obj.iArr, (int[])po.field("iArr"));
+ assertArrayEquals(obj.lArr, (long[])po.field("lArr"));
+ assertArrayEquals(obj.fArr, (float[])po.field("fArr"), 0);
+ assertArrayEquals(obj.dArr, (double[])po.field("dArr"), 0);
+ assertArrayEquals(obj.cArr, (char[])po.field("cArr"));
+ assertBooleanArrayEquals(obj.boolArr, (boolean[])po.field("boolArr"));
+ assertArrayEquals(obj.strArr, (String[])po.field("strArr"));
+ assertArrayEquals(obj.uuidArr, (UUID[])po.field("uuidArr"));
+ assertArrayEquals(obj.dateArr, (Date[])po.field("dateArr"));
+ assertArrayEquals(obj.objArr, (Object[])po.field("objArr"));
+ assertEquals(obj.col, po.field("col"));
+ assertEquals(obj.map, po.field("map"));
+ assertEquals(new Integer(obj.enumVal.ordinal()), new Integer(((Enum<?>)po.field("enumVal")).ordinal()));
+ assertArrayEquals(ordinals(obj.enumArr), ordinals((Enum<?>[])po.field("enumArr")));
+ assertNull(po.field("unknown"));
+
+ assertEquals(obj, po.deserialize());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassWithoutPublicConstructor() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(NoPublicConstructor.class.getName()),
+ new BinaryTypeConfiguration(NoPublicDefaultConstructor.class.getName()),
+ new BinaryTypeConfiguration(ProtectedConstructor.class.getName()))
+ );
+
+ NoPublicConstructor npc = new NoPublicConstructor();
+ BinaryObject npc2 = marshal(npc, marsh);
+
+ assertEquals("test", npc2.<NoPublicConstructor>deserialize().val);
+
+ NoPublicDefaultConstructor npdc = new NoPublicDefaultConstructor(239);
+ BinaryObject npdc2 = marshal(npdc, marsh);
+
+ assertEquals(239, npdc2.<NoPublicDefaultConstructor>deserialize().val);
+
+ ProtectedConstructor pc = new ProtectedConstructor();
+ BinaryObject pc2 = marshal(pc, marsh);
+
+ assertEquals(ProtectedConstructor.class, pc2.<ProtectedConstructor>deserialize().getClass());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCustomSerializer() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ BinaryTypeConfiguration type =
+ new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
+
+ type.setSerializer(new CustomSerializer1());
+
+ marsh.setTypeConfigurations(Arrays.asList(type));
+
+ CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
+
+ BinaryObject po1 = marshal(obj1, marsh);
+
+ assertEquals(20, po1.<CustomSerializedObject1>deserialize().val);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCustomSerializerWithGlobal() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setSerializer(new CustomSerializer1());
+
+ BinaryTypeConfiguration type1 =
+ new BinaryTypeConfiguration(CustomSerializedObject1.class.getName());
+ BinaryTypeConfiguration type2 =
+ new BinaryTypeConfiguration(CustomSerializedObject2.class.getName());
+
+ type2.setSerializer(new CustomSerializer2());
+
+ marsh.setTypeConfigurations(Arrays.asList(type1, type2));
+
+ CustomSerializedObject1 obj1 = new CustomSerializedObject1(10);
+
+ BinaryObject po1 = marshal(obj1, marsh);
+
+ assertEquals(20, po1.<CustomSerializedObject1>deserialize().val);
+
+ CustomSerializedObject2 obj2 = new CustomSerializedObject2(10);
+
+ BinaryObject po2 = marshal(obj2, marsh);
+
+ assertEquals(30, po2.<CustomSerializedObject2>deserialize().val);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCustomIdMapper() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ BinaryTypeConfiguration type =
+ new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
+
+ type.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 11111;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ assert typeId == 11111;
+
+ if ("val1".equals(fieldName))
+ return 22222;
+ else if ("val2".equals(fieldName))
+ return 33333;
+
+ assert false : "Unknown field: " + fieldName;
+
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(type));
+
+ CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str");
+
+ BinaryObjectEx po1 = marshal(obj1, marsh);
+
+ assertEquals(11111, po1.typeId());
+ assertEquals(10, po1.field(22222));
+ assertEquals("str", po1.field(33333));
+
+ assertEquals(10, po1.<CustomMappedObject1>deserialize().val1);
+ assertEquals("str", po1.<CustomMappedObject1>deserialize().val2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCustomIdMapperWithGlobal() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 11111;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ assert typeId == 11111;
+
+ if ("val1".equals(fieldName)) return 22222;
+ else if ("val2".equals(fieldName)) return 33333;
+
+ assert false : "Unknown field: " + fieldName;
+
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration type1 =
+ new BinaryTypeConfiguration(CustomMappedObject1.class.getName());
+ BinaryTypeConfiguration type2 =
+ new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
+
+ type2.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 44444;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ assert typeId == 44444;
+
+ if ("val1".equals(fieldName)) return 55555;
+ else if ("val2".equals(fieldName)) return 66666;
+
+ assert false : "Unknown field: " + fieldName;
+
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(type1, type2));
+
+ CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str1");
+
+ BinaryObjectEx po1 = marshal(obj1, marsh);
+
+ assertEquals(11111, po1.typeId());
+ assertEquals(10, po1.field(22222));
+ assertEquals("str1", po1.field(33333));
+
+ assertEquals(10, po1.<CustomMappedObject1>deserialize().val1);
+ assertEquals("str1", po1.<CustomMappedObject1>deserialize().val2);
+
+ CustomMappedObject2 obj2 = new CustomMappedObject2(20, "str2");
+
+ BinaryObjectEx po2 = marshal(obj2, marsh);
+
+ assertEquals(44444, po2.typeId());
+ assertEquals(20, po2.field(55555));
+ assertEquals("str2", po2.field(66666));
+
+ assertEquals(20, po2.<CustomMappedObject2>deserialize().val1);
+ assertEquals("str2", po2.<CustomMappedObject2>deserialize().val2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDynamicObject() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(DynamicObject.class.getName())
+ ));
+
+ initializePortableContext(marsh);
+
+ BinaryObject po1 = marshal(new DynamicObject(0, 10, 20, 30), marsh);
+
+ assertEquals(new Integer(10), po1.field("val1"));
+ assertEquals(null, po1.field("val2"));
+ assertEquals(null, po1.field("val3"));
+
+ DynamicObject do1 = po1.deserialize();
+
+ assertEquals(10, do1.val1);
+ assertEquals(0, do1.val2);
+ assertEquals(0, do1.val3);
+
+ BinaryObject po2 = marshal(new DynamicObject(1, 10, 20, 30), marsh);
+
+ assertEquals(new Integer(10), po2.field("val1"));
+ assertEquals(new Integer(20), po2.field("val2"));
+ assertEquals(null, po2.field("val3"));
+
+ DynamicObject do2 = po2.deserialize();
+
+ assertEquals(10, do2.val1);
+ assertEquals(20, do2.val2);
+ assertEquals(0, do2.val3);
+
+ BinaryObject po3 = marshal(new DynamicObject(2, 10, 20, 30), marsh);
+
+ assertEquals(new Integer(10), po3.field("val1"));
+ assertEquals(new Integer(20), po3.field("val2"));
+ assertEquals(new Integer(30), po3.field("val3"));
+
+ DynamicObject do3 = po3.deserialize();
+
+ assertEquals(10, do3.val1);
+ assertEquals(20, do3.val2);
+ assertEquals(30, do3.val3);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCycleLink() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(CycleLinkObject.class.getName())
+ ));
+
+ CycleLinkObject obj = new CycleLinkObject();
+
+ obj.self = obj;
+
+ BinaryObject po = marshal(obj, marsh);
+
+ CycleLinkObject obj0 = po.deserialize();
+
+ assert obj0.self == obj0;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDetached() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(DetachedTestObject.class.getName()),
+ new BinaryTypeConfiguration(DetachedInnerTestObject.class.getName())
+ ));
+
+ UUID id = UUID.randomUUID();
+
+ DetachedTestObject obj = marshal(new DetachedTestObject(
+ new DetachedInnerTestObject(null, id)), marsh).deserialize();
+
+ assertEquals(id, obj.inner1.id);
+ assertEquals(id, obj.inner4.id);
+
+ assert obj.inner1 == obj.inner4;
+
+ BinaryObjectImpl innerPo = (BinaryObjectImpl)obj.inner2;
+
+ assert innerPo.detached();
+
+ DetachedInnerTestObject inner = innerPo.deserialize();
+
+ assertEquals(id, inner.id);
+
+ BinaryObjectImpl detachedPo = (BinaryObjectImpl)innerPo.detach();
+
+ assert detachedPo.detached();
+
+ inner = detachedPo.deserialize();
+
+ assertEquals(id, inner.id);
+
+ innerPo = (BinaryObjectImpl)obj.inner3;
+
+ assert innerPo.detached();
+
+ inner = innerPo.deserialize();
+
+ assertEquals(id, inner.id);
+ assertNotNull(inner.inner);
+
+ detachedPo = (BinaryObjectImpl)innerPo.detach();
+
+ assert detachedPo.detached();
+
+ inner = innerPo.deserialize();
+
+ assertEquals(id, inner.id);
+ assertNotNull(inner.inner);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCollectionFields() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(CollectionFieldsObject.class.getName()),
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration(Value.class.getName())
+ ));
+
+ Object[] arr = new Object[] {new Value(1), new Value(2), new Value(3)};
+ Collection<Value> col = Arrays.asList(new Value(4), new Value(5), new Value(6));
+ Map<Key, Value> map = F.asMap(new Key(10), new Value(10), new Key(20), new Value(20), new Key(30), new Value(30));
+
+ CollectionFieldsObject obj = new CollectionFieldsObject(arr, col, map);
+
+ BinaryObject po = marshal(obj, marsh);
+
+ Object[] arr0 = po.field("arr");
+
+ assertEquals(3, arr0.length);
+
+ int i = 1;
+
+ for (Object valPo : arr0)
+ assertEquals(i++, ((BinaryObject)valPo).<Value>deserialize().val);
+
+ Collection<BinaryObject> col0 = po.field("col");
+
+ i = 4;
+
+ for (BinaryObject valPo : col0)
+ assertEquals(i++, valPo.<Value>deserialize().val);
+
+ Map<BinaryObject, BinaryObject> map0 = po.field("map");
+
+ for (Map.Entry<BinaryObject, BinaryObject> e : map0.entrySet())
+ assertEquals(e.getKey().<Key>deserialize().key, e.getValue().<Value>deserialize().val);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ // TODO: Only with full headers.
+ public void _testDefaultMapping() throws Exception {
+ PortableMarshaller marsh1 = createMarshaller();
+
+ BinaryTypeConfiguration customMappingType =
+ new BinaryTypeConfiguration(TestBinary.class.getName());
+
+ customMappingType.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ String typeName;
+
+ try {
+ Method mtd = PortableContext.class.getDeclaredMethod("typeName", String.class);
+
+ mtd.setAccessible(true);
+
+ typeName = (String)mtd.invoke(null, clsName);
+ }
+ catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+
+ return typeName.toLowerCase().hashCode();
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return fieldName.toLowerCase().hashCode();
+ }
+ });
+
+ marsh1.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName()),
+ customMappingType
+ ));
+
+ TestBinary obj = binaryObject();
+
+ BinaryObjectImpl po = marshal(obj, marsh1);
+
+ PortableMarshaller marsh2 = createMarshaller();
+
+ marsh2.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName()),
+ new BinaryTypeConfiguration(TestBinary.class.getName())
+ ));
+
+ PortableContext ctx = initializePortableContext(marsh2);
+
+ po.context(ctx);
+
+ assertEquals(obj, po.deserialize());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeNames() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+ customType1.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 300;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
+
+ customType2.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 400;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
+
+ customType3.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass5");
+
+ customType4.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 0;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+ new BinaryTypeConfiguration("NonExistentClass4"),
+ customType1,
+ customType2,
+ customType3,
+ customType4
+ ));
+
+ PortableContext ctx = initializePortableContext(marsh);
+
+ assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
+ assertEquals("key".hashCode(), ctx.typeId("Key"));
+ assertEquals("nonexistentclass3".hashCode(), ctx.typeId("NonExistentClass3"));
+ assertEquals("nonexistentclass4".hashCode(), ctx.typeId("NonExistentClass4"));
+ assertEquals(300, ctx.typeId(getClass().getSimpleName() + "$Value"));
+ assertEquals(400, ctx.typeId("NonExistentClass1"));
+ assertEquals(500, ctx.typeId("NonExistentClass2"));
+ assertEquals("nonexistentclass5".hashCode(), ctx.typeId("NonExistentClass5"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFieldIdMapping() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+ customType1.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 300;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ switch (fieldName) {
+ case "val1":
+ return 301;
+
+ case "val2":
+ return 302;
+
+ default:
+ return 0;
+ }
+ }
+ });
+
+ BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("NonExistentClass1");
+
+ customType2.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 400;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ switch (fieldName) {
+ case "val1":
+ return 401;
+
+ case "val2":
+ return 402;
+
+ default:
+ return 0;
+ }
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration("NonExistentClass2"),
+ customType1,
+ customType2));
+
+ PortableContext ctx = initializePortableContext(marsh);
+
+ assertEquals("val".hashCode(), ctx.fieldId("key".hashCode(), "val"));
+ assertEquals("val".hashCode(), ctx.fieldId("nonexistentclass2".hashCode(), "val"));
+ assertEquals("val".hashCode(), ctx.fieldId("notconfiguredclass".hashCode(), "val"));
+ assertEquals(301, ctx.fieldId(300, "val1"));
+ assertEquals(302, ctx.fieldId(300, "val2"));
+ assertEquals("val3".hashCode(), ctx.fieldId(300, "val3"));
+ assertEquals(401, ctx.fieldId(400, "val1"));
+ assertEquals(402, ctx.fieldId(400, "val2"));
+ assertEquals("val3".hashCode(), ctx.fieldId(400, "val3"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDuplicateTypeId() throws Exception {
+ final PortableMarshaller marsh = createMarshaller();
+
+ BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration("org.gridgain.Class1");
+
+ customType1.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 100;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.Class2");
+
+ customType2.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 100;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ marsh.setTypeConfigurations(Arrays.asList(customType1, customType2));
+
+ try {
+ initializePortableContext(marsh);
+ }
+ catch (IgniteCheckedException e) {
+ assertEquals("Duplicate type ID [clsName=org.gridgain.Class1, id=100]",
+ e.getCause().getCause().getMessage());
+
+ return;
+ }
+
+ assert false;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopy() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ initializePortableContext(marsh);
+
+ SimpleObject obj = simpleObject();
+
+ final BinaryObject po = marshal(obj, marsh);
+
+ assertEquals(obj, po.deserialize());
+
+ BinaryObject copy = copy(po, null);
+
+ assertEquals(obj, copy.deserialize());
+
+ copy = copy(po, new HashMap<String, Object>());
+
+ assertEquals(obj, copy.deserialize());
+
+ Map<String, Object> map = new HashMap<>(1, 1.0f);
+
+ map.put("i", 3);
+
+ copy = copy(po, map);
+
+ assertEquals((byte)2, copy.<Byte>field("b").byteValue());
+ assertEquals((short)2, copy.<Short>field("s").shortValue());
+ assertEquals(3, copy.<Integer>field("i").intValue());
+ assertEquals(2L, copy.<Long>field("l").longValue());
+ assertEquals(2.2f, copy.<Float>field("f").floatValue(), 0);
+ assertEquals(2.2d, copy.<Double>field("d").doubleValue(), 0);
+ assertEquals((char)2, copy.<Character>field("c").charValue());
+ assertEquals(false, copy.<Boolean>field("bool").booleanValue());
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertEquals((byte)2, obj0.b);
+ assertEquals((short)2, obj0.s);
+ assertEquals(3, obj0.i);
+ assertEquals(2L, obj0.l);
+ assertEquals(2.2f, obj0.f, 0);
+ assertEquals(2.2d, obj0.d, 0);
+ assertEquals((char)2, obj0.c);
+ assertEquals(false, obj0.bool);
+
+ map = new HashMap<>(3, 1.0f);
+
+ map.put("b", (byte)3);
+ map.put("l", 3L);
+ map.put("bool", true);
+
+ copy = copy(po, map);
+
+ assertEquals((byte)3, copy.<Byte>field("b").byteValue());
+ assertEquals((short)2, copy.<Short>field("s").shortValue());
+ assertEquals(2, copy.<Integer>field("i").intValue());
+ assertEquals(3L, copy.<Long>field("l").longValue());
+ assertEquals(2.2f, copy.<Float>field("f").floatValue(), 0);
+ assertEquals(2.2d, copy.<Double>field("d").doubleValue(), 0);
+ assertEquals((char)2, copy.<Character>field("c").charValue());
+ assertEquals(true, copy.<Boolean>field("bool").booleanValue());
+
+ obj0 = copy.deserialize();
+
+ assertEquals((byte)3, obj0.b);
+ assertEquals((short)2, obj0.s);
+ assertEquals(2, obj0.i);
+ assertEquals(3L, obj0.l);
+ assertEquals(2.2f, obj0.f, 0);
+ assertEquals(2.2d, obj0.d, 0);
+ assertEquals((char)2, obj0.c);
+ assertEquals(true, obj0.bool);
+
+ map = new HashMap<>(8, 1.0f);
+
+ map.put("b", (byte)3);
+ map.put("s", (short)3);
+ map.put("i", 3);
+ map.put("l", 3L);
+ map.put("f", 3.3f);
+ map.put("d", 3.3d);
+ map.put("c", (char)3);
+ map.put("bool", true);
+
+ copy = copy(po, map);
+
+ assertEquals((byte)3, copy.<Byte>field("b").byteValue());
+ assertEquals((short)3, copy.<Short>field("s").shortValue());
+ assertEquals(3, copy.<Integer>field("i").intValue());
+ assertEquals(3L, copy.<Long>field("l").longValue());
+ assertEquals(3.3f, copy.<Float>field("f").floatValue(), 0);
+ assertEquals(3.3d, copy.<Double>field("d").doubleValue(), 0);
+ assertEquals((char)3, copy.<Character>field("c").charValue());
+ assertEquals(true, copy.<Boolean>field("bool").booleanValue());
+
+ obj0 = copy.deserialize();
+
+ assertEquals((byte)3, obj0.b);
+ assertEquals((short)3, obj0.s);
+ assertEquals(3, obj0.i);
+ assertEquals(3L, obj0.l);
+ assertEquals(3.3f, obj0.f, 0);
+ assertEquals(3.3d, obj0.d, 0);
+ assertEquals((char)3, obj0.c);
+ assertEquals(true, obj0.bool);
+
+// GridTestUtils.assertThrows(
+// log,
+// new Callable<Object>() {
+// @Override public Object call() throws Exception {
+// po.copy(F.<String, Object>asMap("i", false));
+//
+// return null;
+// }
+// },
+// PortableException.class,
+// "Invalid value type for field: i"
+// );
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyString() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("str", "str3"));
+
+ assertEquals("str3", copy.<String>field("str"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertEquals("str3", obj0.str);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyUuid() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ UUID uuid = UUID.randomUUID();
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("uuid", uuid));
+
+ assertEquals(uuid, copy.<UUID>field("uuid"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertEquals(uuid, obj0.uuid);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyByteArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1, 2, 3}));
+
+ assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new byte[] {1, 2, 3}, obj0.bArr);
+ }
+
+ /**
+ * @param po Portable object.
+ * @param fields Fields.
+ * @return Copy.
+ */
+ private BinaryObject copy(BinaryObject po, Map<String, Object> fields) {
+ BinaryObjectBuilder builder = BinaryObjectBuilderImpl.wrap(po);
+
+ if (fields != null) {
+ for (Map.Entry<String, Object> e : fields.entrySet())
+ builder.setField(e.getKey(), e.getValue());
+ }
+
+ return builder.build();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyShortArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("sArr", new short[]{1, 2, 3}));
+
+ assertArrayEquals(new short[] {1, 2, 3}, copy.<short[]>field("sArr"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new short[] {1, 2, 3}, obj0.sArr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyIntArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("iArr", new int[]{1, 2, 3}));
+
+ assertArrayEquals(new int[] {1, 2, 3}, copy.<int[]>field("iArr"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new int[] {1, 2, 3}, obj0.iArr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyLongArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("lArr", new long[]{1, 2, 3}));
+
+ assertArrayEquals(new long[] {1, 2, 3}, copy.<long[]>field("lArr"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new long[] {1, 2, 3}, obj0.lArr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyFloatArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("fArr", new float[]{1, 2, 3}));
+
+ assertArrayEquals(new float[] {1, 2, 3}, copy.<float[]>field("fArr"), 0);
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new float[] {1, 2, 3}, obj0.fArr, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyDoubleArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("dArr", new double[]{1, 2, 3}));
+
+ assertArrayEquals(new double[] {1, 2, 3}, copy.<double[]>field("dArr"), 0);
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new double[] {1, 2, 3}, obj0.dArr, 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyCharArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("cArr", new char[]{1, 2, 3}));
+
+ assertArrayEquals(new char[]{1, 2, 3}, copy.<char[]>field("cArr"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new char[]{1, 2, 3}, obj0.cArr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyStringArray() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[]{"str1", "str2"}));
+
+ assertArrayEquals(new String[]{"str1", "str2"}, copy.<String[]>field("strArr"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertArrayEquals(new String[]{"str1", "str2"}, obj0.strArr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyObject() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ SimpleObject newObj = new SimpleObject();
+
+ newObj.i = 12345;
+ newObj.fArr = new float[] {5, 8, 0};
+ newObj.str = "newStr";
+
+ BinaryObject copy = copy(po, F.<String, Object>asMap("inner", newObj));
+
+ assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertEquals(newObj, obj0.inner);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyNonPrimitives() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())
+ ));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ Map<String, Object> map = new HashMap<>(3, 1.0f);
+
+ SimpleObject newObj = new SimpleObject();
+
+ newObj.i = 12345;
+ newObj.fArr = new float[] {5, 8, 0};
+ newObj.str = "newStr";
+
+ map.put("str", "str555");
+ map.put("inner", newObj);
+ map.put("bArr", new byte[]{6, 7, 9});
+
+ BinaryObject copy = copy(po, map);
+
+ assertEquals("str555", copy.<String>field("str"));
+ assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
+ assertArrayEquals(new byte[]{6, 7, 9}, copy.<byte[]>field("bArr"));
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertEquals("str555", obj0.str);
+ assertEquals(newObj, obj0.inner);
+ assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPortableCopyMixed() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+
+ SimpleObject obj = simpleObject();
+
+ BinaryObject po = marshal(obj, marsh);
+
+ Map<String, Object> map = new HashMap<>(3, 1.0f);
+
+ SimpleObject newObj = new SimpleObject();
+
+ newObj.i = 12345;
+ newObj.fArr = new float[] {5, 8, 0};
+ newObj.str = "newStr";
+
+ map.put("i", 1234);
+ map.put("str", "str555");
+ map.put("inner", newObj);
+ map.put("s", (short)2323);
+ map.put("bArr", new byte[]{6, 7, 9});
+ map.put("b", (byte)111);
+
+ BinaryObject copy = copy(po, map);
+
+ assertEquals(1234, copy.<Integer>field("i").intValue());
+ assertEquals("str555", copy.<String>field("str"));
+ assertEquals(newObj, copy.<BinaryObject>field("inner").deserialize());
+ assertEquals((short)2323, copy.<Short>field("s").shortValue());
+ assertArrayEquals(new byte[] {6, 7, 9}, copy.<byte[]>field("bArr"));
+ assertEquals((byte)111, copy.<Byte>field("b").byteValue());
+
+ SimpleObject obj0 = copy.deserialize();
+
+ assertEquals(1234, obj0.i);
+ assertEquals("str555", obj0.str);
+ assertEquals(newObj, obj0.inner);
+ assertEquals((short)2323, obj0.s);
+ assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
+ assertEquals((byte)111, obj0.b);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testKeepDeserialized() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
+ marsh.setKeepDeserialized(true);
+
+ BinaryObject po = marshal(simpleObject(), marsh);
+
+ assert po.deserialize() == po.deserialize();
+
+ marsh = createMarshaller();
+
+ marsh.setClassNames(Arrays.asList(SimpleObject.class.getName()));
+ marsh.setKeepDeserialized(false);
+
+ po = marshal(simpleObject(), marsh);
+
+ assert po.deserialize() != po.deserialize();
+
+ marsh = createMarshaller();
+
+ marsh.setKeepDeserialized(true);
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())));
+
+ po = marshal(simpleObject(), marsh);
+
+ assert po.deserialize() == po.deserialize();
+
+ marsh = createMarshaller();
+
+ marsh.setKeepDeserialized(false);
+ marsh.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(SimpleObject.class.getName())));
+
+ po = marshal(simpleObject(), marsh);
+
+ assert po.deserialize() != po.deserialize();
+
+ marsh = createMarshaller();
+
+ marsh.setKeepDeserialized(true);
+
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
+
+ typeCfg.setKeepDeserialized(false);
+
+ marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+
+ po = marshal(simpleObject(), marsh);
+
+ assert po.deserialize() != po.deserialize();
+
+ marsh = createMarshaller();
+
+ marsh.setKeepDeserialized(false);
+
+ typeCfg = new BinaryTypeConfiguration(SimpleObject.class.getName());
+
+ typeCfg.setKeepDeserialized(true);
+
+ marsh.setTypeConfigurations(Arrays.asList(typeCfg));
+
+ po = marshal(simpleObject(), marsh);
+
+ assert po.deserialize() == po.deserialize();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOffheapPortable() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(SimpleObject.class.getName())));
+
+ PortableContext ctx = initializePortableContext(marsh);
+
+ SimpleObject simpleObj = simpleObject();
+
+ BinaryObjectImpl obj = marshal(simpleObj, marsh);
+
+ long ptr = 0;
+
+ long ptr1 = 0;
+
+ long ptr2 = 0;
+
+ try {
+ ptr = copyOffheap(obj);
+
+ BinaryObjectOffheapImpl offheapObj = new BinaryObjectOffheapImpl(ctx,
+ ptr,
+ 0,
+ obj.array().length);
+
+ assertTrue(offheapObj.equals(offheapObj));
+ assertFalse(offheapObj.equals(null));
+ assertFalse(offheapObj.equals("str"));
+ assertTrue(offheapObj.equals(obj));
+ assertTrue(obj.equals(offheapObj));
+
+ ptr1 = copyOffheap(obj);
+
+ BinaryObjectOffheapImpl offheapObj1 = new BinaryObjectOffheapImpl(ctx,
+ ptr1,
+ 0,
+ obj.array().length);
+
+ assertTrue(offheapObj.equals(offheapObj1));
+ assertTrue(offheapObj1.equals(offheapObj));
+
+ assertEquals(obj.typeId(), offheapObj.typeId());
+ assertEquals(obj.hashCode(), offheapObj.hashCode());
+
+ checkSimpleObjectData(simpleObj, offheapObj);
+
+ BinaryObjectOffheapImpl innerOffheapObj = offheapObj.field("inner");
+
+ assertNotNull(innerOffheapObj);
+
+ checkSimpleObjectData(simpleObj.inner, innerOffheapObj);
+
+ obj = (BinaryObjectImpl)offheapObj.heapCopy();
+
+ assertEquals(obj.typeId(), offheapObj.typeId());
+ assertEquals(obj.hashCode(), offheapObj.hashCode());
+
+ checkSimpleObjectData(simpleObj, obj);
+
+ BinaryObjectImpl innerObj = obj.field("inner");
+
+ assertNotNull(innerObj);
+
+ checkSimpleObjectData(simpleObj.inner, innerObj);
+
+ simpleObj.d = 0;
+
+ obj = marshal(simpleObj, marsh);
+
+ assertFalse(offheapObj.equals(obj));
+ assertFalse(obj.equals(offheapObj));
+
+ ptr2 = copyOffheap(obj);
+
+ BinaryObjectOffheapImpl offheapObj2 = new BinaryObjectOffheapImpl(ctx,
+ ptr2,
+ 0,
+ obj.array().length);
+
+ assertFalse(offheapObj.equals(offheapObj2));
+ assertFalse(offheapObj2.equals(offheapObj));
+ }
+ finally {
+ UNSAFE.freeMemory(ptr);
+
+ if (ptr1 > 0)
+ UNSAFE.freeMemory(ptr1);
+
+ if (ptr2 > 0)
+ UNSAFE.freeMemory(ptr2);
+ }
+ }
+
+ /**
+ *
+ */
+ public void testReadResolve() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setClassNames(
+ Arrays.asList(MySingleton.class.getName(), SingletonMarker.class.getName()));
+
+ BinaryObjectImpl portableObj = marshal(MySingleton.INSTANCE, marsh);
+
+ assertTrue(portableObj.array().length <= 1024); // Check that big string was not serialized.
+
+ MySingleton singleton = portableObj.deserialize();
+
+ assertSame(MySingleton.INSTANCE, singleton);
+ }
+
+ /**
+ *
+ */
+ public void testReadResolveOnPortableAware() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setClassNames(Collections.singletonList(MyTestClass.class.getName()));
+
+ BinaryObjectImpl portableObj = marshal(new MyTestClass(), marsh);
+
+ MyTestClass obj = portableObj.deserialize();
+
+ assertEquals("readResolve", obj.s);
+ }
+
+ /**
+ * @throws Exception If ecxeption thrown.
+ */
+ public void testDeclareReadResolveInParent() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.setClassNames(Arrays.asList(ChildPortable.class.getName()));
+
+ BinaryObjectImpl portableObj = marshal(new ChildPortable(), marsh);
+
+ ChildPortable singleton = portableObj.deserialize();
+
+ assertNotNull(singleton.s);
+ }
+
+ /**
+ *
+ */
+ public void testDecimalFields() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ Collection<String> clsNames = new ArrayList<>();
+
+ clsNames.add(DecimalReflective.class.getName());
+ clsNames.add(DecimalMarshalAware.class.getName());
+
+ marsh.setClassNames(clsNames);
+
+ // 1. Test reflective stuff.
+ DecimalReflective obj1 = new DecimalReflective();
+
+ obj1.val = BigDecimal.ZERO;
+ obj1.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN };
+
+ BinaryObjectImpl portObj = marshal(obj1, marsh);
+
+ assertEquals(obj1.val, portObj.field("val"));
+ assertArrayEquals(obj1.valArr, portObj.<BigDecimal[]>field("valArr"));
+
+ assertEquals(obj1.val, portObj.<DecimalReflective>deserialize().val);
+ assertArrayEquals(obj1.valArr, portObj.<DecimalReflective>deserialize().valArr);
+
+ // 2. Test marshal aware stuff.
+ DecimalMarshalAware obj2 = new DecimalMarshalAware();
+
+ obj2.val = BigDecimal.ZERO;
+ obj2.valArr = new BigDecimal[] { BigDecimal.ONE, BigDecimal.TEN.negate() };
+ obj2.rawVal = BigDecimal.TEN;
+ obj2.rawValArr = new BigDecimal[] { BigDecimal.ZERO, BigDecimal.ONE };
+
+ portObj = marshal(obj2, marsh);
+
+ assertEquals(obj2.val, portObj.field("val"));
+ assertArrayEquals(obj2.valArr, portObj.<BigDecimal[]>field("valArr"));
+
+ assertEquals(obj2.val, portObj.<DecimalMarshalAware>deserialize().val);
+ assertArrayEquals(obj2.valArr, portObj.<DecimalMarshalAware>deserialize().valArr);
+ assertEquals(obj2.rawVal, portObj.<DecimalMarshalAware>deserialize().rawVal);
+ assertArrayEquals(obj2.rawValArr, portObj.<DecimalMarshalAware>deserialize().rawValArr);
+ }
+
+ /**
+ * @throws IgniteCheckedException If failed.
+ */
+ public void testFinalField() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ SimpleObjectWithFinal obj = new SimpleObjectWithFinal();
+
+ SimpleObjectWithFinal po0 = marshalUnmarshal(obj, marsh);
+
+ assertEquals(obj.time, po0.time);
+ }
+
+ /**
+ * @throws IgniteCheckedException If failed.
+ */
+ public void testThreadLocalArrayReleased() throws Exception {
+ // Checking the writer directly.
+ assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+
+ PortableMarshaller marsh0 = createMarshaller();
+
+ try (BinaryWriterExImpl writer = new BinaryWriterExImpl(portableContext(marsh0))) {
+ assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+
+ writer.writeString("Thread local test");
+
+ writer.array();
+
+ assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ }
+
+ // Checking the portable marshaller.
+ assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+
+ PortableMarshaller marsh = createMarshaller();
+
+ marsh.marshal(new SimpleObject());
+
+ assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+
+ // Checking the builder.
+ PortableMarshaller marsh2 = createMarshaller();
+
+ BinaryObjectBuilder builder = new BinaryObjectBuilderImpl(portableContext(marsh2),
+ "org.gridgain.foo.bar.TestClass");
+
+ builder.setField("a", "1");
+
+ BinaryObject portableObj = builder.build();
+
+ assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDuplicateName() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ Test1.Job job1 = new Test1().new Job();
+ Test2.Job job2 = new Test2().new Job();
+
+ marsh.marshal(job1);
+
+ try {
+ marsh.marshal(job2);
+ }
+ catch (BinaryObjectException e) {
+ assertEquals(true, e.getMessage().contains("Failed to register class"));
+
+ return;
+ }
+
+ assert false;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClass() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ Class cls = BinaryMarshallerSelfTest.class;
+
+ Class unmarshalledCls = marshalUnmarshal(cls, marsh);
+
+ Assert.assertEquals(cls, unmarshalledCls);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassFieldsMarshalling() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ ObjectWithClassFields obj = new ObjectWithClassFields();
+ obj.cls1 = BinaryMarshallerSelfTest.class;
+
+ byte[] marshal = marsh.marshal(obj);
+
+ ObjectWithClassFields obj2 = marsh.unmarshal(marshal, null);
+
+ assertEquals(obj.cls1, obj2.cls1);
+ assertNull(obj2.cls2);
+
+ BinaryObject portObj = marshal(obj, marsh);
+
+ Class cls1 = portObj.field("cls1");
+
+ assertEquals(obj.cls1, cls1);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMarshallingThroughJdk() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ InetSocketAddress addr = new InetSocketAddress("192.168.0.2", 4545);
+
+ byte[] arr = marsh.marshal(addr);
+
+ InetSocketAddress addr2 = marsh.unmarshal(arr, null);
+
+ assertEquals(addr.getHostString(), addr2.getHostString());
+ assertEquals(addr.getPort(), addr2.getPort());
+
+ TestAddress testAddr = new TestAddress();
+ testAddr.addr = addr;
+ testAddr.str1 = "Hello World";
+
+ SimpleObject simpleObj = new SimpleObject();
+ simpleObj.c = 'g';
+ simpleObj.date = new Date();
+
+ testAddr.obj = simpleObj;
+
+ arr = marsh.marshal(testAddr);
+
+ TestAddress testAddr2 = marsh.unmarshal(arr, null);
+
+ assertEquals(testAddr.addr.getHostString(), testAddr2.addr.getHostString());
+ assertEquals(testAddr.addr.getPort(), testAddr2.addr.getPort());
+ assertEquals(testAddr.str1, testAddr2.str1);
+ assertEquals(testAddr.obj.c, testAddr2.obj.c);
+ assertEquals(testAddr.obj.date, testAddr2.obj.date);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPredefinedTypeIds() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ PortableContext pCtx = initializePortableContext(marsh);
+
+ Field field = pCtx.getClass().getDeclaredField("predefinedTypeNames");
+
+ field.setAccessible(true);
+
+ Map<String, Integer> map = (Map<String, Integer>)field.get(pCtx);
+
+ assertTrue(map.size() > 0);
+
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
+ int id = entry.getValue();
+
+ if (id == GridPortableMarshaller.UNREGISTERED_TYPE_ID)
+ continue;
+
+ PortableClassDescriptor desc = pCtx.descriptorForTypeId(false, entry.getValue(), null);
+
+ assertEquals(desc.typeId(), pCtx.typeId(desc.describedClass().getName()));
+ assertEquals(desc.typeId(), pCtx.typeId(pCtx.typeName(desc.describedClass().getName())));
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCyclicReferencesMarshalling() throws Exception {
+ PortableMarshaller marsh = createMarshaller();
+
+ SimpleObject obj = simpleObject();
+
+ obj.bArr = obj.inner.bArr;
+ obj.cArr = obj.inner.cArr;
+ obj.boolArr = obj.inner.boolArr;
+ obj.sArr = obj.inner.sArr;
+ obj.strArr = obj.inner.strArr;
+ obj.iArr = obj.inner.iArr;
+ obj.lArr = obj.inner.lArr;
+ obj.fArr = obj.inner.fArr;
+ obj.dArr = obj.inner.dArr;
+ obj.dateArr = obj.inner.dateArr;
+ obj.uuidArr = obj.inner.uuidArr;
+ obj.objArr = obj.inner.objArr;
+ obj.bdArr = obj.inner.bdArr;
+ obj.map = obj.inner.map;
+ obj.col = obj.inner.col;
+ obj.mEntry = obj.inner.mEntry;
+
+ SimpleObject res = (SimpleObject)marshalUnmarshal(obj, marsh);
+
+ assertEquals(obj, res);
+
+ assertTrue(res.bArr == res.inner.bArr);
+ assertTrue(res.cArr == res.inner.cArr);
+ assertTrue(res.boolArr == res.inner.boolArr);
+ assertTrue(res.sArr == res.inner.sArr);
+ assertTrue(res.strArr == res.inner.strArr);
+ assertTrue(res.iArr == res.inner.iArr);
+ assertTrue(res.lArr == res.inner.lArr);
+ assertTrue(res.fArr == res.inner.fArr);
+ assertTrue(res.dArr == res.inner.dArr);
+ assertTrue(res.dateArr == res.inner.dateArr);
+ assertTrue(res.uuidArr == res.inner.uuidArr);
+ assertTrue(res.objArr == res.inner.objArr);
+ assertTrue(res.bdArr == res.inner.bdArr);
+ assertTrue(res.map == res.inner.map);
+ assertTrue(res.col == res.inner.col);
+ assertTrue(res.mEntry == res.inner.mEntry);
+ }
+
+ /**
+ * Object with class fields.
+ */
+ private static class ObjectWithClassFields {
+ /** */
+ private Class<?> cls1;
+
+ /** */
+ private Class<?> cls2;
+ }
+
+ /**
+ *
+ */
+ private static class TestAddress {
+ /** */
+ private SimpleObject obj;
+
+ /** */
+ private InetSocketAddress addr;
+
+ /** */
+ private String str1;
+ }
+
+ /**
+ *
+ */
+ private static class Test1 {
+ /**
+ *
+ */
+ private class Job {
+
+ }
+ }
+
+ /**
+ *
+ */
+ private static class Test2 {
+ /**
+ *
+ */
+ private class Job {
+
+ }
+ }
+
+ /**
+ * @param obj Object.
+ * @return Offheap address.
+ */
+ private long copyOffheap(BinaryObjectImpl obj) {
+ byte[] arr = obj.array();
+
+ long ptr = UNSAFE.allocateMemory(arr.length);
+
+ UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+
+ return ptr;
+ }
+
+ /**
+ * @param enumArr Enum array.
+ * @return Ordinals.
+ */
+ private <T extends Enum<?>> Integer[] ordinals(T[] enumArr) {
+ Integer[] ords = new Integer[enumArr.length];
+
+ for (int i = 0; i < enumArr.length; i++)
+ ords[i] = enumArr[i].ordinal();
+
+ return ords;
+ }
+
+ /**
+ * @param po Portable object.
+ * @param off Offset.
+ * @return Value.
+ */
+ private int intFromPortable(BinaryObject po, int off) {
+ byte[] arr = U.field(po, "arr");
+
+ return Integer.reverseBytes(U.bytesToInt(arr, off));
+ }
+
+ /**
+ * @param obj Original object.
+ * @return Result object.
+ */
+ private <T> T marshalUnmarshal(T obj) throws Exception {
+ return marshalUnmarshal(obj, createMarshaller());
+ }
+
+ /**
+ * @param obj Original object.
+ * @param marsh Marshaller.
+ * @return Result object.
+ */
+ private <T> T marshalUnmarshal(Object obj, PortableMarshaller marsh) throws IgniteCheckedException {
+ initializePortableContext(marsh);
+
+ byte[] bytes = marsh.marshal(obj);
+
+ return marsh.unmarshal(bytes, null);
+ }
+
+ /**
+ * @param obj Object.
+ * @param marsh Marshaller.
+ * @return Portable object.
+ */
+ private <T> BinaryObjectImpl marshal(T obj, PortableMarshaller marsh) throws IgniteCheckedException {
+ initializePortableContext(marsh);
+
+ byte[] bytes = marsh.marshal(obj);
+
+ return new BinaryObjectImpl(U.<GridPortableMarshaller>field(marsh, "impl").context(),
+ bytes, 0);
+ }
+
+ /**
+ * Create portable marshaller.
+ *
+ * @return Portable marshaller.
+ * @throws Exception If failed.
+ */
+ private PortableMarshaller createMarshaller() throws Exception {
+ PortableMarshaller marsh = new PortableMarshaller();
+
+ marsh.setCompactFooter(compactFooter());
+
+ initializePortableContext(marsh);
+
+ return marsh;
+ }
+
+ /**
+ * @return Whether to use compact footers or not.
+ */
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
+ * Get portable context of the given marshaller.
+ *
+ * @param marsh Marshaller.
+ * @return Context.
+ * @throws Exception If failed.
+ */
+ private PortableContext portableContext(PortableMarshaller marsh) throws Exception {
+ GridPortableMarshaller marsh0 = IgniteUtils.field(marsh, "impl");
+
+ return marsh0.context();
+ }
+
+ /**
+ * @return Portable context.
+ */
+ private PortableContext initializePortableContext(PortableMarshaller marsh) throws IgniteCheckedException {
+ IgniteConfiguration iCfg = new IgniteConfiguration();
+
+ PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(), iCfg);
+
+ marsh.setContext(new MarshallerContextTestImpl(null));
+
+ IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
+
+ return ctx;
+ }
+
+ /**
+ * @param exp Expected.
+ * @param act Actual.
+ */
+ private void assertBooleanArrayEquals(boolean[] exp, boolean[] act) {
+ assertEquals(exp.length, act.length);
+
+ for (int i = 0; i < act.length; i++)
+ assertEquals(exp[i], act[i]);
+ }
+
+ /**
+ *
+ */
+ private static class SimpleObjectWithFinal {
+ /** */
+ private final long time = System.currentTimeMillis();
+ }
+
+ /**
+ * @return Simple object.
+ */
+ private SimpleObject simpleObject() {
+ SimpleObject inner = new SimpleObject();
+
+ inner.b = 1;
+ inner.s = 1;
+ inner.i = 1;
+ inner.l = 1;
+ inner.f = 1.1f;
+ inner.d = 1.1d;
+ inner.c = 1;
+ inner.bool = true;
+ inner.str = "str1";
+ inner.uuid = UUID.randomUUID();
+ inner.date = new Date();
+ inner.ts = new Timestamp(System.currentTimeMillis());
+ inner.bArr = new byte[] {1, 2, 3};
+ inner.sArr = new short[] {1, 2, 3};
+ inner.iArr = new int[] {1, 2, 3};
+ inner.lArr = new long[] {1, 2, 3};
+ inner.fArr = new float[] {1.1f, 2.2f, 3.3f};
+ inner.dArr = new double[] {1.1d, 2.2d, 3.3d};
+ inner.cArr = new char[] {1, 2, 3};
+ inner.boolArr = new boolean[] {true, false, true};
+ inner.strArr = new String[] {"str1", "str2", "str3"};
+ inner.uuidArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
+ inner.dateArr = new Date[] {new Date(11111), new Date(22222), new Date(33333)};
+ inner.objArr = new Object[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
+ inner.col = new ArrayList<>();
+ inner.map = new HashMap<>();
+ inner.enumVal = TestEnum.A;
+ inner.enumArr = new TestEnum[] {TestEnum.A, TestEnum.B};
+ inner.bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.ONE};
+
+ inner.col.add("str1");
+ inner.col.add("str2");
+ inner.col.add("str3");
+
+ inner.map.put(1, "str1");
+ inner.map.put(2, "str2");
+ inner.map.put(3, "str3");
+
+ inner.mEntry = inner.map.entrySet().iterator().next();
+
+ SimpleObject outer = new SimpleObject();
+
+ outer.b = 2;
+ outer.s = 2;
+ outer.i = 2;
+ outer.l = 2;
+ outer.f = 2.2f;
+ outer.d = 2.2d;
+ outer.c = 2;
+ outer.bool = false;
+ outer.str = "str2";
+ outer.uuid = UUID.randomUUID();
+ outer.date = new Date();
+ outer.ts = new Timestamp(System.currentTimeMillis());
+ outer.bArr = new byte[] {10, 20, 30};
+ outer.sArr = new short[] {10, 20, 30};
+ outer.iArr = new int[] {10, 20, 30};
+ outer.lArr = new long[] {10, 20, 30};
+ outer.fArr = new float[] {10.01f, 20.02f, 30.03f};
+ outer.dArr = new double[] {10.01d, 20.02d, 30.03d};
+ outer.cArr = new char[] {10, 20, 30};
+ outer.boolArr = new boolean[] {false, true, false};
+ outer.strArr = new String[] {"str10", "str20", "str30"};
+ outer.uuidArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
+ outer.dateArr = new Date[] {new Date(44444), new Date(55555), new Date(66666)};
+ outer.objArr = new Object[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
+ outer.col = new ArrayList<>();
+ outer.map = new HashMap<>();
+ outer.enumVal = TestEnum.B;
+ outer.enumArr = new TestEnum[] {TestEnum.B, TestEnum.C};
+ outer.inner = inner;
+ outer.bdArr = new BigDecimal[] {new BigDecimal(5000), BigDecimal.TEN};
+
+
+ outer.col.add("str4");
+ outer.col.add("str5");
+ outer.col.add("str6");
+
+ outer.map.put(4, "str4");
+ outer.map.put(5, "str5");
+ outer.map.put(6, "str6");
+
+ outer.mEntry = outer.map.entrySet().iterator().next();
+
+ return outer;
+ }
+
+ /**
+ * @return Portable object.
+ */
+ private TestBinary binaryObject() {
+ SimpleObject innerSimple = new SimpleObject();
+
+ innerSimple.b = 1;
+ innerSimple.s = 1;
+ innerSimple.i = 1;
+ innerSimple.l = 1;
+ innerSimple.f = 1.1f;
+ innerSimple.d = 1.1d;
+ innerSimple.c = 1;
+ innerSimple.bool = true;
+ innerSimple.str = "str1";
+ innerSimple.uuid = UUID.randomUUID();
+ innerSimple.date = new Date();
+ innerSimple.ts = new Timestamp(System.currentTimeMillis());
+ innerSimple.bArr = new byte[] {1, 2, 3};
+ innerSimple.sArr = new short[] {1, 2, 3};
+ innerSimple.iArr = new int[] {1, 2, 3};
+ innerSimple.lArr = new long[] {1, 2, 3};
+ innerSimple.fArr = new float[] {1.1f, 2.2f, 3.3f};
+ innerSimple.dArr = new double[] {1.1d, 2.2d, 3.3d};
+ innerSimple.cArr = new char[] {1, 2, 3};
+ innerSimple.boolArr = new boolean[] {true, false, true};
+ innerSimple.strArr = new String[] {"str1", "str2", "str3"};
+ innerSimple.uuidArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
+ innerSimple.dateArr = new Date[] {new Date(11111), new Date(22222), new Date(33333)};
+ innerSimple.objArr = new UUID[] {UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID()};
+
<TRUNCATED>
[08/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Posted by ag...@apache.org.
IGNITE-1881: Internal portable -> binary renamings.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d69362f8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d69362f8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d69362f8
Branch: refs/heads/ignite-1.5
Commit: d69362f86b3da5b29f42366938ba1c82403dcb2a
Parents: fff85cb
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Nov 17 16:58:53 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Nov 17 16:58:53 2015 +0300
----------------------------------------------------------------------
.../dotnet/PlatformDotNetConfiguration.java | 2 +-
...CacheAtomicReferenceApiSelfAbstractTest.java | 10 +-
.../platform/PlatformComputeBinarizable.java | 42 +
.../PlatformComputeBinarizableArgTask.java | 119 +
.../platform/PlatformComputeEchoTask.java | 12 +-
.../PlatformComputeJavaBinarizable.java | 39 +
.../platform/PlatformComputeJavaPortable.java | 39 -
.../platform/PlatformComputePortable.java | 42 -
.../PlatformComputePortableArgTask.java | 119 -
.../Apache.Ignite.Benchmarks.csproj | 4 +-
.../Apache.Ignite.Benchmarks/BenchmarkRunner.cs | 4 +-
.../Binary/BinarizableReadBenchmark.cs | 125 +
.../Binary/BinarizableWriteBenchmark.cs | 135 ++
.../Interop/PlatformBenchmarkBase.cs | 8 +-
.../Portable/PortableReadBenchmark.cs | 126 -
.../Portable/PortableWriteBenchmark.cs | 135 --
.../Apache.Ignite.Core.Tests.csproj | 27 +-
.../Apache.Ignite.Core.Tests.nunit | 7 +
.../Binary/BinaryBuilderSelfTest.cs | 1721 ++++++++++++++
.../Binary/BinarySelfTest.cs | 2157 ++++++++++++++++++
.../Binary/BinaryStructureTest.cs | 250 ++
.../BinaryConfigurationTest.cs | 173 ++
.../Cache/CacheAbstractTest.cs | 94 +-
.../Cache/CacheAffinityTest.cs | 4 +-
.../Cache/CacheDynamicStartTest.cs | 6 +-
.../Cache/Query/CacheQueriesTest.cs | 80 +-
.../Continuous/ContinuousQueryAbstractTest.cs | 210 +-
.../ContinuousQueryNoBackupAbstractTest.cs | 4 +-
.../Cache/Store/CacheStoreTest.cs | 68 +-
.../Compute/AbstractTaskTest.cs | 8 +-
.../Compute/BinarizableClosureTaskTest.cs | 185 ++
.../Compute/BinarizableTaskTest.cs | 269 +++
.../Compute/ComputeApiTest.cs | 62 +-
.../Compute/FailoverTaskSelfTest.cs | 18 +-
.../Forked/ForkedBinarizableClosureTaskTest.cs | 30 +
.../Forked/ForkedPortableClosureTaskTest.cs | 30 -
.../Compute/Forked/ForkedResourceTaskTest.cs | 3 -
.../Forked/ForkedSerializableClosureTaskTest.cs | 3 -
.../Compute/PortableClosureTaskTest.cs | 217 --
.../Compute/PortableTaskTest.cs | 269 ---
.../Compute/TaskAdapterTest.cs | 14 +-
.../Compute/TaskResultTest.cs | 46 +-
.../Config/Compute/compute-grid1.xml | 6 +-
.../Config/Compute/compute-standalone.xml | 14 +-
.../Apache.Ignite.Core.Tests/Config/binary.xml | 56 +
.../Config/cache-binarizables.xml | 78 +
.../Config/cache-portables.xml | 78 -
.../Config/cache-query-continuous.xml | 8 +-
.../Config/marshaller-explicit.xml | 47 +
.../Config/marshaller-portable.xml | 43 -
.../Config/native-client-test-cache-store.xml | 2 +-
.../Config/native-client-test-cache.xml | 51 -
.../Config/portable.xml | 56 -
.../Dataload/DataStreamerTest.cs | 42 +-
.../Apache.Ignite.Core.Tests/EventsTest.cs | 16 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 28 +-
.../Apache.Ignite.Core.Tests/FutureTest.cs | 10 +-
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 10 +-
.../Portable/PortableApiSelfTest.cs | 1777 ---------------
.../Portable/PortableSelfTest.cs | 2157 ------------------
.../Portable/PortableStructureTest.cs | 250 --
.../PortableConfigurationTest.cs | 173 --
.../Query/BinarizablePerson.cs | 69 +
.../Query/ImplicitBinarizablePerson.cs | 46 +
.../Query/ImplicitPortablePerson.cs | 46 -
.../Query/NoDefBinarizablePerson.cs | 35 +
.../Query/NoDefPortablePerson.cs | 35 -
.../Query/PortablePerson.cs | 69 -
.../Services/ServiceProxyTest.cs | 130 +-
.../Services/ServicesTest.cs | 88 +-
.../TypeResolverTest.cs | 20 +-
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 20 +-
.../examples/Config/example-cache-query.xml | 12 +-
.../dotnet/examples/Config/example-cache.xml | 12 +-
parent/pom.xml | 1 +
75 files changed, 6133 insertions(+), 6268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
index ff5656b..f323085 100644
--- a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetConfiguration.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List;
/**
- * Mirror of .Net class Configuration.cs
+ * Mirror of .Net class IgniteConfiguration.cs
*/
public class PlatformDotNetConfiguration implements PlatformConfiguration {
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
index 416776a..278bcf9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
@@ -97,15 +97,13 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends Ignite
String initVal = "qwerty";
- IgniteAtomicReference<String> atomic = grid(0).atomicReference(atomicName, null, true);
+ IgniteAtomicReference<String> atomic = grid(0).atomicReference(atomicName, initVal, true);
- assertEquals(null, atomic.get());
+ assertEquals(initVal, atomic.get());
- boolean res = atomic.compareAndSet(null, "x");
+ atomic.compareAndSet("h", "j");
- assertEquals(null, atomic.get()); // ok
- assertTrue(res); // fail
- assertEquals("x", atomic.get()); // fail
+ assertEquals(initVal, atomic.get());
atomic.compareAndSet(initVal, null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java
new file mode 100644
index 0000000..55b3099
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizable.java
@@ -0,0 +1,42 @@
+/*
+ * 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.platform;
+
+/**
+ * Binarizable object for task tests.
+ */
+public class PlatformComputeBinarizable {
+ /** Field. */
+ public int field;
+
+ /**
+ * Constructor.
+ */
+ public PlatformComputeBinarizable() {
+ // No-op.
+ }
+
+ /**
+ * Constructor,
+ *
+ * @param field Field.
+ */
+ public PlatformComputeBinarizable(int field) {
+ this.field = field;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
new file mode 100644
index 0000000..77c7e3a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
@@ -0,0 +1,119 @@
+/*
+ * 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.platform;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.ComputeJobAdapter;
+import org.apache.ignite.compute.ComputeJobResult;
+import org.apache.ignite.compute.ComputeTaskAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Task working with binarizable argument.
+ */
+public class PlatformComputeBinarizableArgTask extends ComputeTaskAdapter<Object, Integer> {
+ /** {@inheritDoc} */
+ @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) {
+ return Collections.singletonMap(new BinarizableArgJob(arg), F.first(subgrid));
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ @Nullable @Override public Integer reduce(List<ComputeJobResult> results) {
+ ComputeJobResult res = results.get(0);
+
+ if (res.getException() != null)
+ throw res.getException();
+ else
+ return results.get(0).getData();
+ }
+
+ /**
+ * Job.
+ */
+ private static class BinarizableArgJob extends ComputeJobAdapter implements Externalizable {
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** Argument. */
+ private Object arg;
+
+ /**
+ * Constructor.
+ */
+ public BinarizableArgJob() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param arg Argument.
+ */
+ private BinarizableArgJob(Object arg) {
+ this.arg = arg;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object execute() {
+ BinaryObject arg0 = ((BinaryObject)arg);
+
+ BinaryType meta = ignite.binary().metadata(arg0.typeId());
+
+ if (meta == null)
+ throw new IgniteException("Metadata doesn't exist.");
+
+ if (meta.fields() == null || !meta.fields().contains("Field"))
+ throw new IgniteException("Field metadata doesn't exist.");
+
+ if (!F.eq("int", meta.fieldTypeName("Field")))
+ throw new IgniteException("Invalid field type: " + meta.fieldTypeName("Field"));
+
+ if (meta.affinityKeyFieldName() != null)
+ throw new IgniteException("Unexpected affinity key: " + meta.affinityKeyFieldName());
+
+ return arg0.field("field");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(arg);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ arg = in.readObject();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
index f64ca7d..fe4e01c 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeEchoTask.java
@@ -155,19 +155,19 @@ public class PlatformComputeEchoTask extends ComputeTaskAdapter<Integer, Object>
return Collections.singletonMap(1, 1);
case TYPE_PORTABLE:
- return new PlatformComputePortable(1);
+ return new PlatformComputeBinarizable(1);
case TYPE_PORTABLE_JAVA:
- return new PlatformComputeJavaPortable(1);
+ return new PlatformComputeJavaBinarizable(1);
case TYPE_OBJ_ARRAY:
return new String[] { "foo", "bar", "baz" };
case TYPE_PORTABLE_ARRAY:
- return new PlatformComputePortable[] {
- new PlatformComputePortable(1),
- new PlatformComputePortable(2),
- new PlatformComputePortable(3)
+ return new PlatformComputeBinarizable[] {
+ new PlatformComputeBinarizable(1),
+ new PlatformComputeBinarizable(2),
+ new PlatformComputeBinarizable(3)
};
case TYPE_ENUM:
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java
new file mode 100644
index 0000000..ade09db
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaBinarizable.java
@@ -0,0 +1,39 @@
+/*
+ * 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.platform;
+
+/**
+ * Binarizable object defined only in Java.
+ */
+public class PlatformComputeJavaBinarizable extends PlatformComputeBinarizable {
+ /**
+ * Constructor.
+ */
+ public PlatformComputeJavaBinarizable() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param field Field.
+ */
+ public PlatformComputeJavaBinarizable(int field) {
+ super(field);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
deleted file mode 100644
index 7a940c4..0000000
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeJavaPortable.java
+++ /dev/null
@@ -1,39 +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.platform;
-
-/**
- * Portable object defined only in Java.
- */
-public class PlatformComputeJavaPortable extends PlatformComputePortable {
- /**
- * Constructor.
- */
- public PlatformComputeJavaPortable() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param field Field.
- */
- public PlatformComputeJavaPortable(int field) {
- super(field);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.java
deleted file mode 100644
index f31f093..0000000
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortable.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.platform;
-
-/**
- * Portable object for task tests.
- */
-public class PlatformComputePortable {
- /** Field. */
- public int field;
-
- /**
- * Constructor.
- */
- public PlatformComputePortable() {
- // No-op.
- }
-
- /**
- * Constructor,
- *
- * @param field Field.
- */
- public PlatformComputePortable(int field) {
- this.field = field;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
deleted file mode 100644
index 1e3c499..0000000
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputePortableArgTask.java
+++ /dev/null
@@ -1,119 +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.platform;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.compute.ComputeJob;
-import org.apache.ignite.compute.ComputeJobAdapter;
-import org.apache.ignite.compute.ComputeJobResult;
-import org.apache.ignite.compute.ComputeTaskAdapter;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.jetbrains.annotations.Nullable;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Task working with portable argument.
- */
-public class PlatformComputePortableArgTask extends ComputeTaskAdapter<Object, Integer> {
- /** {@inheritDoc} */
- @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) {
- return Collections.singletonMap(new PortableArgJob(arg), F.first(subgrid));
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
- @Nullable @Override public Integer reduce(List<ComputeJobResult> results) {
- ComputeJobResult res = results.get(0);
-
- if (res.getException() != null)
- throw res.getException();
- else
- return results.get(0).getData();
- }
-
- /**
- * Job.
- */
- private static class PortableArgJob extends ComputeJobAdapter implements Externalizable {
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** Argument. */
- private Object arg;
-
- /**
- * Constructor.
- */
- public PortableArgJob() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param arg Argument.
- */
- private PortableArgJob(Object arg) {
- this.arg = arg;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object execute() {
- BinaryObject arg0 = ((BinaryObject)arg);
-
- BinaryType meta = ignite.binary().metadata(arg0.typeId());
-
- if (meta == null)
- throw new IgniteException("Metadata doesn't exist.");
-
- if (meta.fields() == null || !meta.fields().contains("Field"))
- throw new IgniteException("Field metadata doesn't exist.");
-
- if (!F.eq("int", meta.fieldTypeName("Field")))
- throw new IgniteException("Invalid field type: " + meta.fieldTypeName("Field"));
-
- if (meta.affinityKeyFieldName() != null)
- throw new IgniteException("Unexpected affinity key: " + meta.affinityKeyFieldName());
-
- return arg0.field("field");
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(arg);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- arg = in.readObject();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
index 99737b8..14b6466 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
@@ -63,8 +63,8 @@
<Compile Include="Model\Employee.cs" />
<Compile Include="Model\Sex.cs" />
<Compile Include="Model\TestModel.cs" />
- <Compile Include="Portable\PortableReadBenchmark.cs" />
- <Compile Include="Portable\PortableWriteBenchmark.cs" />
+ <Compile Include="Binary\BinarizableReadBenchmark.cs" />
+ <Compile Include="Binary\BinarizableWriteBenchmark.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Result\BenchmarkConsoleResultWriter.cs" />
<Compile Include="Result\BenchmarkFileResultWriter.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
index 2d0d348..5d8e78a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
@@ -20,7 +20,7 @@ namespace Apache.Ignite.Benchmarks
using System;
using System.Diagnostics;
using System.Text;
- using Apache.Ignite.Benchmarks.Portable;
+ using Apache.Ignite.Benchmarks.Binary;
/// <summary>
/// Benchmark runner.
@@ -35,7 +35,7 @@ namespace Apache.Ignite.Benchmarks
public static void Main(string[] args)
{
args = new[] {
- typeof(PortableReadBenchmark).FullName,
+ typeof(BinarizableReadBenchmark).FullName,
"-ConfigPath", @"modules\platforms\dotnet\Apache.Ignite.Benchmarks\Config\benchmark.xml",
"-Threads", "1",
"-Warmup", "0",
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs
new file mode 100644
index 0000000..09e588e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableReadBenchmark.cs
@@ -0,0 +1,125 @@
+/*
+ * 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.Benchmarks.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Benchmarks.Model;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Memory;
+
+ /// <summary>
+ /// Binary read benchmark.
+ /// </summary>
+ internal class BinarizableReadBenchmark : BenchmarkBase
+ {
+ /** Marshaller. */
+ private readonly Marshaller _marsh;
+
+ /** Memory manager. */
+ private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
+
+ /** Memory chunk. */
+ private readonly IPlatformMemory _mem;
+
+ /** Pre-allocated address. */
+ private readonly Address _address = BenchmarkUtils.GetRandomAddress();
+
+ /** Pre-allocated model. */
+ private readonly TestModel _model = new TestModel
+ {
+ Byte = 5,
+ Boolean = true,
+ BooleanArray = new[] {true, false, false, false, true, true},
+ ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Char = 'h',
+ CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
+ Date = DateTime.Now,
+ DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
+ Decimal = decimal.MinValue,
+ DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
+ Double = double.MaxValue/2,
+ DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
+ Float = 98,
+ FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
+ Guid = Guid.NewGuid(),
+ GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
+ Int = -90,
+ IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Long = long.MinValue,
+ LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
+ Short = 67,
+ ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
+ String = "String value test 123",
+ StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinarizableReadBenchmark"/> class.
+ /// </summary>
+ public BinarizableReadBenchmark()
+ {
+ _marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (Address)),
+ new BinaryTypeConfiguration(typeof (TestModel))
+ }
+ });
+
+ _mem = _memMgr.Allocate();
+
+ var stream = _mem.GetStream();
+
+ //_marsh.StartMarshal(stream).Write(_model);
+ _marsh.StartMarshal(stream).Write(_address);
+
+ stream.SynchronizeOutput();
+ }
+
+ /// <summary>
+ /// Populate descriptors.
+ /// </summary>
+ /// <param name="descs">Descriptors.</param>
+ protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
+ {
+ descs.Add(BenchmarkOperationDescriptor.Create("ReadTestModel", ReadTestModel, 1));
+ }
+
+ /// <summary>
+ /// Write address.
+ /// </summary>
+ /// <param name="state">State.</param>
+ private void ReadTestModel(BenchmarkState state)
+ {
+ //var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<TestModel>();
+
+ //if (model.Byte != _model.Byte)
+ // throw new InvalidOperationException();
+
+ var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<Address>();
+
+ if (model.FlatNumber != _address.FlatNumber)
+ throw new InvalidOperationException();
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs
new file mode 100644
index 0000000..c4d375f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Binary/BinarizableWriteBenchmark.cs
@@ -0,0 +1,135 @@
+/*
+ * 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.Benchmarks.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Benchmarks.Model;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Memory;
+
+ /// <summary>
+ /// Binary write benchmark.
+ /// </summary>
+ internal class BinarizableWriteBenchmark : BenchmarkBase
+ {
+ /** Marshaller. */
+ private readonly Marshaller _marsh;
+
+ /** Memory manager. */
+ private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
+
+ /** Pre-allocated address. */
+ private readonly Address _address = BenchmarkUtils.GetRandomAddress();
+
+ /** Pre-allocated model. */
+ private readonly TestModel _model = new TestModel
+ {
+ Byte = 5,
+ Boolean = true,
+ BooleanArray = new[] {true, false, false, false, true, true},
+ ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Char = 'h',
+ CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
+ Date = DateTime.Now,
+ DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
+ Decimal = decimal.MinValue,
+ DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
+ Double = double.MaxValue/2,
+ DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
+ Float = 98,
+ FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
+ Guid = Guid.NewGuid(),
+ GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
+ Int = -90,
+ IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
+ Long = long.MinValue,
+ LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
+ Short = 67,
+ ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
+ String = "String value test 123",
+ StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
+ };
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinarizableWriteBenchmark"/> class.
+ /// </summary>
+ public BinarizableWriteBenchmark()
+ {
+ _marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (Address))
+ //new BinaryTypeConfiguration(typeof (TestModel))
+ }
+ });
+ }
+
+ /// <summary>
+ /// Populate descriptors.
+ /// </summary>
+ /// <param name="descs">Descriptors.</param>
+ protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
+ {
+ descs.Add(BenchmarkOperationDescriptor.Create("WriteAddress", WriteAddress, 1));
+ //descs.Add(BenchmarkOperationDescriptor.Create("WriteTestModel", WriteTestModel, 1));
+ }
+
+ /// <summary>
+ /// Write address.
+ /// </summary>
+ /// <param name="state">State.</param>
+ private void WriteAddress(BenchmarkState state)
+ {
+ var mem = _memMgr.Allocate();
+
+ try
+ {
+ var stream = mem.GetStream();
+
+ _marsh.StartMarshal(stream).Write(_address);
+ }
+ finally
+ {
+ mem.Release();
+ }
+ }
+ /// <summary>
+ /// Write address.
+ /// </summary>
+ /// <param name="state">State.</param>
+ private void WriteTestModel(BenchmarkState state)
+ {
+ var mem = _memMgr.Allocate();
+
+ try
+ {
+ var stream = mem.GetStream();
+
+ _marsh.StartMarshal(stream).Write(_model);
+ }
+ finally
+ {
+ mem.Release();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
index 67809d5..eeebed0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PlatformBenchmarkBase.cs
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Benchmarks.Interop
var cfg = new IgniteConfiguration
{
- BinaryConfiguration = GetPortableConfiguration(),
+ BinaryConfiguration = GetBinaryConfiguration(),
JvmOptions = new List<string>
{
"-Xms2g",
@@ -75,10 +75,10 @@ namespace Apache.Ignite.Benchmarks.Interop
}
/// <summary>
- /// Get portable configuration.
+ /// Get binary configuration.
/// </summary>
- /// <returns>Portable configuration.</returns>
- private static BinaryConfiguration GetPortableConfiguration()
+ /// <returns>Gets binary configuration.</returns>
+ private static BinaryConfiguration GetBinaryConfiguration()
{
return new BinaryConfiguration
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
deleted file mode 100644
index ad9ae39..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableReadBenchmark.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Benchmarks.Portable
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Benchmarks.Model;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Memory;
-
- /// <summary>
- /// Portable read benchmark.
- /// </summary>
- internal class PortableReadBenchmark : BenchmarkBase
- {
- /** Marshaller. */
- private readonly Marshaller _marsh;
-
- /** Memory manager. */
- private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
-
- /** Memory chunk. */
- private readonly IPlatformMemory _mem;
-
- /** Pre-allocated address. */
- private readonly Address _address = BenchmarkUtils.GetRandomAddress();
-
-
- /** Pre-allocated model. */
- private readonly TestModel _model = new TestModel
- {
- Byte = 5,
- Boolean = true,
- BooleanArray = new[] {true, false, false, false, true, true},
- ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Char = 'h',
- CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
- Date = DateTime.Now,
- DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
- Decimal = decimal.MinValue,
- DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
- Double = double.MaxValue/2,
- DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
- Float = 98,
- FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
- Guid = Guid.NewGuid(),
- GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
- Int = -90,
- IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Long = long.MinValue,
- LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
- Short = 67,
- ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
- String = "String value test 123",
- StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
- };
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PortableReadBenchmark"/> class.
- /// </summary>
- public PortableReadBenchmark()
- {
- _marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (Address)),
- new BinaryTypeConfiguration(typeof (TestModel))
- }
- });
-
- _mem = _memMgr.Allocate();
-
- var stream = _mem.GetStream();
-
- //_marsh.StartMarshal(stream).Write(_model);
- _marsh.StartMarshal(stream).Write(_address);
-
- stream.SynchronizeOutput();
- }
-
- /// <summary>
- /// Populate descriptors.
- /// </summary>
- /// <param name="descs">Descriptors.</param>
- protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
- {
- descs.Add(BenchmarkOperationDescriptor.Create("ReadTestModel", ReadTestModel, 1));
- }
-
- /// <summary>
- /// Write address.
- /// </summary>
- /// <param name="state">State.</param>
- private void ReadTestModel(BenchmarkState state)
- {
- //var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<TestModel>();
-
- //if (model.Byte != _model.Byte)
- // throw new InvalidOperationException();
-
- var model = _marsh.StartUnmarshal(_mem.GetStream()).ReadObject<Address>();
-
- if (model.FlatNumber != _address.FlatNumber)
- throw new InvalidOperationException();
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
deleted file mode 100644
index a630161..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Portable/PortableWriteBenchmark.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Benchmarks.Portable
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Benchmarks.Model;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Memory;
-
- /// <summary>
- /// Portable write benchmark.
- /// </summary>
- internal class PortableWriteBenchmark : BenchmarkBase
- {
- /** Marshaller. */
- private readonly Marshaller _marsh;
-
- /** Memory manager. */
- private readonly PlatformMemoryManager _memMgr = new PlatformMemoryManager(1024);
-
- /** Pre-allocated address. */
- private readonly Address _address = BenchmarkUtils.GetRandomAddress();
-
- /** Pre-allocated model. */
- private readonly TestModel _model = new TestModel
- {
- Byte = 5,
- Boolean = true,
- BooleanArray = new[] {true, false, false, false, true, true},
- ByteArray = new byte[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Char = 'h',
- CharArray = new[] {'b', 'n', 'm', 'q', 'w', 'e', 'r', 't', 'y'},
- Date = DateTime.Now,
- DateArray = Enumerable.Range(1, 15).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray(),
- Decimal = decimal.MinValue,
- DecimalArray = new decimal?[] {1.1M, decimal.MinValue, decimal.MaxValue, decimal.MinusOne, decimal.One},
- Double = double.MaxValue/2,
- DoubleArray = new[] {double.MaxValue, double.MinValue, double.Epsilon, double.NegativeInfinity},
- Float = 98,
- FloatArray = new[] {float.MinValue, float.MaxValue, 10F, 36F},
- Guid = Guid.NewGuid(),
- GuidArray = Enumerable.Range(1, 9).Select(x => (Guid?) Guid.NewGuid()).ToArray(),
- Int = -90,
- IntArray = new[] {128, 1, 2, 3, 5, 6, 8, 9, 14},
- Long = long.MinValue,
- LongArray = Enumerable.Range(1, 12).Select(x => (long) x).ToArray(),
- Short = 67,
- ShortArray = Enumerable.Range(100, 12).Select(x => (short) x).ToArray(),
- String = "String value test 123",
- StringArray = Enumerable.Range(1, 13).Select(x => Guid.NewGuid().ToString()).ToArray()
- };
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PortableWriteBenchmark"/> class.
- /// </summary>
- public PortableWriteBenchmark()
- {
- _marsh = new Marshaller(new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (Address))
- //new PortableTypeConfiguration(typeof (TestModel))
- }
- });
- }
-
- /// <summary>
- /// Populate descriptors.
- /// </summary>
- /// <param name="descs">Descriptors.</param>
- protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
- {
- descs.Add(BenchmarkOperationDescriptor.Create("WriteAddress", WriteAddress, 1));
- //descs.Add(BenchmarkOperationDescriptor.Create("WriteTestModel", WriteTestModel, 1));
- }
-
- /// <summary>
- /// Write address.
- /// </summary>
- /// <param name="state">State.</param>
- private void WriteAddress(BenchmarkState state)
- {
- var mem = _memMgr.Allocate();
-
- try
- {
- var stream = mem.GetStream();
-
- _marsh.StartMarshal(stream).Write(_address);
- }
- finally
- {
- mem.Release();
- }
- }
- /// <summary>
- /// Write address.
- /// </summary>
- /// <param name="state">State.</param>
- private void WriteTestModel(BenchmarkState state)
- {
- var mem = _memMgr.Allocate();
-
- try
- {
- var stream = mem.GetStream();
-
- _marsh.StartMarshal(stream).Write(_model);
- }
- finally
- {
- mem.Release();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 10b3dcd..a5bb7a8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -84,7 +84,7 @@
<Compile Include="Cache\Store\CacheStoreTest.cs" />
<Compile Include="Cache\Store\CacheTestParallelLoadStore.cs" />
<Compile Include="Cache\Store\CacheTestStore.cs" />
- <Compile Include="Compute\Forked\ForkedPortableClosureTaskTest.cs" />
+ <Compile Include="Compute\Forked\ForkedBinarizableClosureTaskTest.cs" />
<Compile Include="Compute\Forked\ForkedResourceTaskTest.cs" />
<Compile Include="Compute\Forked\ForkedSerializableClosureTaskTest.cs" />
<Compile Include="Compute\Forked\ForkedTaskAdapterTest.cs" />
@@ -94,8 +94,8 @@
<Compile Include="Compute\ComputeMultithreadedTest.cs" />
<Compile Include="Compute\IgniteExceptionTaskSelfTest.cs" />
<Compile Include="Compute\FailoverTaskSelfTest.cs" />
- <Compile Include="Compute\PortableClosureTaskTest.cs" />
- <Compile Include="Compute\PortableTaskTest.cs" />
+ <Compile Include="Compute\BinarizableClosureTaskTest.cs" />
+ <Compile Include="Compute\BinarizableTaskTest.cs" />
<Compile Include="Compute\ResourceTaskTest.cs" />
<Compile Include="Compute\SerializableClosureTaskTest.cs" />
<Compile Include="Compute\TaskAdapterTest.cs" />
@@ -116,21 +116,21 @@
<Compile Include="IgniteManagerTest.cs" />
<Compile Include="MarshallerTest.cs" />
<Compile Include="MessagingTest.cs" />
- <Compile Include="PortableConfigurationTest.cs" />
- <Compile Include="Portable\PortableStructureTest.cs" />
+ <Compile Include="BinaryConfigurationTest.cs" />
+ <Compile Include="Binary\BinaryStructureTest.cs" />
<Compile Include="SerializationTest.cs" />
<Compile Include="IgniteStartStopTest.cs" />
<Compile Include="TestUtils.cs" />
<Compile Include="Memory\InteropMemoryTest.cs" />
- <Compile Include="Portable\PortableApiSelfTest.cs" />
- <Compile Include="Portable\PortableSelfTest.cs" />
+ <Compile Include="Binary\BinaryBuilderSelfTest.cs" />
+ <Compile Include="Binary\BinarySelfTest.cs" />
<Compile Include="Process\IgniteProcess.cs" />
<Compile Include="Process\IgniteProcessConsoleOutputReader.cs" />
<Compile Include="Process\IIgniteProcessOutputReader.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Query\ImplicitPortablePerson.cs" />
- <Compile Include="Query\NoDefPortablePerson.cs" />
- <Compile Include="Query\PortablePerson.cs" />
+ <Compile Include="Query\ImplicitBinarizablePerson.cs" />
+ <Compile Include="Query\NoDefBinarizablePerson.cs" />
+ <Compile Include="Query\BinarizablePerson.cs" />
<Compile Include="Services\ServicesTest.cs" />
<Compile Include="Services\ServicesTestAsync.cs" />
<Compile Include="Services\ServiceProxyTest.cs" />
@@ -161,7 +161,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
- <Content Include="Config\cache-portables.xml">
+ <Content Include="Config\cache-binarizables.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Config\cache-query-continuous.xml">
@@ -207,7 +207,7 @@
<Content Include="Config\marshaller-invalid.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
- <Content Include="Config\marshaller-portable.xml">
+ <Content Include="Config\marshaller-explicit.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Config\native-client-test-cache-affinity.xml">
@@ -222,7 +222,7 @@
<Content Include="Config\native-client-test-cache.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
- <Content Include="Config\portable.xml">
+ <Content Include="Config\binary.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Config\start-test-grid1.xml">
@@ -241,6 +241,7 @@
</Content>
</ItemGroup>
<ItemGroup>
+ <None Include="Apache.Ignite.Core.Tests.nunit" />
<None Include="Apache.Ignite.Core.Tests.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit
new file mode 100644
index 0000000..7aeb108
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.nunit
@@ -0,0 +1,7 @@
+<NUnitProject>
+ <Settings activeconfig="Debug" />
+ <Config name="Debug" binpathtype="Auto">
+ <assembly path="bin\x64\Debug\Apache.Ignite.Core.Tests.exe" />
+ </Config>
+ <Config name="Release" binpathtype="Auto" />
+</NUnitProject>
\ No newline at end of file
[45/55] [abbrv] ignite git commit: IGNITE-1970: Binaries: simplified
header reading.
Posted by ag...@apache.org.
IGNITE-1970: Binaries: simplified header reading.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f37863a4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f37863a4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f37863a4
Branch: refs/heads/ignite-1.5
Commit: f37863a43bceebcc38af750c403efb35955b70df
Parents: 9c71785
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 15:19:00 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 15:19:00 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryReaderExImpl.java | 65 ++++++++++++--------
1 file changed, 38 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f37863a4/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 356aaae..5d31670 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -28,7 +28,6 @@ import org.apache.ignite.internal.portable.streams.PortableInputStream;
import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -186,47 +185,59 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
start = in.position();
- // Parse header if possible.
- byte hdr = in.readBytePositioned(start);
+ byte hdr = in.readByte();
+ // Perform full header parsing in case of portable object.
if (hdr == GridPortableMarshaller.OBJ) {
- // Skip header.
- in.readByte();
-
// Ensure protocol is fine.
PortableUtils.checkProtocolVersion(in.readByte());
- // Read and parse flags.
+ // Read header content.
short flags = in.readShort();
+ int typeId0 = in.readInt();
- userType = PortableUtils.isUserType(flags);
+ in.readInt(); // Skip hash code.
+ int len = in.readInt();
+ schemaId = in.readInt();
+ int offset = in.readInt();
+
+ // Get trivial flag values.
+ userType = PortableUtils.isUserType(flags);
fieldIdLen = PortableUtils.fieldIdLength(flags);
fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
- int typeId0 = in.readIntPositioned(start + GridPortableMarshaller.TYPE_ID_POS);
+ // Calculate footer borders and raw offset.
+ if (PortableUtils.hasSchema(flags)) {
+ // Schema exists.
+ footerStart = start + offset;
- IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(in, start);
-
- footerStart = footer.get1();
- footerLen = footer.get2() - footerStart;
-
- schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS);
+ if (PortableUtils.hasRaw(flags)) {
+ footerLen = len - offset - 4;
+ rawOff = start + in.readIntPositioned(start + len - 4);
+ }
+ else {
+ footerLen = len - offset;
+ rawOff = start + len;
+ }
+ }
+ else {
+ // No schema.
+ footerStart = start + len;
+ footerLen = 0;
- rawOff = PortableUtils.rawOffsetAbsolute(in, start);
+ if (PortableUtils.hasRaw(flags))
+ rawOff = start + offset;
+ else
+ rawOff = start + len;
+ }
+ // Finally, we have to resolve real type ID.
if (typeId0 == UNREGISTERED_TYPE_ID) {
- // Skip to the class name position.
- in.position(start + GridPortableMarshaller.DFLT_HDR_LEN);
-
int off = in.position();
- Class cls = doReadClass(typeId0);
-
- // registers class by typeId, at least locally if the cache is not ready yet.
- PortableClassDescriptor desc = ctx.descriptorForClass(cls);
-
- typeId = desc.typeId();
+ // Registers class by type ID, at least locally if the cache is not ready yet.
+ typeId = ctx.descriptorForClass(doReadClass(typeId0)).typeId();
int clsNameLen = in.position() - off;
@@ -240,8 +251,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
idMapper = userType ? ctx.userTypeIdMapper(typeId) : null;
schema = PortableUtils.hasSchema(flags) ? getOrCreateSchema() : null;
-
- in.position(start);
}
else {
typeId = 0;
@@ -256,6 +265,8 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
fieldOffsetLen = 0;
schema = null;
}
+
+ in.position(start);
}
/**
[20/55] [abbrv] ignite git commit: IGNITE-1816: Implemented compact
footers.
Posted by ag...@apache.org.
IGNITE-1816: Implemented compact footers.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0b4a8f83
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0b4a8f83
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0b4a8f83
Branch: refs/heads/ignite-1.5
Commit: 0b4a8f831fe2d183e6e831c90da0d3fc86ac2ed0
Parents: 66c84ea
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 18 14:54:38 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 18 14:54:38 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 6 +
.../ignite/internal/IgniteNodeAttributes.java | 3 +
.../portable/BinaryCachingMetadataHandler.java | 70 +
.../internal/portable/BinaryMetadata.java | 16 +-
.../portable/BinaryMetadataCollector.java | 49 +-
.../internal/portable/BinaryObjectEx.java | 2 +-
.../internal/portable/BinaryObjectImpl.java | 14 +-
.../portable/BinaryObjectOffheapImpl.java | 14 +-
.../internal/portable/BinaryReaderExImpl.java | 132 +-
.../internal/portable/BinaryTypeImpl.java | 7 +-
.../internal/portable/BinaryWriterExImpl.java | 161 +-
.../portable/PortableClassDescriptor.java | 102 +-
.../internal/portable/PortableContext.java | 66 +-
.../internal/portable/PortableSchema.java | 296 +-
.../ignite/internal/portable/PortableUtils.java | 457 ++-
.../builder/BinaryObjectBuilderImpl.java | 130 +-
.../portable/builder/PortableBuilderReader.java | 21 +-
.../portable/CacheObjectBinaryProcessor.java | 2 +-
.../CacheObjectBinaryProcessorImpl.java | 162 +-
.../platform/PlatformContextImpl.java | 10 +-
.../cpp/PlatformCppConfigurationClosure.java | 9 +-
.../PlatformDotNetConfigurationClosure.java | 9 +-
.../ignite/internal/util/IgniteUtils.java | 25 +
.../marshaller/portable/PortableMarshaller.java | 38 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 51 +-
.../portable/BinaryFieldsAbstractSelfTest.java | 13 +-
.../BinaryFooterOffsetsAbstractSelfTest.java | 199 +
.../BinaryFooterOffsetsHeapSelfTest.java | 32 +
.../BinaryFooterOffsetsOffheapSelfTest.java | 61 +
.../portable/BinaryMarshallerSelfTest.java | 3795 ++++++++++++++++++
.../BinaryObjectBuilderAdditionalSelfTest.java | 1291 ++++++
.../portable/BinaryObjectBuilderSelfTest.java | 1066 +++++
...idBinaryObjectBuilderAdditionalSelfTest.java | 1280 ------
.../GridBinaryObjectBuilderSelfTest.java | 1053 -----
...idPortableMarshallerCtxDisabledSelfTest.java | 2 +-
.../GridPortableMarshallerSelfTest.java | 3760 -----------------
.../PortableCompactOffsetsAbstractSelfTest.java | 190 -
.../PortableCompactOffsetsHeapSelfTest.java | 32 -
.../PortableCompactOffsetsOffheapSelfTest.java | 61 -
.../BinaryFieldsHeapNonCompactSelfTest.java | 34 +
.../BinaryFieldsOffheapNonCompactSelfTest.java | 30 +
...naryFooterOffsetsHeapNonCompactSelfTest.java | 30 +
...yFooterOffsetsOffheapNonCompactSelfTest.java | 30 +
.../BinaryMarshallerNonCompactSelfTest.java | 30 +
...jectBuilderAdditionalNonCompactSelfTest.java | 30 +
.../BinaryObjectBuilderNonCompactSelfTest.java | 30 +
.../IgnitePortableObjectsTestSuite.java | 36 +-
.../core-test/src/binary_reader_writer_test.cpp | 64 +-
.../include/ignite/impl/binary/binary_common.h | 22 +-
.../ignite/impl/binary/binary_reader_impl.h | 58 +-
.../include/ignite/impl/binary/binary_schema.h | 6 +-
.../ignite/impl/binary/binary_writer_impl.h | 2 +-
.../core/src/impl/binary/binary_reader_impl.cpp | 8 +-
.../cpp/core/src/impl/binary/binary_schema.cpp | 12 +-
.../core/src/impl/binary/binary_writer_impl.cpp | 29 +-
.../Config/Compute/compute-grid1.xml | 1 +
.../Config/marshaller-explicit.xml | 4 +-
.../Impl/Binary/BinaryObjectBuilder.cs | 25 +-
.../Impl/Binary/BinaryObjectHeader.cs | 131 +-
.../Impl/Binary/BinaryObjectSchemaHolder.cs | 9 +-
.../Impl/Binary/BinaryReader.cs | 2 +-
.../Impl/Binary/BinaryWriter.cs | 27 +-
.../Impl/Binary/IgniteBinary.cs | 3 +-
63 files changed, 8154 insertions(+), 7186 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index c4829a4..2b6eaad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -157,6 +157,7 @@ import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.lifecycle.LifecycleEventType;
import org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
import org.apache.ignite.mxbean.ClusterLocalNodeMetricsMXBean;
import org.apache.ignite.mxbean.IgniteMXBean;
import org.apache.ignite.mxbean.ThreadPoolMXBean;
@@ -201,6 +202,7 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_JVM_PID;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_LANG_RUNTIME;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_COMPACT_FOOTER;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER_USE_DFLT_SUID;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTENT_ID;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
@@ -1272,6 +1274,10 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName());
add(ATTR_MARSHALLER_USE_DFLT_SUID,
getBoolean(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, OptimizedMarshaller.USE_DFLT_SUID));
+
+ if (cfg.getMarshaller() instanceof PortableMarshaller)
+ add(ATTR_MARSHALLER_COMPACT_FOOTER, ((PortableMarshaller)cfg.getMarshaller()).isCompactFooter());
+
add(ATTR_USER_NAME, System.getProperty("user.name"));
add(ATTR_GRID_NAME, gridName);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index 86a460d..946b686 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -36,6 +36,9 @@ public final class IgniteNodeAttributes {
/** Internal attribute name constant. */
public static final String ATTR_MARSHALLER_USE_DFLT_SUID = ATTR_PREFIX + ".marshaller.useDefaultSUID";
+ /** Attribute for marshaller compact footers. */
+ public static final String ATTR_MARSHALLER_COMPACT_FOOTER = ATTR_PREFIX + ".marshaller.compactFooter";
+
/** Internal attribute name constant. */
public static final String ATTR_JIT_NAME = ATTR_PREFIX + ".jit.name";
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java
new file mode 100644
index 0000000..a3c846b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
+
+import java.util.HashMap;
+
+/**
+ * Simple caching metadata handler. Used mainly in tests.
+ */
+public class BinaryCachingMetadataHandler implements BinaryMetadataHandler {
+ /** Cached metadatas. */
+ private final HashMap<Integer, BinaryType> metas = new HashMap<>();
+
+ /**
+ * Create new handler instance.
+ *
+ * @return New handler.
+ */
+ public static BinaryCachingMetadataHandler create() {
+ return new BinaryCachingMetadataHandler();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private BinaryCachingMetadataHandler() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized void addMeta(int typeId, BinaryType type) throws BinaryObjectException {
+ synchronized (this) {
+ BinaryType oldType = metas.put(typeId, type);
+
+ if (oldType != null) {
+ BinaryMetadata oldMeta = ((BinaryTypeImpl)oldType).metadata();
+ BinaryMetadata newMeta = ((BinaryTypeImpl)type).metadata();
+
+ BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta);
+
+ BinaryType mergedType = mergedMeta.wrap(((BinaryTypeImpl)oldType).context());
+
+ metas.put(typeId, mergedType);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public synchronized BinaryType metadata(int typeId) throws BinaryObjectException {
+ return metas.get(typeId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java
index fe88d11..a464d6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadata.java
@@ -49,6 +49,9 @@ public class BinaryMetadata implements Externalizable {
/** Affinity key field name. */
private String affKeyFieldName;
+ /** Schemas associated with type. */
+ private Collection<PortableSchema> schemas;
+
/**
* For {@link Externalizable}.
*/
@@ -63,15 +66,17 @@ public class BinaryMetadata implements Externalizable {
* @param typeName Type name.
* @param fields Fields map.
* @param affKeyFieldName Affinity key field name.
+ * @param schemas Schemas.
*/
public BinaryMetadata(int typeId, String typeName, @Nullable Map<String, Integer> fields,
- @Nullable String affKeyFieldName) {
+ @Nullable String affKeyFieldName, @Nullable Collection<PortableSchema> schemas) {
assert typeName != null;
this.typeId = typeId;
this.typeName = typeName;
this.fields = fields;
this.affKeyFieldName = affKeyFieldName;
+ this.schemas = schemas;
}
/**
@@ -120,6 +125,13 @@ public class BinaryMetadata implements Externalizable {
}
/**
+ * @return Schemas.
+ */
+ public Collection<PortableSchema> schemas() {
+ return schemas != null ? schemas : Collections.<PortableSchema>emptyList();
+ }
+
+ /**
* Wrap metadata into binary type.
*
* @param ctx Portable context.
@@ -135,6 +147,7 @@ public class BinaryMetadata implements Externalizable {
U.writeString(out, typeName);
U.writeMap(out, fields);
U.writeString(out, affKeyFieldName);
+ U.writeCollection(out, schemas);
}
/** {@inheritDoc} */
@@ -143,6 +156,7 @@ public class BinaryMetadata implements Externalizable {
typeName = U.readString(in);
fields = U.readMap(in);
affKeyFieldName = U.readString(in);
+ schemas = U.readCollection(in);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
index 67e1a0d..28eb1d0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryMetadataCollector.java
@@ -17,6 +17,12 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.jetbrains.annotations.Nullable;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -27,26 +33,37 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.jetbrains.annotations.Nullable;
/**
* Writer for meta data collection.
*/
class BinaryMetadataCollector implements BinaryWriter {
- /** */
- private final Map<String, Integer> meta = new HashMap<>();
+ /** Type ID. */
+ private final int typeId;
- /** */
+ /** Type name. */
private final String typeName;
+ /** ID mapper. */
+ private final BinaryIdMapper idMapper;
+
+ /** Collected metadata. */
+ private final Map<String, Integer> meta = new HashMap<>();
+
+ /** Schema builder. */
+ private PortableSchema.Builder schemaBuilder = PortableSchema.Builder.newBuilder();
+
/**
+ * Constructor.
+ *
+ * @param typeId Type ID.
* @param typeName Type name.
+ * @param idMapper ID mapper.
*/
- BinaryMetadataCollector(String typeName) {
+ BinaryMetadataCollector(int typeId, String typeName, BinaryIdMapper idMapper) {
+ this.typeId = typeId;
this.typeName = typeName;
+ this.idMapper = idMapper;
}
/**
@@ -56,6 +73,13 @@ class BinaryMetadataCollector implements BinaryWriter {
return meta;
}
+ /**
+ * @return Schemas.
+ */
+ PortableSchema schema() {
+ return schemaBuilder.build();
+ }
+
/** {@inheritDoc} */
@Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
add(fieldName, PortableClassDescriptor.Mode.BYTE);
@@ -242,13 +266,12 @@ class BinaryMetadataCollector implements BinaryWriter {
if (oldFieldTypeId != null && !oldFieldTypeId.equals(fieldTypeId)) {
throw new BinaryObjectException(
- "Field is written twice with different types [" +
- "typeName=" + typeName +
- ", fieldName=" + name +
+ "Field is written twice with different types [" + "typeName=" + typeName + ", fieldName=" + name +
", fieldTypeName1=" + PortableUtils.fieldTypeName(oldFieldTypeId) +
- ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) +
- ']'
+ ", fieldTypeName2=" + PortableUtils.fieldTypeName(fieldTypeId) + ']'
);
}
+
+ schemaBuilder.addField(idMapper.fieldId(typeId, name));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
index b3512ce..6902675 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectEx.java
@@ -170,7 +170,7 @@ public abstract class BinaryObjectEx implements BinaryObject {
}
if (meta == null)
- return "PortableObject [hash=" + idHash + ", typeId=" + typeId() + ']';
+ return BinaryObject.class.getSimpleName() + " [hash=" + idHash + ", typeId=" + typeId() + ']';
handles.put(this, idHash);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
index d432ea0..d9339f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectImpl.java
@@ -251,7 +251,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
if (ctx == null)
throw new BinaryObjectException("PortableContext is not set for the object.");
- return ctx.metaData(typeId());
+ return ctx.metadata(typeId());
}
/** {@inheritDoc} */
@@ -279,15 +279,17 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
int schemaOffset = PortablePrimitives.readInt(arr, start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
short flags = PortablePrimitives.readShort(arr, start + GridPortableMarshaller.FLAGS_POS);
- int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
- int fieldOffsetPos = start + schemaOffset + order * (4 + fieldOffsetSize) + 4;
+ int fieldIdLen = PortableUtils.isCompactFooter(flags) ? 0 : PortableUtils.FIELD_ID_LEN;
+ int fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
+
+ int fieldOffsetPos = start + schemaOffset + order * (fieldIdLen + fieldOffsetLen) + fieldIdLen;
int fieldPos;
- if (fieldOffsetSize == PortableUtils.OFFSET_1)
+ if (fieldOffsetLen == PortableUtils.OFFSET_1)
fieldPos = start + ((int)PortablePrimitives.readByte(arr, fieldOffsetPos) & 0xFF);
- else if (fieldOffsetSize == PortableUtils.OFFSET_2)
+ else if (fieldOffsetLen == PortableUtils.OFFSET_2)
fieldPos = start + ((int)PortablePrimitives.readShort(arr, fieldOffsetPos) & 0xFFFF);
else
fieldPos = start + PortablePrimitives.readInt(arr, fieldOffsetPos);
@@ -458,7 +460,7 @@ public final class BinaryObjectImpl extends BinaryObjectEx implements Externaliz
@Override protected PortableSchema createSchema() {
BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, start, null);
- return reader.createSchema();
+ return reader.getOrCreateSchema();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
index f7cb844..a71c98a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryObjectOffheapImpl.java
@@ -136,7 +136,7 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
start,
null);
- return reader.createSchema();
+ return reader.getOrCreateSchema();
}
/** {@inheritDoc} */
@@ -164,7 +164,7 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
if (ctx == null)
throw new BinaryObjectException("PortableContext is not set for the object.");
- return ctx.metaData(typeId());
+ return ctx.metadata(typeId());
}
/** {@inheritDoc} */
@@ -198,15 +198,17 @@ public class BinaryObjectOffheapImpl extends BinaryObjectEx implements Externali
int schemaOffset = PortablePrimitives.readInt(ptr, start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
short flags = PortablePrimitives.readShort(ptr, start + GridPortableMarshaller.FLAGS_POS);
- int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
- int fieldOffsetPos = start + schemaOffset + order * (4 + fieldOffsetSize) + 4;
+ int fieldIdLen = PortableUtils.isCompactFooter(flags) ? 0 : PortableUtils.FIELD_ID_LEN;
+ int fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
+
+ int fieldOffsetPos = start + schemaOffset + order * (fieldIdLen + fieldOffsetLen) + fieldIdLen;
int fieldPos;
- if (fieldOffsetSize == PortableUtils.OFFSET_1)
+ if (fieldOffsetLen == PortableUtils.OFFSET_1)
fieldPos = start + ((int)PortablePrimitives.readByte(ptr, fieldOffsetPos) & 0xFF);
- else if (fieldOffsetSize == PortableUtils.OFFSET_2)
+ else if (fieldOffsetLen == PortableUtils.OFFSET_2)
fieldPos = start + ((int)PortablePrimitives.readShort(ptr, fieldOffsetPos) & 0xFFFF);
else
fieldPos = start + PortablePrimitives.readInt(ptr, fieldOffsetPos);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index 669ba01..6ff3047 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -17,6 +17,23 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
+import org.apache.ignite.internal.portable.streams.PortableInputStream;
+import org.apache.ignite.internal.util.GridEnumCache;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -30,7 +47,6 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
@@ -39,22 +55,6 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryInvalidTypeException;
-import org.apache.ignite.binary.BinaryRawReader;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
-import org.apache.ignite.internal.portable.streams.PortableInputStream;
-import org.apache.ignite.internal.util.GridEnumCache;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.ARR_LIST;
@@ -117,9 +117,6 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_AR
*/
@SuppressWarnings("unchecked")
public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, ObjectInput {
- /** Length of a single field descriptor. */
- private static final int FIELD_DESC_LEN = 16;
-
/** */
private final PortableContext ctx;
@@ -162,8 +159,14 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
/** Schema Id. */
private int schemaId;
+ /** Whether this is user type or not. */
+ private boolean userType;
+
+ /** Whether field IDs exist. */
+ private int fieldIdLen;
+
/** Offset size in bytes. */
- private int offsetSize;
+ private int fieldOffsetLen;
/** Object schema. */
private PortableSchema schema;
@@ -225,18 +228,21 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
short flags = in.readShort();
- offsetSize = PortableUtils.fieldOffsetSize(flags);
+ userType = PortableUtils.isUserType(flags);
+
+ fieldIdLen = PortableUtils.fieldIdLength(flags);
+ fieldOffsetLen = PortableUtils.fieldOffsetLength(flags);
typeId = in.readIntPositioned(start + GridPortableMarshaller.TYPE_ID_POS);
- IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(in, start, offsetSize);
+ IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(in, start);
footerStart = footer.get1();
footerLen = footer.get2() - footerStart;
schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS);
- rawOff = PortableUtils.rawOffsetAbsolute(in, start, offsetSize);
+ rawOff = PortableUtils.rawOffsetAbsolute(in, start);
if (typeId == UNREGISTERED_TYPE_ID) {
// Skip to the class name position.
@@ -2555,29 +2561,68 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/**
- * Create schema.
+ * Get or create object schema.
*
* @return Schema.
*/
- public PortableSchema createSchema() {
+ public PortableSchema getOrCreateSchema() {
parseHeaderIfNeeded();
- LinkedHashMap<Integer, Integer> fields = new LinkedHashMap<>();
+ PortableSchema schema = ctx.schemaRegistry(typeId).schema(schemaId);
+
+ if (schema == null) {
+ if (fieldIdLen != PortableUtils.FIELD_ID_LEN) {
+ BinaryTypeImpl type = (BinaryTypeImpl)ctx.metadata(typeId);
+
+ if (type == null || type.metadata() == null)
+ throw new BinaryObjectException("Cannot find metadata for object with compact footer: " +
+ typeId);
+
+ for (PortableSchema typeSchema : type.metadata().schemas()) {
+ if (schemaId == typeSchema.schemaId()) {
+ schema = typeSchema;
+
+ break;
+ }
+ }
+
+ if (schema == null)
+ throw new BinaryObjectException("Cannot find schema for object with compact footer [" +
+ "typeId=" + typeId + ", schemaId=" + schemaId + ']');
+ }
+ else
+ schema = createSchema();
+
+ assert schema != null;
+
+ ctx.schemaRegistry(typeId).addSchema(schemaId, schema);
+ }
+
+ return schema;
+ }
+
+ /**
+ * Create schema.
+ *
+ * @return Schema.
+ */
+ private PortableSchema createSchema() {
+ assert fieldIdLen == PortableUtils.FIELD_ID_LEN;
+
+ PortableSchema.Builder builder = PortableSchema.Builder.newBuilder();
int searchPos = footerStart;
int searchEnd = searchPos + footerLen;
- int idx = 0;
-
while (searchPos < searchEnd) {
int fieldId = in.readIntPositioned(searchPos);
- fields.put(fieldId, idx++);
+ builder.addField(fieldId);
- searchPos += 4 + offsetSize;
+ searchPos += PortableUtils.FIELD_ID_LEN + fieldOffsetLen;
}
- return new PortableSchema(fields);
+ return builder.build();
}
/**
@@ -2593,7 +2638,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
int searchPos = footerStart;
int searchTail = searchPos + footerLen;
- if (hasLowFieldsCount(footerLen)) {
+ if (!userType || (fieldIdLen != 0 && hasLowFieldsCount(footerLen))) {
while (true) {
if (searchPos >= searchTail)
return 0;
@@ -2601,37 +2646,32 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
int id0 = in.readIntPositioned(searchPos);
if (id0 == id) {
- int pos = start + PortableUtils.fieldOffsetRelative(in, searchPos + 4, offsetSize);
+ int pos = start + PortableUtils.fieldOffsetRelative(in, searchPos + PortableUtils.FIELD_ID_LEN,
+ fieldOffsetLen);
in.position(pos);
return pos;
}
- searchPos += 4 + offsetSize;
+ searchPos += PortableUtils.FIELD_ID_LEN + fieldOffsetLen;
}
}
else {
PortableSchema schema0 = schema;
if (schema0 == null) {
- schema0 = ctx.schemaRegistry(typeId).schema(schemaId);
-
- if (schema0 == null) {
- schema0 = createSchema();
-
- ctx.schemaRegistry(typeId).addSchema(schemaId, schema0);
- }
+ schema0 = getOrCreateSchema();
schema = schema0;
}
- int order = schema.order(id);
+ int order = schema0.order(id);
if (order != PortableSchema.ORDER_NOT_FOUND) {
- int offsetPos = footerStart + order * (4 + offsetSize) + 4;
+ int offsetPos = footerStart + order * (fieldIdLen + fieldOffsetLen) + fieldIdLen;
- int pos = start + PortableUtils.fieldOffsetRelative(in, offsetPos, offsetSize);
+ int pos = start + PortableUtils.fieldOffsetRelative(in, offsetPos, fieldOffsetLen);
in.position(pos);
@@ -2650,7 +2690,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
private boolean hasLowFieldsCount(int footerLen) {
assert hdrParsed;
- return footerLen < (FIELD_DESC_LEN << 4);
+ return footerLen < ((fieldOffsetLen + fieldIdLen) << 3);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
index 40b6252..60c135d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
@@ -62,10 +62,15 @@ public class BinaryTypeImpl implements BinaryType {
return ctx.createField(meta.typeId(), fieldName);
}
- public String affinityKeyFieldName() {
+ /** {@inheritDoc} */
+ @Override public String affinityKeyFieldName() {
return meta.affinityKeyFieldName();
}
+ /** {@inheritDoc} */
+ public PortableContext context() {
+ return ctx;
+ }
/**
* @return Metadata.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
index cedf1c8..6cb18fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
@@ -90,15 +90,9 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** Length: integer. */
private static final int LEN_INT = 4;
- /** */
+ /** Initial capacity. */
private static final int INIT_CAP = 1024;
- /** FNV1 hash offset basis. */
- private static final int FNV1_OFFSET_BASIS = 0x811C9DC5;
-
- /** FNV1 hash prime. */
- private static final int FNV1_PRIME = 0x01000193;
-
/** Maximum offset which fits in 1 byte. */
private static final int MAX_OFFSET_1 = 1 << 8;
@@ -139,7 +133,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
private SchemaHolder schema;
/** Schema ID. */
- private int schemaId;
+ private int schemaId = PortableUtils.schemaInitialId();
/** Amount of written fields. */
private int fieldCnt;
@@ -332,6 +326,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/**
* Perform post-write activity. This includes:
+ * - writing flags;
* - writing object length;
* - writing schema offset;
* - writing schema to the tail.
@@ -339,7 +334,16 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
* @param userType User type flag.
*/
public void postWrite(boolean userType) {
+ short flags = userType ? PortableUtils.FLAG_USR_TYP : 0;
+
+ boolean useCompactFooter = ctx.isCompactFooter() && userType;
+
+ if (useCompactFooter)
+ flags |= PortableUtils.FLAG_COMPACT_FOOTER;
+
if (schema != null) {
+ flags |= PortableUtils.FLAG_HAS_SCHEMA;
+
// Write schema ID.
out.writeInt(start + SCHEMA_ID_POS, schemaId);
@@ -347,34 +351,35 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, out.position() - start);
// Write the schema.
- int offsetByteCnt = schema.write(this, fieldCnt);
+ int offsetByteCnt = schema.write(this, fieldCnt, useCompactFooter);
+ if (offsetByteCnt == PortableUtils.OFFSET_1)
+ flags |= PortableUtils.FLAG_OFFSET_ONE_BYTE;
+ else if (offsetByteCnt == PortableUtils.OFFSET_2)
+ flags |= PortableUtils.FLAG_OFFSET_TWO_BYTES;
+
// Write raw offset if needed.
- if (rawOffPos != 0)
- out.writeInt(rawOffPos - start);
-
- if (offsetByteCnt == PortableUtils.OFFSET_1) {
- int flags = (userType ? PortableUtils.FLAG_USR_TYP : 0) | PortableUtils.FLAG_OFFSET_ONE_BYTE;
-
- out.writeShort(start + FLAGS_POS, (short)flags);
- }
- else if (offsetByteCnt == PortableUtils.OFFSET_2) {
- int flags = (userType ? PortableUtils.FLAG_USR_TYP : 0) | PortableUtils.FLAG_OFFSET_TWO_BYTES;
+ if (rawOffPos != 0) {
+ flags |= PortableUtils.FLAG_HAS_RAW;
- out.writeShort(start + FLAGS_POS, (short)flags);
+ out.writeInt(rawOffPos - start);
}
}
else {
- // Write raw-only flag is needed.
- int flags = (userType ? PortableUtils.FLAG_USR_TYP : 0) | PortableUtils.FLAG_RAW_ONLY;
-
- out.writeShort(start + FLAGS_POS, (short)flags);
+ if (rawOffPos != 0) {
+ // If there are no schema, we are free to write raw offset to schema offset.
+ flags |= PortableUtils.FLAG_HAS_RAW;
- // If there are no schema, we are free to write raw offset to schema offset.
- out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, (rawOffPos == 0 ? out.position() : rawOffPos) - start);
+ out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, rawOffPos - start);
+ }
+ else
+ out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, 0);
}
- // 5. Write length.
+ // Write flags.
+ out.writeShort(start + FLAGS_POS, flags);
+
+ // Write length.
out.writeInt(start + TOTAL_LEN_POS, out.position() - start);
}
@@ -1737,22 +1742,9 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
SCHEMA.set(schema);
}
-
- // Initialize offset when the first field is written.
- schemaId = FNV1_OFFSET_BASIS;
}
- // Advance schema hash.
- int schemaId0 = schemaId ^ (fieldId & 0xFF);
- schemaId0 = schemaId0 * FNV1_PRIME;
- schemaId0 = schemaId0 ^ ((fieldId >> 8) & 0xFF);
- schemaId0 = schemaId0 * FNV1_PRIME;
- schemaId0 = schemaId0 ^ ((fieldId >> 16) & 0xFF);
- schemaId0 = schemaId0 * FNV1_PRIME;
- schemaId0 = schemaId0 ^ ((fieldId >> 24) & 0xFF);
- schemaId0 = schemaId0 * FNV1_PRIME;
-
- schemaId = schemaId0;
+ schemaId = PortableUtils.updateSchemaId(schemaId, fieldId);
schema.push(fieldId, fieldOff);
@@ -1760,6 +1752,25 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
+ * @return Current schema ID.
+ */
+ public int schemaId() {
+ return schemaId;
+ }
+
+ /**
+ * @return Current writer's schema.
+ */
+ public PortableSchema currentSchema() {
+ PortableSchema.Builder builder = PortableSchema.Builder.newBuilder();
+
+ if (schema != null)
+ schema.build(builder, fieldCnt);
+
+ return builder.build();
+ }
+
+ /**
* Attempts to write the object as a handle.
*
* @param obj Object to write.
@@ -1844,13 +1855,25 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
+ * Build the schema.
+ *
+ * @param builder Builder.
+ * @param fieldCnt Fields count.
+ */
+ public void build(PortableSchema.Builder builder, int fieldCnt) {
+ for (int curIdx = idx - fieldCnt * 2; curIdx < idx; curIdx += 2)
+ builder.addField(data[curIdx]);
+ }
+
+ /**
* Write collected frames and pop them.
*
* @param writer Writer.
* @param fieldCnt Count.
- * @return Amount of bytes dedicated to
+ * @param compactFooter Whether footer should be written in compact form.
+ * @return Amount of bytes dedicated to each field offset. Could be 1, 2 or 4.
*/
- public int write(BinaryWriterExImpl writer, int fieldCnt) {
+ public int write(BinaryWriterExImpl writer, int fieldCnt, boolean compactFooter) {
int startIdx = idx - fieldCnt * 2;
assert startIdx >= 0;
@@ -1859,29 +1882,51 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
int res;
- if (lastOffset < MAX_OFFSET_1) {
- for (int idx0 = startIdx; idx0 < idx; ) {
- writer.writeInt(data[idx0++]);
- writer.writeByte((byte) data[idx0++]);
+ if (compactFooter) {
+ if (lastOffset < MAX_OFFSET_1) {
+ for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
+ writer.writeByte((byte)data[curIdx]);
+
+ res = PortableUtils.OFFSET_1;
}
+ else if (lastOffset < MAX_OFFSET_2) {
+ for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
+ writer.writeShort((short)data[curIdx]);
- res = PortableUtils.OFFSET_1;
- }
- else if (lastOffset < MAX_OFFSET_2) {
- for (int idx0 = startIdx; idx0 < idx; ) {
- writer.writeInt(data[idx0++]);
- writer.writeShort((short)data[idx0++]);
+ res = PortableUtils.OFFSET_2;
}
+ else {
+ for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
+ writer.writeInt(data[curIdx]);
- res = PortableUtils.OFFSET_2;
+ res = PortableUtils.OFFSET_4;
+ }
}
else {
- for (int idx0 = startIdx; idx0 < idx; ) {
- writer.writeInt(data[idx0++]);
- writer.writeInt(data[idx0++]);
+ if (lastOffset < MAX_OFFSET_1) {
+ for (int curIdx = startIdx; curIdx < idx;) {
+ writer.writeInt(data[curIdx++]);
+ writer.writeByte((byte) data[curIdx++]);
+ }
+
+ res = PortableUtils.OFFSET_1;
+ }
+ else if (lastOffset < MAX_OFFSET_2) {
+ for (int curIdx = startIdx; curIdx < idx;) {
+ writer.writeInt(data[curIdx++]);
+ writer.writeShort((short)data[curIdx++]);
+ }
+
+ res = PortableUtils.OFFSET_2;
}
+ else {
+ for (int curIdx = startIdx; curIdx < idx;) {
+ writer.writeInt(data[curIdx++]);
+ writer.writeInt(data[curIdx++]);
+ }
- res = PortableUtils.OFFSET_4;
+ res = PortableUtils.OFFSET_4;
+ }
}
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 225e0ba..8543ce6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -38,6 +38,7 @@ import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -79,6 +80,9 @@ public class PortableClassDescriptor {
/** */
private final String typeName;
+ /** Affinity key field name. */
+ private final String affKeyFieldName;
+
/** */
private final Constructor<?> ctor;
@@ -92,7 +96,13 @@ public class PortableClassDescriptor {
private final Method readResolveMtd;
/** */
- private final Map<String, Integer> fieldsMeta;
+ private final Map<String, Integer> stableFieldsMeta;
+
+ /** Object schemas. Initialized only for serializable classes and contains only 1 entry. */
+ private final Collection<PortableSchema> stableSchemas;
+
+ /** Schema registry. */
+ private final PortableSchemaRegistry schemaReg;
/** */
private final boolean keepDeserialized;
@@ -112,13 +122,14 @@ public class PortableClassDescriptor {
* @param userType User type flag.
* @param typeId Type ID.
* @param typeName Type name.
+ * @param affKeyFieldName Affinity key field name.
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param metaDataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @param registered Whether typeId has been successfully registered by MarshallerContext or not.
* @param predefined Whether the class is predefined or not.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
PortableClassDescriptor(
PortableContext ctx,
@@ -126,6 +137,7 @@ public class PortableClassDescriptor {
boolean userType,
int typeId,
String typeName,
+ @Nullable String affKeyFieldName,
@Nullable BinaryIdMapper idMapper,
@Nullable BinarySerializer serializer,
boolean metaDataEnabled,
@@ -135,17 +147,21 @@ public class PortableClassDescriptor {
) throws BinaryObjectException {
assert ctx != null;
assert cls != null;
+ assert idMapper != null;
this.ctx = ctx;
this.cls = cls;
- this.userType = userType;
this.typeId = typeId;
+ this.userType = userType;
this.typeName = typeName;
+ this.affKeyFieldName = affKeyFieldName;
this.serializer = serializer;
this.idMapper = idMapper;
this.keepDeserialized = keepDeserialized;
this.registered = registered;
+ schemaReg = ctx.schemaRegistry(typeId);
+
excluded = MarshallerExclusions.isExcluded(cls);
useOptMarshaller = !predefined && initUseOptimizedMarshallerFlag();
@@ -193,7 +209,8 @@ public class PortableClassDescriptor {
case EXCLUSION:
ctor = null;
fields = null;
- fieldsMeta = null;
+ stableFieldsMeta = null;
+ stableSchemas = null;
break;
@@ -201,16 +218,17 @@ public class PortableClassDescriptor {
case EXTERNALIZABLE:
ctor = constructor(cls);
fields = null;
- fieldsMeta = null;
+ stableFieldsMeta = null;
+ stableSchemas = null;
break;
case OBJECT:
- assert idMapper != null;
-
ctor = constructor(cls);
fields = new ArrayList<>();
- fieldsMeta = metaDataEnabled ? new HashMap<String, Integer>() : null;
+ stableFieldsMeta = metaDataEnabled ? new HashMap<String, Integer>() : null;
+
+ PortableSchema.Builder schemaBuilder = PortableSchema.Builder.newBuilder();
Collection<String> names = new HashSet<>();
Collection<Integer> ids = new HashSet<>();
@@ -236,12 +254,16 @@ public class PortableClassDescriptor {
fields.add(fieldInfo);
+ schemaBuilder.addField(fieldId);
+
if (metaDataEnabled)
- fieldsMeta.put(name, fieldInfo.fieldMode().typeId());
+ stableFieldsMeta.put(name, fieldInfo.fieldMode().typeId());
}
}
}
+ stableSchemas = Collections.singleton(schemaBuilder.build());
+
break;
default:
@@ -284,7 +306,14 @@ public class PortableClassDescriptor {
* @return Fields meta data.
*/
Map<String, Integer> fieldsMeta() {
- return fieldsMeta;
+ return stableFieldsMeta;
+ }
+
+ /**
+ * @return Schemas.
+ */
+ Collection<PortableSchema> schemas() {
+ return stableSchemas;
}
/**
@@ -345,7 +374,7 @@ public class PortableClassDescriptor {
/**
* @param obj Object.
* @param writer Writer.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
assert obj != null;
@@ -539,21 +568,34 @@ public class PortableClassDescriptor {
((Binarylizable)obj).writeBinary(writer);
writer.postWrite(userType);
- }
- finally {
- writer.popSchema();
- }
- if (obj.getClass() != BinaryMetadata.class
- && ctx.isMetaDataChanged(typeId, writer.metaDataHashSum())) {
- BinaryMetadataCollector metaCollector = new BinaryMetadataCollector(typeName);
+ // Check whether we need to update metadata.
+ if (obj.getClass() != BinaryMetadata.class) {
+ int schemaId = writer.schemaId();
- if (serializer != null)
- serializer.writeBinary(obj, metaCollector);
- else
- ((Binarylizable)obj).writeBinary(metaCollector);
+ if (schemaReg.schema(schemaId) == null) {
+ // This is new schema, let's update metadata.
+ BinaryMetadataCollector collector =
+ new BinaryMetadataCollector(typeId, typeName, idMapper);
+
+ if (serializer != null)
+ serializer.writeBinary(obj, collector);
+ else
+ ((Binarylizable)obj).writeBinary(collector);
+
+ PortableSchema newSchema = collector.schema();
- ctx.updateMetaData(typeId, typeName, metaCollector.meta());
+ BinaryMetadata meta = new BinaryMetadata(typeId, typeName, collector.meta(),
+ affKeyFieldName, Collections.singleton(newSchema));
+
+ ctx.updateMetadata(typeId, meta);
+
+ schemaReg.addSchema(newSchema.schemaId(), newSchema);
+ }
+ }
+ }
+ finally {
+ writer.popSchema();
}
}
@@ -601,7 +643,7 @@ public class PortableClassDescriptor {
/**
* @param reader Reader.
* @return Object.
- * @throws org.apache.ignite.binary.BinaryObjectException If failed.
+ * @throws BinaryObjectException If failed.
*/
Object read(BinaryReaderExImpl reader) throws BinaryObjectException {
assert reader != null;
@@ -683,7 +725,6 @@ public class PortableClassDescriptor {
PortableUtils.writeHeader(
writer,
- userType,
registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID,
obj instanceof CacheObjectImpl ? 0 : obj.hashCode(),
registered ? null : cls.getName()
@@ -694,7 +735,7 @@ public class PortableClassDescriptor {
/**
* @return Instance.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
private Object newInstance() throws BinaryObjectException {
assert ctor != null;
@@ -710,7 +751,7 @@ public class PortableClassDescriptor {
/**
* @param cls Class.
* @return Constructor.
- * @throws org.apache.ignite.binary.BinaryObjectException If constructor doesn't exist.
+ * @throws BinaryObjectException If constructor doesn't exist.
*/
@SuppressWarnings("ConstantConditions")
@Nullable private static Constructor<?> constructor(Class<?> cls) throws BinaryObjectException {
@@ -719,6 +760,9 @@ public class PortableClassDescriptor {
try {
Constructor<?> ctor = U.forceEmptyConstructor(cls);
+ if (ctor == null)
+ throw new BinaryObjectException("Failed to find empty constructor for class: " + cls.getName());
+
ctor.setAccessible(true);
return ctor;
@@ -871,7 +915,7 @@ public class PortableClassDescriptor {
/**
* @param obj Object.
* @param writer Writer.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
assert obj != null;
@@ -1074,7 +1118,7 @@ public class PortableClassDescriptor {
/**
* @param obj Object.
* @param reader Reader.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @throws BinaryObjectException In case of error.
*/
public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
Object val = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index 86578ad..afc23e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -61,7 +61,6 @@ import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.typedef.F;
@@ -107,9 +106,6 @@ public class PortableContext implements Externalizable {
}
/** */
- private final ConcurrentMap<Integer, Collection<Integer>> metaDataCache = new ConcurrentHashMap8<>();
-
- /** */
private final ConcurrentMap<Class<?>, PortableClassDescriptor> descByCls = new ConcurrentHashMap8<>();
/** Holds classes loaded by default class loader only. */
@@ -130,6 +126,9 @@ public class PortableContext implements Externalizable {
/** */
private final ConcurrentMap<Integer, BinaryIdMapper> mappers = new ConcurrentHashMap8<>(0);
+ /** Affinity key field names. */
+ private final ConcurrentMap<Integer, String> affKeyFieldNames = new ConcurrentHashMap8<>(0);
+
/** */
private final Map<String, BinaryIdMapper> typeMappers = new ConcurrentHashMap8<>(0);
@@ -151,6 +150,9 @@ public class PortableContext implements Externalizable {
/** */
private boolean keepDeserialized;
+ /** Compact footer flag. */
+ private boolean compactFooter;
+
/** Object schemas. */
private volatile Map<Integer, PortableSchemaRegistry> schemas;
@@ -262,6 +264,8 @@ public class PortableContext implements Externalizable {
marsh.getClassNames(),
marsh.getTypeConfigurations()
);
+
+ compactFooter = marsh.isCompactFooter();
}
/**
@@ -504,6 +508,7 @@ public class PortableContext implements Externalizable {
false,
clsName.hashCode(),
clsName,
+ null,
BASIC_CLS_ID_MAPPER,
null,
false,
@@ -550,6 +555,7 @@ public class PortableContext implements Externalizable {
true,
typeId,
typeName,
+ null,
idMapper,
null,
true,
@@ -567,7 +573,8 @@ public class PortableContext implements Externalizable {
mappers.putIfAbsent(typeId, idMapper);
- metaHnd.addMeta(typeId, new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null).wrap(this));
+ metaHnd.addMeta(typeId,
+ new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), null, desc.schemas()).wrap(this));
return desc;
}
@@ -694,6 +701,7 @@ public class PortableContext implements Externalizable {
false,
id,
typeName,
+ null,
DFLT_ID_MAPPER,
null,
false,
@@ -745,11 +753,17 @@ public class PortableContext implements Externalizable {
if (mappers.put(id, idMapper) != null)
throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
+ if (affKeyFieldName != null) {
+ if (affKeyFieldNames.put(id, affKeyFieldName) != null)
+ throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
+ }
+
String typeName = typeName(clsName);
typeMappers.put(typeName, idMapper);
Map<String, Integer> fieldsMeta = null;
+ Collection<PortableSchema> schemas = null;
if (cls != null) {
PortableClassDescriptor desc = new PortableClassDescriptor(
@@ -758,6 +772,7 @@ public class PortableContext implements Externalizable {
true,
id,
typeName,
+ affKeyFieldName,
idMapper,
serializer,
true,
@@ -767,6 +782,7 @@ public class PortableContext implements Externalizable {
);
fieldsMeta = desc.fieldsMeta();
+ schemas = desc.schemas();
if (IgniteUtils.detectClassLoader(cls).equals(dfltLdr))
userTypes.put(id, desc);
@@ -774,7 +790,7 @@ public class PortableContext implements Externalizable {
descByCls.put(cls, desc);
}
- metaHnd.addMeta(id, new BinaryMetadata(id, typeName, fieldsMeta, affKeyFieldName).wrap(this));
+ metaHnd.addMeta(id, new BinaryMetadata(id, typeName, fieldsMeta, affKeyFieldName, schemas).wrap(this));
}
/**
@@ -797,48 +813,32 @@ public class PortableContext implements Externalizable {
* @return Meta data.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
- @Nullable public BinaryType metaData(int typeId) throws BinaryObjectException {
+ @Nullable public BinaryType metadata(int typeId) throws BinaryObjectException {
return metaHnd != null ? metaHnd.metadata(typeId) : null;
}
/**
* @param typeId Type ID.
- * @param metaHashSum Meta data hash sum.
- * @return Whether meta is changed.
+ * @return Affinity key field name.
*/
- boolean isMetaDataChanged(int typeId, @Nullable Integer metaHashSum) {
- if (metaHashSum == null)
- return false;
-
- Collection<Integer> hist = metaDataCache.get(typeId);
-
- if (hist == null) {
- Collection<Integer> old = metaDataCache.putIfAbsent(typeId, hist = new GridConcurrentHashSet<>());
-
- if (old != null)
- hist = old;
- }
-
- return hist.add(metaHashSum);
+ public String affinityKeyFieldName(int typeId) {
+ return affKeyFieldNames.get(typeId);
}
/**
* @param typeId Type ID.
- * @param typeName Type name.
- * @param fields Fields map.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @param meta Meta data.
+ * @throws BinaryObjectException In case of error.
*/
- public void updateMetaData(int typeId, String typeName, Map<String, Integer> fields) throws BinaryObjectException {
- updateMetaData(typeId, new BinaryMetadata(typeId, typeName, fields, null));
+ public void updateMetadata(int typeId, BinaryMetadata meta) throws BinaryObjectException {
+ metaHnd.addMeta(typeId, meta.wrap(this));
}
/**
- * @param typeId Type ID.
- * @param meta Meta data.
- * @throws org.apache.ignite.binary.BinaryObjectException In case of error.
+ * @return Whether field IDs should be skipped in footer or not.
*/
- public void updateMetaData(int typeId, BinaryMetadata meta) throws BinaryObjectException {
- metaHnd.addMeta(typeId, meta.wrap(this));
+ public boolean isCompactFooter() {
+ return compactFooter;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
index 96a93f4..86ca5f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
@@ -17,10 +17,16 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.List;
/**
* Schema describing portable object content. We rely on the following assumptions:
@@ -28,130 +34,150 @@ import java.util.Map;
* for quick comparisons performed within already fetched L1 cache line.
* - When there are more fields, we store them inside a hash map.
*/
-public class PortableSchema {
+public class PortableSchema implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
/** Order returned if field is not found. */
public static final int ORDER_NOT_FOUND = -1;
/** Inline flag. */
- private final boolean inline;
+ private boolean inline;
+
+ /** Map with ID to order. */
+ private HashMap<Integer, Integer> idToOrder;
- /** Map with offsets. */
- private final HashMap<Integer, Integer> map;
+ /** IDs depending on order. */
+ private ArrayList<Integer> ids;
/** ID 1. */
- private final int id0;
+ private int id0;
/** ID 2. */
- private final int id1;
+ private int id1;
/** ID 3. */
- private final int id2;
+ private int id2;
/** ID 4. */
- private final int id3;
+ private int id3;
/** ID 1. */
- private final int id4;
+ private int id4;
/** ID 2. */
- private final int id5;
+ private int id5;
/** ID 3. */
- private final int id6;
+ private int id6;
/** ID 4. */
- private final int id7;
+ private int id7;
+
+ /** Schema ID. */
+ private int schemaId;
+
+ /**
+ * {@link Externalizable} support.
+ */
+ public PortableSchema() {
+ // No-op.
+ }
/**
* Constructor.
*
- * @param vals Values.
+ * @param schemaId Schema ID.
+ * @param fieldIds Field IDs.
*/
- public PortableSchema(LinkedHashMap<Integer, Integer> vals) {
- if (vals.size() <= 8) {
- inline = true;
-
- Iterator<Map.Entry<Integer, Integer>> iter = vals.entrySet().iterator();
+ private PortableSchema(int schemaId, List<Integer> fieldIds) {
+ this.schemaId = schemaId;
- Map.Entry<Integer, Integer> entry = iter.hasNext() ? iter.next() : null;
-
- if (entry != null) {
- id0 = entry.getKey();
+ if (fieldIds.size() <= 8) {
+ inline = true;
- assert entry.getValue() == 0;
- }
- else
- id0 = 0;
+ Iterator<Integer> iter = fieldIds.iterator();
- if ((entry = iter.hasNext() ? iter.next() : null) != null) {
- id1 = entry.getKey();
+ id0 = iter.hasNext() ? iter.next() : 0;
+ id1 = iter.hasNext() ? iter.next() : 0;
+ id2 = iter.hasNext() ? iter.next() : 0;
+ id3 = iter.hasNext() ? iter.next() : 0;
+ id4 = iter.hasNext() ? iter.next() : 0;
+ id5 = iter.hasNext() ? iter.next() : 0;
+ id6 = iter.hasNext() ? iter.next() : 0;
+ id7 = iter.hasNext() ? iter.next() : 0;
- assert entry.getValue() == 1;
- }
- else
- id1 = 0;
+ idToOrder = null;
+ }
+ else {
+ inline = false;
- if ((entry = iter.hasNext() ? iter.next() : null) != null) {
- id2 = entry.getKey();
+ id0 = id1 = id2 = id3 = id4 = id5 = id6 = id7 = 0;
- assert entry.getValue() == 2;
- }
- else
- id2 = 0;
+ ids = new ArrayList<>();
+ idToOrder = new HashMap<>();
- if ((entry = iter.hasNext() ? iter.next() : null) != null) {
- id3 = entry.getKey();
+ for (int i = 0; i < fieldIds.size(); i++) {
+ int fieldId = fieldIds.get(i);
- assert entry.getValue() == 3;
+ ids.add(fieldId);
+ idToOrder.put(fieldId, i);
}
- else
- id3 = 0;
+ }
+ }
- if ((entry = iter.hasNext() ? iter.next() : null) != null) {
- id4 = entry.getKey();
+ /**
+ * @return Schema ID.
+ */
+ public int schemaId() {
+ return schemaId;
+ }
- assert entry.getValue() == 4;
- }
- else
- id4 = 0;
+ /**
+ * Get field ID by order in footer.
+ *
+ * @param order Order.
+ * @return Field ID.
+ */
+ public int fieldId(int order) {
+ if (inline) {
+ switch (order) {
+ case 0:
+ return id0;
- if ((entry = iter.hasNext() ? iter.next() : null) != null) {
- id5 = entry.getKey();
+ case 1:
+ return id1;
- assert entry.getValue() == 5;
- }
- else
- id5 = 0;
+ case 2:
+ return id2;
- if ((entry = iter.hasNext() ? iter.next() : null) != null) {
- id6 = entry.getKey();
+ case 3:
+ return id3;
- assert entry.getValue() == 6;
- }
- else
- id6 = 0;
+ case 4:
+ return id4;
- if ((entry = iter.hasNext() ? iter.next() : null) != null) {
- id7 = entry.getKey();
+ case 5:
+ return id5;
- assert entry.getValue() == 7;
- }
- else
- id7 = 0;
+ case 6:
+ return id6;
- map = null;
- }
- else {
- inline = false;
+ case 7:
+ return id7;
- id0 = id1 = id2 = id3 = id4 = id5 = id6 = id7 = 0;
+ default:
+ assert false : "Should not reach here.";
- map = new HashMap<>(vals);
+ return 0;
+ }
}
+ else
+ return ids.get(order);
}
/**
- * Get field position in footer by schema ID.
+ * Get field order in footer by field ID.
*
* @param id Field ID.
* @return Offset or {@code 0} if there is no such field.
@@ -185,9 +211,125 @@ public class PortableSchema {
return ORDER_NOT_FOUND;
}
else {
- Integer order = map.get(id);
+ Integer order = idToOrder.get(id);
return order != null ? order : ORDER_NOT_FOUND;
}
}
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return schemaId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ return o != null && o instanceof PortableSchema && schemaId == ((PortableSchema)o).schemaId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(schemaId);
+
+ if (inline) {
+ out.writeBoolean(true);
+
+ out.writeInt(id0);
+ out.writeInt(id1);
+ out.writeInt(id2);
+ out.writeInt(id3);
+ out.writeInt(id4);
+ out.writeInt(id5);
+ out.writeInt(id6);
+ out.writeInt(id7);
+ }
+ else {
+ out.writeBoolean(false);
+
+ out.writeInt(ids.size());
+
+ for (Integer id : ids)
+ out.writeInt(id);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ schemaId = in.readInt();
+
+ if (in.readBoolean()) {
+ inline = true;
+
+ id0 = in.readInt();
+ id1 = in.readInt();
+ id2 = in.readInt();
+ id3 = in.readInt();
+ id4 = in.readInt();
+ id5 = in.readInt();
+ id6 = in.readInt();
+ id7 = in.readInt();
+ }
+ else {
+ inline = false;
+
+ int size = in.readInt();
+
+ ids = new ArrayList<>(size);
+ idToOrder = U.newHashMap(size);
+
+ for (int i = 0; i < size; i++) {
+ int fieldId = in.readInt();
+
+ ids.add(fieldId);
+ idToOrder.put(fieldId, i);
+ }
+ }
+ }
+
+ /**
+ * Schema builder.
+ */
+ public static class Builder {
+ /** Schema ID. */
+ private int schemaId = PortableUtils.schemaInitialId();
+
+ /** Fields. */
+ private final ArrayList<Integer> fields = new ArrayList<>();
+
+ /**
+ * Create new schema builder.
+ *
+ * @return Schema builder.
+ */
+ public static Builder newBuilder() {
+ return new Builder();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private Builder() {
+ // No-op.
+ }
+
+ /**
+ * Add field.
+ *
+ * @param fieldId Field ID.
+ */
+ public void addField(int fieldId) {
+ fields.add(fieldId);
+
+ schemaId = PortableUtils.updateSchemaId(schemaId, fieldId);
+ }
+
+ /**
+ * Build schema.
+ *
+ * @return Schema.
+ */
+ public PortableSchema build() {
+ return new PortableSchema(schemaId, fields);
+ }
+ }
}
[48/55] [abbrv] ignite git commit: IGNITE-1282 - Fixed deadlock
caused by listener notification from the synchronized block.
Posted by ag...@apache.org.
IGNITE-1282 - Fixed deadlock caused by listener notification from the synchronized block.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/70746cbd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/70746cbd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/70746cbd
Branch: refs/heads/ignite-1.5
Commit: 70746cbd17b4c7b4e3e218d288d82b8f4546b568
Parents: a28649e
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 19:11:35 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 19:11:35 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheMvccManager.java | 29 ++++++++++++--------
.../cache/transactions/IgniteTxEntry.java | 3 ++
2 files changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/70746cbd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index 9104acb..2449df1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -141,18 +141,25 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
Collection<GridCacheMvccFuture<?>> futCol = mvccFuts.get(owner.version());
if (futCol != null) {
+ ArrayList<GridCacheMvccFuture<?>> futColCp;
+
synchronized (futCol) {
- for (GridCacheMvccFuture<?> fut : futCol) {
- if (!fut.isDone()) {
- GridCacheMvccFuture<Boolean> mvccFut = (GridCacheMvccFuture<Boolean>)fut;
-
- // Since this method is called outside of entry synchronization,
- // we can safely invoke any method on the future.
- // Also note that we don't remove future here if it is done.
- // The removal is initiated from within future itself.
- if (mvccFut.onOwnerChanged(entry, owner))
- return;
- }
+ futColCp = new ArrayList<>(futCol.size());
+
+ futColCp.addAll(futCol);
+ }
+
+ // Must invoke onOwnerChanged outside of synchronization block.
+ for (GridCacheMvccFuture<?> fut : futColCp) {
+ if (!fut.isDone()) {
+ GridCacheMvccFuture<Boolean> mvccFut = (GridCacheMvccFuture<Boolean>)fut;
+
+ // Since this method is called outside of entry synchronization,
+ // we can safely invoke any method on the future.
+ // Also note that we don't remove future here if it is done.
+ // The removal is initiated from within future itself.
+ if (mvccFut.onOwnerChanged(entry, owner))
+ return;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70746cbd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 7436375..fba1513 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -839,6 +839,9 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
if (this.ctx == null) {
GridCacheContext<?, ?> cacheCtx = ctx.cacheContext(cacheId);
+ assert cacheCtx != null : "Failed to find cache context [cacheId=" + cacheId +
+ ", readyTopVer=" + ctx.exchange().readyAffinityVersion() + ']';
+
if (cacheCtx.isNear() && !near)
cacheCtx = cacheCtx.near().dht().context();
else if (!cacheCtx.isNear() && near)
[39/55] [abbrv] ignite git commit: Merge branch ignite-1.5 into
ignite-1282
Posted by ag...@apache.org.
Merge branch ignite-1.5 into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3d4ce809
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3d4ce809
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3d4ce809
Branch: refs/heads/ignite-1.5
Commit: 3d4ce809fc96d93936a69a6076e7141da41d739c
Parents: c505f48 900788b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 14:03:43 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 14:03:43 2015 +0300
----------------------------------------------------------------------
modules/camel/README.txt | 34 +
modules/camel/licenses/apache-2.0.txt | 202 ++
modules/camel/pom.xml | 102 +
.../ignite/stream/camel/CamelStreamer.java | 237 ++
.../stream/camel/IgniteCamelStreamerTest.java | 420 ++++
.../camel/IgniteCamelStreamerTestSuite.java | 48 +
.../src/test/resources/camel.test.properties | 18 +
.../ignite/codegen/MessageCodeGenerator.java | 1 +
.../java/org/apache/ignite/IgniteCache.java | 3 +-
.../java/org/apache/ignite/IgniteCompute.java | 3 +-
.../org/apache/ignite/compute/ComputeJob.java | 2 +-
.../internal/GridEventConsumeHandler.java | 22 +-
.../internal/GridMessageListenHandler.java | 18 +
.../ignite/internal/GridUpdateNotifier.java | 2 +-
.../apache/ignite/internal/IgniteKernal.java | 9 +-
.../communication/GridIoMessageFactory.java | 26 +-
.../discovery/GridDiscoveryManager.java | 2 +-
.../processors/cache/GridCacheAdapter.java | 151 +-
.../processors/cache/GridCacheAtomicFuture.java | 6 +
.../cache/GridCacheDeploymentManager.java | 2 +-
.../processors/cache/GridCacheEntryEx.java | 12 +-
.../processors/cache/GridCacheFuture.java | 13 -
.../processors/cache/GridCacheGateway.java | 1 -
.../processors/cache/GridCacheIoManager.java | 50 +-
.../processors/cache/GridCacheMapEntry.java | 158 +-
.../processors/cache/GridCacheMessage.java | 20 +-
.../processors/cache/GridCacheMvcc.java | 7 -
.../processors/cache/GridCacheMvccFuture.java | 7 +
.../processors/cache/GridCacheMvccManager.java | 150 +-
.../GridCachePartitionExchangeManager.java | 59 +-
.../cache/GridCacheSharedContext.java | 38 +-
.../cache/GridCacheUpdateAtomicResult.java | 15 +-
.../cache/GridCacheUpdateTxResult.java | 24 +-
.../processors/cache/IgniteCacheProxy.java | 3 +
.../distributed/GridCacheTxRecoveryFuture.java | 54 +-
.../distributed/GridDistributedBaseMessage.java | 56 -
.../distributed/GridDistributedLockRequest.java | 6 -
.../GridDistributedLockResponse.java | 32 +-
.../distributed/GridDistributedTxMapping.java | 78 -
.../GridDistributedTxPrepareRequest.java | 67 +-
.../GridDistributedTxRemoteAdapter.java | 158 +-
.../dht/CacheDistributedGetFutureAdapter.java | 27 +-
.../cache/distributed/dht/CacheGetFuture.java | 32 +
.../dht/GridClientPartitionTopology.java | 38 +-
.../distributed/dht/GridDhtCacheAdapter.java | 141 ++
.../distributed/dht/GridDhtLocalPartition.java | 35 +
.../distributed/dht/GridDhtLockFuture.java | 79 +-
.../distributed/dht/GridDhtLockRequest.java | 2 +-
.../dht/GridDhtPartitionTopology.java | 26 +-
.../dht/GridDhtPartitionTopologyImpl.java | 112 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 14 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 38 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 112 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 28 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 89 +-
.../cache/distributed/dht/GridDhtTxMapping.java | 134 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 136 +-
.../dht/GridDhtTxPrepareRequest.java | 54 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 29 +-
.../dht/GridPartitionedGetFuture.java | 69 +-
.../dht/GridPartitionedSingleGetFuture.java | 697 ++++++
.../dht/atomic/GridDhtAtomicCache.java | 206 +-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 159 +-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 121 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 5 -
.../dht/colocated/GridDhtColocatedCache.java | 162 +-
.../colocated/GridDhtColocatedLockFuture.java | 81 +-
.../GridDhtPartitionsExchangeFuture.java | 35 +-
.../preloader/GridDhtPartitionsFullMessage.java | 64 +-
.../GridDhtPartitionsSingleMessage.java | 56 +-
.../distributed/near/CacheVersionedValue.java | 2 +-
.../distributed/near/GridNearAtomicCache.java | 10 +-
.../distributed/near/GridNearCacheAdapter.java | 4 +-
.../distributed/near/GridNearGetFuture.java | 49 +-
.../distributed/near/GridNearGetRequest.java | 1 -
.../distributed/near/GridNearGetResponse.java | 2 -
.../distributed/near/GridNearLockFuture.java | 72 +-
.../distributed/near/GridNearLockRequest.java | 4 +-
...arOptimisticSerializableTxPrepareFuture.java | 124 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 170 +-
...ridNearOptimisticTxPrepareFutureAdapter.java | 72 +-
.../GridNearPessimisticTxPrepareFuture.java | 59 +-
.../near/GridNearSingleGetRequest.java | 396 ++++
.../near/GridNearSingleGetResponse.java | 321 +++
.../near/GridNearTransactionalCache.java | 10 +-
.../near/GridNearTxFinishFuture.java | 103 +-
.../cache/distributed/near/GridNearTxLocal.java | 273 ++-
.../near/GridNearTxPrepareFutureAdapter.java | 20 +-
.../near/GridNearTxPrepareRequest.java | 61 +-
.../distributed/near/GridNearTxRemote.java | 33 +-
.../distributed/near/IgniteTxMappings.java | 75 +
.../distributed/near/IgniteTxMappingsImpl.java | 92 +
.../near/IgniteTxMappingsSingleImpl.java | 101 +
.../processors/cache/local/GridLocalCache.java | 4 +-
.../cache/local/GridLocalLockFuture.java | 5 -
.../CacheContinuousQueryBatchAck.java | 163 ++
.../continuous/CacheContinuousQueryEntry.java | 196 +-
.../continuous/CacheContinuousQueryHandler.java | 811 ++++++-
.../CacheContinuousQueryListener.java | 35 +
.../continuous/CacheContinuousQueryManager.java | 151 +-
.../cache/transactions/IgniteInternalTx.java | 13 +-
.../cache/transactions/IgniteTxAdapter.java | 68 +-
.../cache/transactions/IgniteTxEntry.java | 29 +-
.../cache/transactions/IgniteTxHandler.java | 38 +-
.../IgniteTxImplicitSingleStateImpl.java | 266 +++
.../transactions/IgniteTxLocalAdapter.java | 1424 ++++++-----
.../cache/transactions/IgniteTxLocalEx.java | 30 +-
.../cache/transactions/IgniteTxLocalState.java | 44 +
.../transactions/IgniteTxLocalStateAdapter.java | 41 +
.../cache/transactions/IgniteTxManager.java | 21 +-
.../cache/transactions/IgniteTxMap.java | 3 +-
.../cache/transactions/IgniteTxRemoteEx.java | 18 +-
.../IgniteTxRemoteSingleStateImpl.java | 108 +
.../cache/transactions/IgniteTxRemoteState.java | 34 +
.../IgniteTxRemoteStateAdapter.java | 115 +
.../transactions/IgniteTxRemoteStateImpl.java | 124 +
.../cache/transactions/IgniteTxState.java | 177 ++
.../cache/transactions/IgniteTxStateImpl.java | 414 ++++
.../clock/GridClockSyncProcessor.java | 28 +-
.../continuous/GridContinuousBatch.java | 44 +
.../continuous/GridContinuousBatchAdapter.java | 46 +
.../continuous/GridContinuousHandler.java | 22 +
.../continuous/GridContinuousProcessor.java | 221 +-
.../StartRoutineAckDiscoveryMessage.java | 14 +-
.../StartRoutineDiscoveryMessage.java | 21 +-
.../internal/util/UUIDCollectionMessage.java | 114 +
.../util/future/GridCompoundFuture.java | 15 +-
.../ignite/internal/util/lang/GridFunc.java | 8 +-
.../ignite/internal/util/nio/GridNioServer.java | 13 +-
.../ignite/marshaller/MarshallerExclusions.java | 4 +-
.../org/apache/ignite/mxbean/IgniteMXBean.java | 8 +-
.../org/apache/ignite/stream/StreamAdapter.java | 18 +-
.../IgniteClientReconnectCacheTest.java | 11 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 75 +
.../GridCacheConcurrentTxMultiNodeTest.java | 15 -
.../cache/GridCachePartitionedGetSelfTest.java | 3 +-
.../processors/cache/GridCacheTestEntryEx.java | 10 +-
.../IgniteCacheAbstractStopBusySelfTest.java | 27 +-
.../IgniteCacheP2pUnmarshallingErrorTest.java | 184 +-
.../CacheGetFutureHangsSelfTest.java | 6 +
.../GridCacheAbstractNodeRestartSelfTest.java | 2 +
.../IgniteCacheSingleGetMessageTest.java | 357 +++
.../GridCacheReplicatedMetricsSelfTest.java | 9 -
.../IgniteCacheTxStoreSessionTest.java | 2 +-
...ContinuousQueryFailoverAbstractSelfTest.java | 2235 ++++++++++++++++++
...ryFailoverAtomicNearEnabledSelfSelfTest.java | 46 +
...FailoverAtomicPrimaryWriteOrderSelfTest.java | 44 +
...usQueryFailoverAtomicReplicatedSelfTest.java | 40 +
...inuousQueryFailoverTxReplicatedSelfTest.java | 32 +
.../CacheContinuousQueryFailoverTxSelfTest.java | 39 +
...ridCacheContinuousQueryAbstractSelfTest.java | 153 +-
.../GridCacheContinuousQueryTxSelfTest.java | 49 +
...CacheContinuousQueryClientReconnectTest.java | 187 ++
.../IgniteCacheContinuousQueryClientTest.java | 157 +-
...cheContinuousQueryClientTxReconnectTest.java | 32 +
.../p2p/GridP2PSameClassLoaderSelfTest.java | 16 +-
.../testframework/junits/GridAbstractTest.java | 2 +-
.../junits/common/GridCommonAbstractTest.java | 3 +
.../testsuites/IgniteCacheTestSuite3.java | 2 +
.../testsuites/IgniteCacheTestSuite4.java | 3 +
.../ignite/util/mbeans/GridMBeanSelfTest.java | 33 +-
modules/flume/README.txt | 72 +
modules/flume/licenses/apache-2.0.txt | 202 ++
modules/flume/pom.xml | 77 +
.../ignite/stream/flume/EventTransformer.java | 36 +
.../apache/ignite/stream/flume/IgniteSink.java | 186 ++
.../stream/flume/IgniteSinkConstants.java | 35 +
.../ignite/stream/flume/IgniteSinkTest.java | 142 ++
.../stream/flume/IgniteSinkTestSuite.java | 37 +
.../stream/flume/TestEventTransformer.java | 66 +
.../flume/src/test/resources/example-ignite.xml | 71 +
.../IgniteCacheQuerySelfTestSuite.java | 16 +-
.../GridSpringResourceInjectionSelfTest.java | 143 ++
.../processors/resource/spring-resource.xml | 27 +
.../testsuites/IgniteResourceSelfTestSuite.java | 2 +
modules/twitter/README.txt | 32 +
modules/twitter/licenses/apache-2.0.txt | 202 ++
modules/twitter/pom.xml | 122 +
.../ignite/stream/twitter/OAuthSettings.java | 86 +
.../ignite/stream/twitter/TwitterStreamer.java | 295 +++
.../twitter/IgniteTwitterStreamerTest.java | 234 ++
.../twitter/IgniteTwitterStreamerTestSuite.java | 32 +
.../stream/twitter/TwitterStreamerImpl.java | 79 +
.../config/benchmark-multicast.properties | 6 +-
.../benchmark-query-put-separated.properties | 87 +
.../yardstick/cache/CacheEntryEventProbe.java | 156 ++
.../cache/IgniteSqlQueryPutBenchmark.java | 31 +-
.../IgniteSqlQueryPutSeparatedBenchmark.java | 84 +
parent/pom.xml | 1 +
pom.xml | 3 +
190 files changed, 15606 insertions(+), 2789 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
----------------------------------------------------------------------
diff --cc modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
index b8ccc03,74c71c4..5a31415
--- a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
+++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
@@@ -43,7 -43,10 +43,8 @@@ import org.apache.ignite.internal.GridD
import org.apache.ignite.internal.GridDirectMap;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.IgniteCodeGeneratingFail;
-import org.apache.ignite.internal.processors.cache.distributed.GridDistributedTxPrepareRequest;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareRequest;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest;
+import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateRequest;
+ import org.apache.ignite.internal.util.UUIDCollectionMessage;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 5ced545,8d363ad..512a801
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@@ -1205,14 -1186,15 +1215,16 @@@ public abstract class GridCacheMapEntr
val != null,
evtOld,
evtOld != null || hasValueUnlocked(),
- subjId, null, taskName);
+ subjId, null, taskName,
+ keepPortable);
}
- if (cctx.isLocal() || cctx.isReplicated() || (tx != null && tx.local() && !isNear()))
- cctx.continuousQueries().onEntryUpdated(this, key, val, old, false);
+ if (cctx.isLocal() || cctx.isReplicated() ||
+ (!isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local())))
+ cctx.continuousQueries().onEntryUpdated(key, val, old, isInternal() || !context().userCache(),
+ partition(), tx.local(), false, updateCntr0, topVer);
- cctx.dataStructures().onEntryUpdated(key, false);
+ cctx.dataStructures().onEntryUpdated(key, false, keepPortable);
}
if (log.isDebugEnabled())
@@@ -1224,9 -1206,9 +1236,9 @@@
cctx.store().put(tx, keyValue(false), CU.value(val, cctx, false), newVer);
if (intercept)
- cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, val, val0));
+ cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, val, val0, keepPortable));
- return valid ? new GridCacheUpdateTxResult(true, retval ? old : null) :
+ return valid ? new GridCacheUpdateTxResult(true, retval ? old : null, updateCntr0) :
new GridCacheUpdateTxResult(false, null);
}
@@@ -1377,14 -1366,15 +1397,16 @@@
evtOld != null || hasValueUnlocked(),
subjId,
null,
- taskName);
+ taskName,
+ keepPortable);
}
- if (cctx.isLocal() || cctx.isReplicated() || (tx != null && tx.local() && !isNear()))
- cctx.continuousQueries().onEntryUpdated(this, key, null, old, false);
+ if (cctx.isLocal() || cctx.isReplicated() ||
+ (!isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local())))
+ cctx.continuousQueries().onEntryUpdated(key, null, old, isInternal()
+ || !context().userCache(),partition(), tx.local(), false, updateCntr0, topVer);
- cctx.dataStructures().onEntryUpdated(key, true);
+ cctx.dataStructures().onEntryUpdated(key, true, keepPortable);
deferred = cctx.deferredDelete() && !detached() && !isInternal();
@@@ -1718,9 -1707,14 +1740,14 @@@
if (res)
updateMetrics(op, metrics);
- cctx.continuousQueries().onEntryUpdated(this, key, val, old, false);
+ if (!isNear()) {
+ long updateCntr = nextPartCounter(AffinityTopologyVersion.NONE);
+
+ cctx.continuousQueries().onEntryUpdated(key, val, old, isInternal() || !context().userCache(),
+ partition(), true, false, updateCntr, AffinityTopologyVersion.NONE);
+ }
- cctx.dataStructures().onEntryUpdated(key, op == GridCacheOperation.DELETE);
+ cctx.dataStructures().onEntryUpdated(key, op == GridCacheOperation.DELETE, keepBinary);
if (intercept) {
if (op == GridCacheOperation.UPDATE)
@@@ -2336,10 -2377,7 +2415,7 @@@
if (res)
updateMetrics(op, metrics);
- if (cctx.isReplicated() || primary)
- cctx.continuousQueries().onEntryUpdated(this, key, val, oldVal, false);
-
- cctx.dataStructures().onEntryUpdated(key, op == GridCacheOperation.DELETE);
+ cctx.dataStructures().onEntryUpdated(key, op == GridCacheOperation.DELETE, keepPortable);
if (intercept) {
if (op == GridCacheOperation.UPDATE)
@@@ -3186,10 -3230,10 +3268,10 @@@
drReplicate(drType, val, ver);
if (!skipQryNtf) {
- if (cctx.isLocal() || cctx.isReplicated() || cctx.affinity().primary(cctx.localNode(), key, topVer))
- cctx.continuousQueries().onEntryUpdated(this, key, val, null, preload);
+ cctx.continuousQueries().onEntryUpdated(key, val, null, this.isInternal()
+ || !this.context().userCache(), this.partition(), true, preload, updateCntr, topVer);
- cctx.dataStructures().onEntryUpdated(key, false);
+ cctx.dataStructures().onEntryUpdated(key, false, true);
}
if (cctx.store().isLocal()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index db19c67,55ca12d..2330a95
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@@ -707,11 -649,9 +651,10 @@@ public abstract class GridDhtTxLocalAda
passedKeys,
read,
needRetVal,
- skipped,
accessTtl,
null,
- skipStore);
+ skipStore,
+ keepBinary);
}
catch (IgniteCheckedException e) {
setRollbackOnly();
@@@ -738,14 -677,11 +680,12 @@@
final Collection<KeyCacheObject> passedKeys,
final boolean read,
final boolean needRetVal,
- final Set<KeyCacheObject> skipped,
final long accessTtl,
@Nullable final CacheEntryPredicate[] filter,
- boolean skipStore) {
+ boolean skipStore,
+ boolean keepBinary) {
if (log.isDebugEnabled())
- log.debug("Before acquiring transaction lock on keys [passedKeys=" + passedKeys + ", skipped=" +
- skipped + ']');
+ log.debug("Before acquiring transaction lock on keys [keys=" + passedKeys + ']');
if (passedKeys.isEmpty())
return new GridFinishedFuture<>(ret);
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 255640f,3ee1048..cd76a56
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@@ -1765,8 -1875,7 +1881,8 @@@ public class GridDhtAtomicCache<K, V> e
req.invokeArguments(),
primary && writeThrough() && !req.skipStore(),
!req.skipStore(),
- req.returnValue(),
+ sndPrevVal || req.returnValue(),
+ req.keepBinary(),
expiry,
true,
true,
@@@ -2036,8 -2156,7 +2164,8 @@@
null,
/*write-through*/false,
/*read-through*/false,
- /*retval*/false,
+ /*retval*/sndPrevVal,
+ req.keepBinary(),
expiry,
/*event*/true,
/*metrics*/true,
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
index 7b95042,72a60d2..a8807e1
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
@@@ -139,9 -144,19 +144,22 @@@ public class GridDhtAtomicUpdateReques
/** Task name hash. */
private int taskNameHash;
+ /** Partition. */
+ private GridLongList updateCntrs;
+
+ /** On response flag. Access should be synced on future. */
+ @GridDirectTransient
+ private boolean onRes;
+
+ @GridDirectTransient
+ private List<Integer> partIds;
+
+ @GridDirectTransient
+ private List<CacheObject> localPrevVals;
+
+ /** Keep portable flag. */
+ private boolean keepBinary;
+
/**
* Empty constructor required by {@link Externalizable}.
*/
@@@ -191,9 -205,10 +209,11 @@@
this.taskNameHash = taskNameHash;
this.invokeArgs = invokeArgs;
this.addDepInfo = addDepInfo;
+ this.keepBinary = keepBinary;
keys = new ArrayList<>();
+ partIds = new ArrayList<>();
+ localPrevVals = new ArrayList<>();
if (forceTransformBackups) {
entryProcessors = new ArrayList<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index 648a248,706655b..49a267a
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@@ -251,8 -249,7 +251,8 @@@ public class GridNearAtomicCache<K, V>
/*write-through*/false,
/*read-through*/false,
/*retval*/false,
+ keepPortable,
- /**expiry policy*/null,
+ /*expiry policy*/null,
/*event*/true,
/*metrics*/true,
/*primary*/false,
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 685b998,dfaa44e..00f0a75
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@@ -562,8 -520,17 +545,10 @@@ public final class GridNearGetFuture<K
add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
}
else {
- K key0 = key.value(cctx.cacheObjectContext(), true);
- key0 = (K)cctx.unwrapPortableIfNeeded(key0, !deserializePortable);
-
- V val0;
-
- if (!skipVals) {
- val0 = v.value(cctx.cacheObjectContext(), true);
- val0 = (V)cctx.unwrapPortableIfNeeded(val0, !deserializePortable);
- }
- else
- val0 = (V)Boolean.TRUE;
+ K key0 = (K)cctx.unwrapPortableIfNeeded(key, !deserializePortable);
- V val0 = (V)cctx.unwrapPortableIfNeeded(v, !deserializePortable);
++ V val0 = !skipVals ?
++ (V)cctx.unwrapPortableIfNeeded(v, !deserializePortable) :
++ (V)Boolean.TRUE;
add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 4b5b204,1c01e4e..2eb4c68
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@@ -347,9 -332,8 +332,9 @@@ public class GridNearTxLocal extends Gr
boolean readThrough,
boolean async,
final Collection<KeyCacheObject> keys,
- boolean skipVals,
+ final boolean skipVals,
final boolean needVer,
+ boolean keepBinary,
final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c
) {
if (cacheCtx.isNear()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
index 58ee0c6,ba58f57..cef8371
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
@@@ -390,10 -392,9 +393,10 @@@ public class GridNearTxRemote extends G
-1L,
cached,
drVer,
- skipStore);
+ skipStore,
+ keepBinary);
- writeMap.put(key, txEntry);
+ txState.addWriteEntry(key, txEntry);
return true;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 9f52699,cff62d9..fae7d8c
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@@ -2133,265 -2183,363 +2201,363 @@@ public abstract class IgniteTxLocalAdap
KeyCacheObject cacheKey = cacheCtx.toCacheKeyObject(key);
- IgniteTxKey txKey = cacheCtx.txKey(cacheKey);
-
- IgniteTxEntry txEntry = entry(txKey);
-
- // First time access.
- if (txEntry == null) {
- while (true) {
- GridCacheEntryEx entry = entryEx(cacheCtx, txKey, topologyVersion());
-
- try {
- entry.unswap(false);
-
- // Check if lock is being explicitly acquired by the same thread.
- if (!implicit && cctx.kernalContext().config().isCacheSanityCheckEnabled() &&
- entry.lockedByThread(threadId, xidVer))
- throw new IgniteCheckedException("Cannot access key within transaction if lock is " +
- "externally held [key=" + key + ", entry=" + entry + ", xidVer=" + xidVer +
- ", threadId=" + threadId +
- ", locNodeId=" + cctx.localNodeId() + ']');
-
- CacheObject old = null;
- GridCacheVersion readVer = null;
+ boolean loadMissed = enlistWriteEntry(cacheCtx,
+ cacheKey,
+ val,
+ entryProcessor,
+ invokeArgs,
+ expiryPlc,
+ retval,
+ lockOnly,
+ filter,
+ drVer,
+ drTtl,
+ drExpireTime,
+ ret,
+ enlisted,
+ skipStore,
+ singleRmv,
+ hasFilters,
+ needVal,
+ needReadVer);
+
+ if (loadMissed) {
+ if (missedForLoad == null)
+ missedForLoad = new HashSet<>();
+
+ missedForLoad.add(cacheKey);
+ }
+ }
- if (optimistic() && !implicit()) {
- try {
- if (needReadVer) {
- T2<CacheObject, GridCacheVersion> res = primaryLocal(entry) ?
- entry.innerGetVersioned(this,
- /*swap*/false,
- /*unmarshal*/retval,
- /*metrics*/retval,
- /*events*/retval,
- CU.subjectId(this, cctx),
- entryProcessor,
- resolveTaskName(),
- null,
- keepBinary) : null;
+ if (missedForLoad != null) {
+ return loadMissing(cacheCtx,
+ missedForLoad,
+ filter,
+ ret,
+ needReadVer,
+ singleRmv,
+ hasFilters,
+ skipStore,
+ retval);
+ }
- if (res != null) {
- old = res.get1();
- readVer = res.get2();
- }
- }
- else {
- old = entry.innerGet(this,
- /*swap*/false,
- /*read-through*/false,
- /*fail-fast*/false,
- /*unmarshal*/retval,
- /*metrics*/retval,
- /*events*/retval,
- /*temporary*/false,
- CU.subjectId(this, cctx),
- entryProcessor,
- resolveTaskName(),
- null,
- keepBinary);
- }
- }
- catch (ClusterTopologyCheckedException e) {
- entry.context().evicts().touch(entry, topologyVersion());
+ return new GridFinishedFuture<>();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+ }
- throw e;
- }
- }
- else
- old = retval ? entry.rawGetOrUnmarshal(false) : entry.rawGet();
+ /**
+ * @param cacheCtx Cache context.
+ * @param keys Keys to load.
+ * @param filter Filter.
+ * @param ret Return value.
+ * @param needReadVer Read version flag.
+ * @param singleRmv {@code True} for single remove operation.
+ * @param hasFilters {@code True} if filters not empty.
+ * @param skipStore Skip store flag.
+ * @param retval Return value flag.
+ * @return Load future.
+ */
+ private IgniteInternalFuture<Void> loadMissing(
+ final GridCacheContext cacheCtx,
+ final Set<KeyCacheObject> keys,
+ final CacheEntryPredicate[] filter,
+ final GridCacheReturn ret,
+ final boolean needReadVer,
+ final boolean singleRmv,
+ final boolean hasFilters,
+ final boolean skipStore,
+ final boolean retval) {
+ GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c =
+ new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
+ @Override public void apply(KeyCacheObject key,
+ @Nullable Object val,
+ @Nullable GridCacheVersion loadVer) {
+ if (log.isDebugEnabled())
+ log.debug("Loaded value from remote node [key=" + key + ", val=" + val + ']');
- if (old != null && hasFilters && !filter(entry.context(), cacheKey, old, filter)) {
- skipped = skip(skipped, cacheKey);
+ IgniteTxEntry e = entry(new IgniteTxKey(key, cacheCtx.cacheId()));
- ret.set(cacheCtx, old, false, keepBinary);
+ assert e != null;
- if (!readCommitted()) {
- // Enlist failed filters as reads for non-read-committed mode,
- // so future ops will get the same values.
- txEntry = addEntry(READ,
- old,
- null,
- null,
- entry,
- null,
- CU.empty0(),
- false,
- -1L,
- -1L,
- null,
- skipStore,
- keepBinary);
+ if (needReadVer) {
+ assert loadVer != null;
- txEntry.markValid();
+ e.serializableReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
+ }
- if (needReadVer) {
- assert readVer != null;
+ if (singleRmv) {
+ assert !hasFilters && !retval;
+ assert val == null || Boolean.TRUE.equals(val) : val;
- txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
- }
- }
- ret.set(cacheCtx, null, val != null);
++ ret.set(cacheCtx, null, val != null, keepBinary);
+ }
+ else {
+ CacheObject cacheVal = cacheCtx.toCacheObject(val);
- if (readCommitted())
- cacheCtx.evicts().touch(entry, topologyVersion());
+ if (e.op() == TRANSFORM) {
+ GridCacheVersion ver;
- break; // While.
+ try {
+ ver = e.cached().version();
}
+ catch (GridCacheEntryRemovedException ex) {
+ assert optimistic() : e;
- final GridCacheOperation op = lockOnly ? NOOP : rmv ? DELETE :
- entryProcessor != null ? TRANSFORM : old != null ? UPDATE : CREATE;
+ if (log.isDebugEnabled())
+ log.debug("Failed to get entry version: [msg=" + ex.getMessage() + ']');
- txEntry = addEntry(op,
- cacheCtx.toCacheObject(val),
- entryProcessor,
- invokeArgs,
- entry,
- expiryPlc,
- filter,
- true,
- drTtl,
- drExpireTime,
- drVer,
- skipStore,
- keepBinary);
+ ver = null;
+ }
- if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
- cacheCtx.evicts().touch(entry, topologyVersion());
+ addInvokeResult(e, cacheVal, ret, ver);
+ }
+ else {
+ boolean success = !hasFilters || isAll(e.context(), key, cacheVal, filter);
- enlisted.add(cacheKey);
+ ret.set(cacheCtx, cacheVal, success);
+ }
+ }
+ }
+ };
- if (!pessimistic() && !implicit()) {
- txEntry.markValid();
+ return loadMissing(
+ cacheCtx,
+ /*read through*/cacheCtx.config().isLoadPreviousValue() && !skipStore,
+ /*async*/true,
+ keys,
+ /*skipVals*/singleRmv,
+ needReadVer,
+ c);
+ }
- if (old == null) {
- if (needVal) {
- if (missedForLoad == null)
- missedForLoad = new HashSet<>();
+ /**
+ * @param cacheCtx Cache context.
+ * @param cacheKey Key.
+ * @param val Value.
+ * @param entryProcessor Entry processor.
+ * @param invokeArgs Optional arguments for EntryProcessor.
+ * @param expiryPlc Explicitly specified expiry policy for entry.
+ * @param retval Return value flag.
+ * @param lockOnly
+ * @param filter Filter.
+ * @param drVer DR version.
+ * @param drTtl DR ttl.
+ * @param drExpireTime DR expire time.
+ * @param ret Return value.
+ * @param enlisted Enlisted keys collection.
+ * @param skipStore Skip store flag.
+ * @param singleRmv {@code True} for single remove operation.
+ * @param hasFilters {@code True} if filters not empty.
+ * @param needVal {@code True} if value is needed.
+ * @param needReadVer {@code True} if need read entry version.
+ * @return {@code True} if entry value should be loaded.
+ * @throws IgniteCheckedException If failed.
+ */
+ private boolean enlistWriteEntry(GridCacheContext cacheCtx,
+ final KeyCacheObject cacheKey,
+ final @Nullable Object val,
+ final @Nullable EntryProcessor<?, ?, ?> entryProcessor,
+ final @Nullable Object[] invokeArgs,
+ final @Nullable ExpiryPolicy expiryPlc,
+ final boolean retval,
+ final boolean lockOnly,
+ final CacheEntryPredicate[] filter,
+ final GridCacheVersion drVer,
+ final long drTtl,
+ long drExpireTime,
+ final GridCacheReturn ret,
+ @Nullable final Collection<KeyCacheObject> enlisted,
+ boolean skipStore,
+ boolean singleRmv,
+ boolean hasFilters,
+ final boolean needVal,
+ boolean needReadVer
+ ) throws IgniteCheckedException {
+ boolean loadMissed = false;
- missedForLoad.add(cacheKey);
- }
- else {
- assert !implicit() || !transform : this;
- assert txEntry.op() != TRANSFORM : txEntry;
+ final boolean rmv = val == null && entryProcessor == null;
- if (retval)
- ret.set(cacheCtx, null, true, keepBinary);
- else
- ret.success(true);
- }
- }
- else {
- if (needReadVer) {
- assert readVer != null;
+ IgniteTxKey txKey = cacheCtx.txKey(cacheKey);
- txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
- }
+ IgniteTxEntry txEntry = entry(txKey);
- if (retval && !transform)
- ret.set(cacheCtx, old, true, keepBinary);
- else {
- if (txEntry.op() == TRANSFORM) {
- GridCacheVersion ver;
+ // First time access.
+ if (txEntry == null) {
+ while (true) {
+ GridCacheEntryEx entry = entryEx(cacheCtx, txKey, topologyVersion());
- try {
- ver = entry.version();
- }
- catch (GridCacheEntryRemovedException ex) {
- assert optimistic() : txEntry;
+ try {
+ entry.unswap(false);
+
+ // Check if lock is being explicitly acquired by the same thread.
+ if (!implicit && cctx.kernalContext().config().isCacheSanityCheckEnabled() &&
+ entry.lockedByThread(threadId, xidVer)) {
+ throw new IgniteCheckedException("Cannot access key within transaction if lock is " +
+ "externally held [key=" + CU.value(cacheKey, cacheCtx, false) +
+ ", entry=" + entry +
+ ", xidVer=" + xidVer +
+ ", threadId=" + threadId +
+ ", locNodeId=" + cctx.localNodeId() + ']');
+ }
- if (log.isDebugEnabled())
- log.debug("Failed to get entry version " +
- "[err=" + ex.getMessage() + ']');
+ CacheObject old = null;
+ GridCacheVersion readVer = null;
- ver = null;
- }
+ if (optimistic() && !implicit()) {
+ try {
+ if (needReadVer) {
+ T2<CacheObject, GridCacheVersion> res = primaryLocal(entry) ?
+ entry.innerGetVersioned(this,
+ /*swap*/false,
+ /*unmarshal*/retval,
+ /*metrics*/retval,
+ /*events*/retval,
+ CU.subjectId(this, cctx),
+ entryProcessor,
+ resolveTaskName(),
+ null) : null;
- addInvokeResult(txEntry, old, ret, ver);
- }
- else
- ret.success(true);
- }
+ if (res != null) {
+ old = res.get1();
+ readVer = res.get2();
}
}
- // Pessimistic.
else {
- if (retval && !transform)
- ret.set(cacheCtx, old, true, keepBinary);
- else
- ret.success(true);
+ old = entry.innerGet(this,
+ /*swap*/false,
+ /*read-through*/false,
+ /*fail-fast*/false,
+ /*unmarshal*/retval,
+ /*metrics*/retval,
+ /*events*/retval,
+ /*temporary*/false,
+ CU.subjectId(this, cctx),
+ entryProcessor,
+ resolveTaskName(),
+ null);
}
-
- break; // While.
}
- catch (GridCacheEntryRemovedException ignore) {
- if (log.isDebugEnabled())
- log.debug("Got removed entry in transaction putAll0 method: " + entry);
+ catch (ClusterTopologyCheckedException e) {
+ entry.context().evicts().touch(entry, topologyVersion());
+
+ throw e;
}
}
- }
- else {
- if (entryProcessor == null && txEntry.op() == TRANSFORM)
- throw new IgniteCheckedException("Failed to enlist write value for key (cannot have update value in " +
- "transaction after EntryProcessor is applied): " + key);
-
- GridCacheEntryEx entry = txEntry.cached();
+ else
+ old = retval ? entry.rawGetOrUnmarshal(false) : entry.rawGet();
- CacheObject v = txEntry.value();
+ if (old != null && hasFilters && !filter(entry.context(), cacheKey, old, filter)) {
+ ret.set(cacheCtx, old, false);
- boolean del = txEntry.op() == DELETE && rmv;
+ if (!readCommitted()) {
+ // Enlist failed filters as reads for non-read-committed mode,
+ // so future ops will get the same values.
+ txEntry = addEntry(READ,
+ old,
+ null,
+ null,
+ entry,
+ null,
+ CU.empty0(),
+ false,
+ -1L,
+ -1L,
+ null,
+ skipStore);
- if (!del) {
- if (hasFilters && !filter(entry.context(), cacheKey, v, filter)) {
- skipped = skip(skipped, cacheKey);
+ txEntry.markValid();
- ret.set(cacheCtx, v, false, keepBinary);
+ if (needReadVer) {
+ assert readVer != null;
- continue;
+ txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
+ }
}
- GridCacheOperation op = rmv ? DELETE : entryProcessor != null ? TRANSFORM :
- v != null ? UPDATE : CREATE;
+ if (readCommitted())
+ cacheCtx.evicts().touch(entry, topologyVersion());
- txEntry = addEntry(op,
- cacheCtx.toCacheObject(val),
- entryProcessor,
- invokeArgs,
- entry,
- expiryPlc,
- filter,
- true,
- drTtl,
- drExpireTime,
- drVer,
- skipStore,
- keepBinary);
+ break; // While.
+ }
+
+ final GridCacheOperation op = lockOnly ? NOOP : rmv ? DELETE :
+ entryProcessor != null ? TRANSFORM : old != null ? UPDATE : CREATE;
+
+ txEntry = addEntry(op,
+ cacheCtx.toCacheObject(val),
+ entryProcessor,
+ invokeArgs,
+ entry,
+ expiryPlc,
+ filter,
+ true,
+ drTtl,
+ drExpireTime,
+ drVer,
+ skipStore);
+ if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
+ cacheCtx.evicts().touch(entry, topologyVersion());
+
+ if (enlisted != null)
enlisted.add(cacheKey);
- if (txEntry.op() == TRANSFORM) {
- GridCacheVersion ver;
+ if (!pessimistic() && !implicit()) {
+ txEntry.markValid();
- try {
- ver = entry.version();
- }
- catch (GridCacheEntryRemovedException e) {
- assert optimistic() : txEntry;
+ if (old == null) {
+ if (needVal)
+ loadMissed = true;
+ else {
+ assert !implicit() || !transform : this;
+ assert txEntry.op() != TRANSFORM : txEntry;
- if (log.isDebugEnabled())
- log.debug("Failed to get entry version: [msg=" + e.getMessage() + ']');
+ if (retval)
+ ret.set(cacheCtx, null, true);
+ else
+ ret.success(true);
+ }
+ }
+ else {
+ if (needReadVer) {
+ assert readVer != null;
- ver = null;
+ txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
}
- addInvokeResult(txEntry, txEntry.value(), ret, ver);
- }
- }
+ if (retval && !transform)
+ ret.set(cacheCtx, old, true);
+ else {
+ if (txEntry.op() == TRANSFORM) {
+ GridCacheVersion ver;
- if (!pessimistic()) {
- txEntry.markValid();
+ try {
+ ver = entry.version();
+ }
+ catch (GridCacheEntryRemovedException ex) {
+ assert optimistic() : txEntry;
+ if (log.isDebugEnabled())
+ log.debug("Failed to get entry version " +
+ "[err=" + ex.getMessage() + ']');
+
+ ver = null;
+ }
+
+ addInvokeResult(txEntry, old, ret, ver);
+ }
+ else
+ ret.success(true);
+ }
+ }
+ }
+ // Pessimistic.
+ else {
if (retval && !transform)
- ret.set(cacheCtx, v, true, keepBinary);
+ ret.set(cacheCtx, old, true);
else
ret.success(true);
}
@@@ -2829,19 -3081,15 +3101,16 @@@
drMap,
null,
opCtx != null && opCtx.skipStore(),
- false);
+ false,
+ opCtx != null && opCtx.isKeepBinary());
if (pessimistic()) {
- // Loose all skipped.
- final Set<KeyCacheObject> loaded = loadFut.get();
-
- final Collection<KeyCacheObject> keys = F.view(enlisted, F0.notIn(loaded));
+ assert loadFut == null || loadFut.isDone() : loadFut;
if (log.isDebugEnabled())
- log.debug("Before acquiring transaction lock for put on keys: " + keys);
+ log.debug("Before acquiring transaction lock for put on keys: " + enlisted);
- IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(keys,
+ IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(enlisted,
lockTimeout(),
this,
false,
@@@ -3029,141 -3292,131 +3313,132 @@@
init();
- try {
- Collection<KeyCacheObject> enlisted = new ArrayList<>();
-
- CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
+ final Collection<KeyCacheObject> enlisted = new ArrayList<>();
- ExpiryPolicy plc;
+ CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
- if (!F.isEmpty(filter))
- plc = opCtx != null ? opCtx.expiry() : null;
- else
- plc = null;
+ ExpiryPolicy plc;
- final IgniteInternalFuture<Set<KeyCacheObject>> loadFut = enlistWrite(
- cacheCtx,
- keys0,
- plc,
- implicit,
- /** lookup map */null,
- /** invoke map */null,
- /** invoke arguments */null,
- retval,
- /** lock only */false,
- filter,
- ret,
- enlisted,
- null,
- drMap,
- opCtx != null && opCtx.skipStore(),
- singleRmv,
- opCtx != null && opCtx.isKeepBinary()
- );
+ if (!F.isEmpty(filter))
+ plc = opCtx != null ? opCtx.expiry() : null;
+ else
+ plc = null;
- if (log.isDebugEnabled())
- log.debug("Remove keys: " + enlisted);
+ final IgniteInternalFuture<Void> loadFut = enlistWrite(
+ cacheCtx,
+ keys0,
+ plc,
+ /** lookup map */null,
+ /** invoke map */null,
+ /** invoke arguments */null,
+ retval,
+ /** lock only */false,
+ filter,
+ ret,
+ enlisted,
+ null,
+ drMap,
+ opCtx != null && opCtx.skipStore(),
- singleRmv
++ singleRmv,
++ opCtx != null && opCtx.isKeepBinary()
+ );
- // Acquire locks only after having added operation to the write set.
- // Otherwise, during rollback we will not know whether locks need
- // to be rolled back.
- if (pessimistic()) {
- // Loose all skipped.
- final Collection<KeyCacheObject> passedKeys = F.view(enlisted, F0.notIn(loadFut.get()));
+ if (log.isDebugEnabled())
+ log.debug("Remove keys: " + enlisted);
- if (log.isDebugEnabled())
- log.debug("Before acquiring transaction lock for remove on keys: " + passedKeys);
+ // Acquire locks only after having added operation to the write set.
+ // Otherwise, during rollback we will not know whether locks need
+ // to be rolled back.
+ if (pessimistic()) {
+ assert loadFut.isDone() : loadFut;
- IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(passedKeys,
- lockTimeout(),
- this,
- false,
- retval,
- isolation,
- isInvalidate(),
- -1L);
+ if (log.isDebugEnabled())
+ log.debug("Before acquiring transaction lock for remove on keys: " + enlisted);
- PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
- @Override protected GridCacheReturn postLock(GridCacheReturn ret)
- throws IgniteCheckedException
- {
- if (log.isDebugEnabled())
- log.debug("Acquired transaction lock for remove on keys: " + passedKeys);
+ IgniteInternalFuture<Boolean> fut = cacheCtx.cache().txLockAsync(enlisted,
+ lockTimeout(),
+ this,
+ false,
+ retval,
+ isolation,
+ isInvalidate(),
+ -1L);
+
+ PLC1<GridCacheReturn> plc1 = new PLC1<GridCacheReturn>(ret) {
+ @Override protected GridCacheReturn postLock(GridCacheReturn ret)
+ throws IgniteCheckedException
+ {
+ if (log.isDebugEnabled())
+ log.debug("Acquired transaction lock for remove on keys: " + enlisted);
- postLockWrite(cacheCtx,
- passedKeys,
- loadFut.get(),
- ret,
+ postLockWrite(cacheCtx,
+ enlisted,
+ ret,
/*remove*/true,
- retval,
+ retval,
/*read*/false,
- -1L,
- filter,
+ -1L,
+ filter,
/*computeInvoke*/false);
- return ret;
- }
- };
+ return ret;
+ }
+ };
- if (fut.isDone()) {
+ if (fut.isDone()) {
+ try {
+ return nonInterruptable(plc1.apply(fut.get(), null));
+ }
+ catch (GridClosureException e) {
+ return new GridFinishedFuture<>(e.unwrap());
+ }
+ catch (IgniteCheckedException e) {
try {
- return nonInterruptable(plc1.apply(fut.get(), null));
+ return nonInterruptable(plc1.apply(false, e));
}
- catch (GridClosureException e) {
- return new GridFinishedFuture<>(e.unwrap());
- }
- catch (IgniteCheckedException e) {
- try {
- return nonInterruptable(plc1.apply(false, e));
- }
- catch (Exception e1) {
- return new GridFinishedFuture<>(e1);
- }
+ catch (Exception e1) {
+ return new GridFinishedFuture<>(e1);
}
}
- else
- return nonInterruptable(new GridEmbeddedFuture<>(
- fut,
- plc1
- ));
}
- else {
- if (implicit()) {
- // Should never load missing values for implicit transaction as values will be returned
- // with prepare response, if required.
- assert loadFut.isDone();
-
- return nonInterruptable(commitAsync().chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, GridCacheReturn>() {
- @Override public GridCacheReturn applyx(IgniteInternalFuture<IgniteInternalTx> txFut)
- throws IgniteCheckedException {
- try {
- txFut.get();
+ else
+ return nonInterruptable(new GridEmbeddedFuture<>(
+ fut,
+ plc1
+ ));
+ }
+ else {
+ if (implicit()) {
+ // Should never load missing values for implicit transaction as values will be returned
+ // with prepare response, if required.
+ assert loadFut.isDone();
- return implicitRes;
- }
- catch (IgniteCheckedException | RuntimeException e) {
- rollbackAsync();
+ return nonInterruptable(commitAsync().chain(new CX1<IgniteInternalFuture<IgniteInternalTx>, GridCacheReturn>() {
+ @Override public GridCacheReturn applyx(IgniteInternalFuture<IgniteInternalTx> txFut)
+ throws IgniteCheckedException {
+ try {
+ txFut.get();
- throw e;
- }
+ return implicitRes;
}
- }));
- }
- else
- return nonInterruptable(loadFut.chain(new CX1<IgniteInternalFuture<Set<KeyCacheObject>>, GridCacheReturn>() {
- @Override public GridCacheReturn applyx(IgniteInternalFuture<Set<KeyCacheObject>> f)
- throws IgniteCheckedException {
- f.get();
+ catch (IgniteCheckedException | RuntimeException e) {
+ rollbackAsync();
- return ret;
+ throw e;
}
- }));
+ }
+ }));
}
- }
- catch (IgniteCheckedException e) {
- setRollbackOnly();
+ else {
+ return nonInterruptable(loadFut.chain(new CX1<IgniteInternalFuture<Void>, GridCacheReturn>() {
+ @Override public GridCacheReturn applyx(IgniteInternalFuture<Void> f)
+ throws IgniteCheckedException {
+ f.get();
- return new GridFinishedFuture<>(e);
+ return ret;
+ }
+ }));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
----------------------------------------------------------------------
diff --cc modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
index db44fac,99b2423..dfa4cbc
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
@@@ -74,21 -76,6 +76,11 @@@ public class IgniteSqlQueryPutBenchmar
return true;
}
+ /** {@inheritDoc} */
+ @Override public void onWarmupFinished() {
+ super.onWarmupFinished();
-
- resCnt.reset();
- cnt.reset();
- }
-
- /** {@inheritDoc} */
- @Override public void tearDown() throws Exception {
- ignite().log().info("Average number of entries per query: " + ((double)resCnt.longValue() / cnt.longValue()));
-
- super.tearDown();
+ }
+
/**
* @param minSalary Min salary.
* @param maxSalary Max salary.
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/parent/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d4ce809/pom.xml
----------------------------------------------------------------------
diff --cc pom.xml
index 68e57c6,1008981..115df88
--- a/pom.xml
+++ b/pom.xml
@@@ -73,10 -73,14 +73,13 @@@
<module>modules/cloud</module>
<module>modules/mesos</module>
<module>modules/kafka</module>
+ <module>modules/flume</module>
<module>modules/yarn</module>
<module>modules/jms11</module>
+ <module>modules/twitter</module>
<module>modules/mqtt</module>
<module>modules/zookeeper</module>
+ <module>modules/camel</module>
- <module>modules/platform</module>
</modules>
<profiles>
[52/55] [abbrv] ignite git commit: Merge branch ignite-1.5 into
ignite-1282
Posted by ag...@apache.org.
Merge branch ignite-1.5 into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3d8c4c0f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3d8c4c0f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3d8c4c0f
Branch: refs/heads/ignite-1.5
Commit: 3d8c4c0f0cf7eda1544969dcc5663a9da0d6f9d2
Parents: ae5fb3e 457ca6f
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Sat Nov 21 12:25:43 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Sat Nov 21 12:25:43 2015 +0300
----------------------------------------------------------------------
.../datastructures/IgniteSemaphoreExample.java | 168 ++
.../ignite/examples/CacheExamplesSelfTest.java | 10 +-
.../stream/camel/IgniteCamelStreamerTest.java | 16 +-
.../camel/IgniteCamelStreamerTestSuite.java | 1 -
.../src/main/java/org/apache/ignite/Ignite.java | 17 +
.../java/org/apache/ignite/IgniteSemaphore.java | 312 ++++
.../apache/ignite/events/DiscoveryEvent.java | 6 +-
.../apache/ignite/internal/IgniteKernal.java | 21 +
.../internal/MarshallerContextAdapter.java | 4 +-
.../internal/direct/DirectByteBufferStream.java | 1499 -----------------
.../internal/direct/DirectMessageReader.java | 144 +-
.../internal/direct/DirectMessageWriter.java | 65 +-
.../direct/DirectMessageWriterState.java | 123 --
.../direct/state/DirectMessageState.java | 98 ++
.../direct/state/DirectMessageStateItem.java | 28 +
.../direct/stream/DirectByteBufferStream.java | 316 ++++
.../stream/v1/DirectByteBufferStreamImplV1.java | 1360 +++++++++++++++
.../stream/v2/DirectByteBufferStreamImplV2.java | 1583 ++++++++++++++++++
.../managers/communication/GridIoManager.java | 64 +-
.../GridCachePartitionExchangeManager.java | 34 +-
.../processors/cache/GridCacheUtils.java | 39 +-
.../CacheDataStructuresManager.java | 2 +-
.../GridFutureRemapTimeoutObject.java | 72 -
.../dht/GridClientPartitionTopology.java | 38 +-
.../distributed/dht/GridDhtLockFuture.java | 1 -
.../dht/GridDhtPartitionTopology.java | 12 +-
.../dht/GridDhtPartitionTopologyImpl.java | 45 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 1 -
.../dht/GridPartitionedGetFuture.java | 30 +-
.../colocated/GridDhtColocatedLockFuture.java | 1 -
.../dht/preloader/GridDhtPartitionFullMap.java | 41 +-
.../dht/preloader/GridDhtPartitionMap.java | 148 +-
.../dht/preloader/GridDhtPartitionMap2.java | 306 ++++
.../GridDhtPartitionsExchangeFuture.java | 24 +-
.../GridDhtPartitionsSingleMessage.java | 6 +-
.../distributed/near/GridNearCacheAdapter.java | 1 -
.../distributed/near/GridNearGetFuture.java | 30 +-
.../distributed/near/GridNearLockFuture.java | 2 -
...arOptimisticSerializableTxPrepareFuture.java | 3 -
.../near/GridNearOptimisticTxPrepareFuture.java | 1 -
.../near/GridNearTxFinishFuture.java | 4 -
.../distributed/near/GridNearTxRemote.java | 1 -
.../processors/cache/local/GridLocalCache.java | 1 -
.../cache/local/GridLocalLockFuture.java | 2 -
.../cache/transactions/IgniteInternalTx.java | 1 -
.../cache/transactions/IgniteTxAdapter.java | 1 -
.../IgniteTxImplicitSingleStateImpl.java | 29 +-
.../cache/transactions/IgniteTxManager.java | 1 -
.../IgniteTxRemoteSingleStateImpl.java | 19 +-
.../cache/transactions/IgniteTxStateImpl.java | 1 -
.../datastructures/DataStructuresProcessor.java | 240 ++-
.../GridAtomicCacheQueueImpl.java | 126 +-
.../GridCacheAtomicReferenceImpl.java | 10 +-
.../GridCacheCountDownLatchImpl.java | 15 +-
.../datastructures/GridCacheQueueAdapter.java | 32 +-
.../datastructures/GridCacheSemaphoreEx.java | 47 +
.../datastructures/GridCacheSemaphoreImpl.java | 763 +++++++++
.../datastructures/GridCacheSemaphoreState.java | 144 ++
.../GridTransactionalCacheQueueImpl.java | 193 +--
.../ignite/internal/util/IgniteUtils.java | 31 +
.../internal/util/ipc/IpcToNioAdapter.java | 14 +-
.../util/nio/GridCommunicationClient.java | 4 +-
.../internal/util/nio/GridDirectParser.java | 37 +-
.../util/nio/GridNioMessageReaderFactory.java | 37 +
.../util/nio/GridNioMessageWriterFactory.java | 35 +
.../ignite/internal/util/nio/GridNioServer.java | 47 +-
.../util/nio/GridShmemCommunicationClient.java | 12 +-
.../ignite/internal/visor/cache/VisorCache.java | 6 +-
.../communication/MessageFormatter.java | 15 +-
.../extensions/communication/MessageReader.java | 26 +-
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 6 +-
.../communication/tcp/TcpCommunicationSpi.java | 80 +-
.../ignite/spi/discovery/DiscoverySpi.java | 2 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 36 +
.../org/apache/ignite/stream/StreamAdapter.java | 1 -
.../apache/ignite/stream/StreamTransformer.java | 9 +-
.../resources/META-INF/classnames.properties | 1 +
.../IgniteClientReconnectAtomicsTest.java | 44 +-
...eAbstractDataStructuresFailoverSelfTest.java | 1065 +++++++-----
.../IgniteClientDataStructuresAbstractTest.java | 59 +-
.../IgniteDataStructureUniqueNameTest.java | 14 +-
.../IgniteSemaphoreAbstractSelfTest.java | 411 +++++
.../local/IgniteLocalSemaphoreSelfTest.java | 98 ++
...rtitionedDataStructuresFailoverSelfTest.java | 7 +-
...edOffheapDataStructuresFailoverSelfTest.java | 12 +-
.../IgnitePartitionedSemaphoreSelfTest.java | 33 +
...eplicatedDataStructuresFailoverSelfTest.java | 7 +-
.../IgniteReplicatedSemaphoreSelfTest.java | 33 +
.../dht/GridCacheDhtPreloadDelayedSelfTest.java | 12 +-
.../dht/GridCacheDhtPreloadSelfTest.java | 4 +-
.../distributed/dht/GridCacheDhtTestUtils.java | 8 +-
...gniteAtomicLongChangingTopologySelfTest.java | 2 +
...cingDelayedPartitionMapExchangeSelfTest.java | 178 ++
.../cache/GridCacheDataStructuresLoadTest.java | 283 ++--
...GridTcpCommunicationSpiRecoverySelfTest.java | 4 +-
...lientDiscoverySpiFailureTimeoutSelfTest.java | 4 +-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 90 +-
.../testframework/GridSpiTestContext.java | 12 +-
.../testframework/junits/GridAbstractTest.java | 6 +-
.../ignite/testframework/junits/IgniteMock.java | 10 +
.../junits/multijvm/IgniteProcessProxy.java | 7 +
.../testsuites/IgniteCacheTestSuite3.java | 2 +
.../h2/twostep/GridReduceQueryExecutor.java | 4 +-
.../org/apache/ignite/IgniteSpringBean.java | 12 +
.../spring/IgniteTransactionHolder.java | 97 ++
.../spring/SpringTransactionManager.java | 522 ++++++
.../transactions/spring/package-info.java | 22 +
.../test/java/config/spring-transactions.xml | 36 +
.../testsuites/IgniteSpringTestSuite.java | 5 +-
.../GridSpringTransactionManagerSelfTest.java | 165 ++
.../spring/GridSpringTransactionService.java | 68 +
.../cache/WaitMapExchangeFinishCallable.java | 4 +-
.../IgniteFailoverAbstractBenchmark.java | 4 +-
parent/pom.xml | 4 +-
114 files changed, 9013 insertions(+), 3036 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/Ignite.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/CacheDataStructuresManager.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --cc modules/core/src/main/resources/META-INF/classnames.properties
index 94deec2,065a72b..96be534
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@@ -645,10 -629,10 +645,11 @@@ org.apache.ignite.internal.processors.c
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$1
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$SupplyContextPhase
+ org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyPool$1
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyPool$DemandMessage
+org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture$2
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3d8c4c0f/parent/pom.xml
----------------------------------------------------------------------
[05/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs
new file mode 100644
index 0000000..74ae244
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/BinaryConfigurationTest.cs
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Binary configuration tests.
+ /// </summary>
+ public class BinaryConfigurationTest
+ {
+ /** Cache. */
+ private ICache<int, TestGenericBinarizableBase> _cache;
+
+ /** Random generator. */
+ private static readonly Random Rnd = new Random();
+
+ /** Test types for code config */
+ private static readonly Type[] TestTypes = {
+ typeof (TestGenericBinarizable<int>),
+ typeof (TestGenericBinarizable<string>),
+ typeof (TestGenericBinarizable<TestGenericBinarizable<int>>),
+ typeof (TestGenericBinarizable<List<Tuple<int, string>>>),
+ typeof (TestGenericBinarizable<int, string>),
+ typeof (TestGenericBinarizable<int, TestGenericBinarizable<string>>),
+ typeof (TestGenericBinarizable<int, string, Type>),
+ typeof (TestGenericBinarizable<int, string, TestGenericBinarizable<int, string, Type>>)
+ };
+
+ /** Test types for xml config */
+ private static readonly Type[] TestTypesXml = {
+ typeof (TestGenericBinarizable<long>),
+ typeof (TestGenericBinarizable<Type>),
+ typeof (TestGenericBinarizable<TestGenericBinarizable<long>>),
+ typeof (TestGenericBinarizable<List<Tuple<long, string>>>),
+ typeof (TestGenericBinarizable<long, string>),
+ typeof (TestGenericBinarizable<long, TestGenericBinarizable<string>>),
+ typeof (TestGenericBinarizable<long, string, Type>),
+ typeof (TestGenericBinarizable<long, string, TestGenericBinarizable<long, string, Type>>)
+ };
+
+ /// <summary>
+ /// Starts the grid with provided config.
+ /// </summary>
+ /// <param name="binaryConfiguration">The binary configuration.</param>
+ private void StartGrid(BinaryConfiguration binaryConfiguration)
+ {
+ Ignition.StopAll(true);
+
+ var grid = Ignition.Start(new IgniteConfiguration
+ {
+ SpringConfigUrl = "config\\cache-binarizables.xml",
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ BinaryConfiguration = binaryConfiguration
+ });
+
+ _cache = grid.GetCache<int, TestGenericBinarizableBase>(null);
+ }
+
+ /// <summary>
+ /// Test fixture tear-down routine.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void TestFixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the configuration set in code.
+ /// </summary>
+ [Test]
+ public void TestCodeConfiguration()
+ {
+ StartGrid(new BinaryConfiguration
+ {
+ TypeConfigurations = TestTypes.Select(x => new BinaryTypeConfiguration(x)).ToList()
+ });
+
+ CheckBinarizableTypes(TestTypes);
+ }
+
+ /// <summary>
+ /// Tests the configuration set in xml.
+ /// </summary>
+ [Test]
+ public void TestXmlConfiguration()
+ {
+ StartGrid(null);
+
+ CheckBinarizableTypes(TestTypesXml);
+ }
+
+ /// <summary>
+ /// Checks that specified types are binarizable and can be successfully used in cache.
+ /// </summary>
+ private void CheckBinarizableTypes(IEnumerable<Type> testTypes)
+ {
+ int key = 0;
+
+ foreach (var typ in testTypes)
+ {
+ key += 1;
+
+ var inst = CreateInstance(typ);
+
+ _cache.Put(key, inst);
+
+ var result = _cache.Get(key);
+
+ Assert.AreEqual(inst.Prop, result.Prop);
+
+ Assert.AreEqual(typ, result.GetType());
+ }
+ }
+
+ /// <summary>
+ /// Creates the instance of specified test binarizable type and sets a value on it.
+ /// </summary>
+ private static TestGenericBinarizableBase CreateInstance(Type type)
+ {
+ var inst = (TestGenericBinarizableBase)Activator.CreateInstance(type);
+
+ inst.Prop = Rnd.Next(int.MaxValue);
+
+ return inst;
+ }
+ }
+
+ public abstract class TestGenericBinarizableBase
+ {
+ public object Prop { get; set; }
+ }
+
+ public class TestGenericBinarizable<T> : TestGenericBinarizableBase
+ {
+ public T Prop1 { get; set; }
+ }
+
+ public class TestGenericBinarizable<T1, T2> : TestGenericBinarizableBase
+ {
+ public T1 Prop1 { get; set; }
+ public T2 Prop2 { get; set; }
+ }
+
+ public class TestGenericBinarizable<T1, T2, T3> : TestGenericBinarizableBase
+ {
+ public T1 Prop1 { get; set; }
+ public T2 Prop2 { get; set; }
+ public T3 Prop3 { get; set; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 7df0e5a..64124d7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -148,7 +148,7 @@ namespace Apache.Ignite.Core.Tests.Cache
public bool ThrowErr { get; set; }
// Error flag
- public bool ThrowErrPortable { get; set; }
+ public bool ThrowErrBinarizable { get; set; }
// Error flag
public bool ThrowErrNonSerializable { get; set; }
@@ -179,8 +179,8 @@ namespace Apache.Ignite.Core.Tests.Cache
if (ThrowErr)
throw new Exception(ExceptionText);
- if (ThrowErrPortable)
- throw new PortableTestException {Info = ExceptionText};
+ if (ThrowErrBinarizable)
+ throw new BinarizableTestException {Info = ExceptionText};
if (ThrowErrNonSerializable)
throw new NonSerializableException();
@@ -204,9 +204,9 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// Portable add processor.
+ /// Binary add processor.
/// </summary>
- public class PortableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IBinarizable
+ public class BinarizableAddArgCacheEntryProcessor : AddArgCacheEntryProcessor, IBinarizable
{
/** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
@@ -214,7 +214,7 @@ namespace Apache.Ignite.Core.Tests.Cache
var w = writer.GetRawWriter();
w.WriteBoolean(ThrowErr);
- w.WriteBoolean(ThrowErrPortable);
+ w.WriteBoolean(ThrowErrBinarizable);
w.WriteBoolean(ThrowErrNonSerializable);
w.WriteInt(ThrowOnKey);
w.WriteBoolean(Remove);
@@ -227,7 +227,7 @@ namespace Apache.Ignite.Core.Tests.Cache
var r = reader.GetRawReader();
ThrowErr = r.ReadBoolean();
- ThrowErrPortable = r.ReadBoolean();
+ ThrowErrBinarizable = r.ReadBoolean();
ThrowErrNonSerializable = r.ReadBoolean();
ThrowOnKey = r.ReadInt();
Remove = r.ReadBoolean();
@@ -244,9 +244,9 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// Portable exception.
+ /// Binary exception.
/// </summary>
- public class PortableTestException : Exception, IBinarizable
+ public class BinarizableTestException : Exception, IBinarizable
{
/// <summary>
/// Gets or sets exception info.
@@ -298,11 +298,11 @@ namespace Apache.Ignite.Core.Tests.Cache
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortablePerson)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizablePerson)));
portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(CacheTestKey)));
portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(TestReferenceObject)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableAddArgCacheEntryProcessor)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableTestException)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableAddArgCacheEntryProcessor)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableTestException)));
portCfg.TypeConfigurations = portTypeCfgs;
@@ -1558,11 +1558,11 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestPutGetPortable()
+ public void TestPutGetBinary()
{
- var cache = Cache<int, PortablePerson>();
+ var cache = Cache<int, BinarizablePerson>();
- PortablePerson obj1 = new PortablePerson("obj1", 1);
+ BinarizablePerson obj1 = new BinarizablePerson("obj1", 1);
cache.Put(1, obj1);
@@ -1573,11 +1573,11 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestPutGetPortableAsync()
+ public void TestPutGetBinaryAsync()
{
- var cache = Cache<int, PortablePerson>().WrapAsync();
+ var cache = Cache<int, BinarizablePerson>().WrapAsync();
- PortablePerson obj1 = new PortablePerson("obj1", 1);
+ BinarizablePerson obj1 = new BinarizablePerson("obj1", 1);
cache.Put(1, obj1);
@@ -1588,7 +1588,7 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestPutGetPortableKey()
+ public void TestPutGetBinaryKey()
{
var cache = Cache<CacheTestKey, string>();
@@ -1674,7 +1674,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Category(TestUtils.CategoryIntensive)]
public void TestPutGetAsyncMultithreaded()
{
- var cache = Cache<CacheTestKey, PortablePerson>();
+ var cache = Cache<CacheTestKey, BinarizablePerson>();
const int threads = 10;
const int objPerThread = 1000;
@@ -1692,7 +1692,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- futs.Add(cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key)));
+ futs.Add(cache.PutAsync(new CacheTestKey(key), new BinarizablePerson("Person-" + key, key)));
}
foreach (var fut in futs)
@@ -1729,7 +1729,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key)).Wait();
+ cache.PutAsync(new CacheTestKey(key), new BinarizablePerson("Person-" + key, key)).Wait();
}
}, threads);
@@ -1739,7 +1739,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int threadIdx = Interlocked.Increment(ref cntr);
- var futs = new List<Task<PortablePerson>>();
+ var futs = new List<Task<BinarizablePerson>>();
for (int i = 0; i < objPerThread; i++)
{
@@ -1765,9 +1765,9 @@ namespace Apache.Ignite.Core.Tests.Cache
//[Test]
//[Category(TestUtils.CATEGORY_INTENSIVE)]
- public void TestAsyncMultithreadedKeepPortable()
+ public void TestAsyncMultithreadedKeepBinary()
{
- var cache = Cache().WithKeepBinary<CacheTestKey, PortablePerson>();
+ var cache = Cache().WithKeepBinary<CacheTestKey, BinarizablePerson>();
var portCache = Cache().WithKeepBinary<CacheTestKey, IBinaryObject>();
const int threads = 10;
@@ -1786,7 +1786,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- var task = cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
+ var task = cache.PutAsync(new CacheTestKey(key), new BinarizablePerson("Person-" + key, key));
futs.Add(task);
}
@@ -2742,15 +2742,15 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestKeepPortableFlag()
+ public void TestKeepBinaryFlag()
{
- TestKeepPortableFlag(false);
+ TestKeepBinaryFlag(false);
}
[Test]
- public void TestKeepPortableFlagAsync()
+ public void TestKeepBinaryFlagAsync()
{
- TestKeepPortableFlag(true);
+ TestKeepBinaryFlag(true);
}
[Test]
@@ -2793,7 +2793,7 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
- public void TestSerializableKeepPortable()
+ public void TestSerializableKeepBinary()
{
var cache = Cache<int, TestSerializableObject>();
@@ -2801,9 +2801,9 @@ namespace Apache.Ignite.Core.Tests.Cache
cache.Put(1, obj);
- var portableResult = cache.WithKeepBinary<int, IBinaryObject>().Get(1);
+ var binaryRes = cache.WithKeepBinary<int, IBinaryObject>().Get(1);
- var resultObj = portableResult.Deserialize<TestSerializableObject>();
+ var resultObj = binaryRes.Deserialize<TestSerializableObject>();
Assert.AreEqual(obj, resultObj);
}
@@ -2823,7 +2823,7 @@ namespace Apache.Ignite.Core.Tests.Cache
private void TestInvoke(bool async)
{
TestInvoke<AddArgCacheEntryProcessor>(async);
- TestInvoke<PortableAddArgCacheEntryProcessor>(async);
+ TestInvoke<BinarizableAddArgCacheEntryProcessor>(async);
try
{
@@ -2863,7 +2863,7 @@ namespace Apache.Ignite.Core.Tests.Cache
// Test exceptions
AssertThrowsCacheEntryProcessorException(() => cache.Invoke(key, new T {ThrowErr = true}, arg));
AssertThrowsCacheEntryProcessorException(
- () => cache.Invoke(key, new T {ThrowErrPortable = true}, arg));
+ () => cache.Invoke(key, new T {ThrowErrBinarizable = true}, arg));
AssertThrowsCacheEntryProcessorException(
() => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "BinaryObjectException");
}
@@ -2904,7 +2904,7 @@ namespace Apache.Ignite.Core.Tests.Cache
for (var i = 1; i < 10; i++)
{
TestInvokeAll<AddArgCacheEntryProcessor>(async, i);
- TestInvokeAll<PortableAddArgCacheEntryProcessor>(async, i);
+ TestInvokeAll<BinarizableAddArgCacheEntryProcessor>(async, i);
try
{
@@ -2956,7 +2956,7 @@ namespace Apache.Ignite.Core.Tests.Cache
var errKey = entries.Keys.Reverse().Take(5).Last();
TestInvokeAllException(cache, entries, new T { ThrowErr = true, ThrowOnKey = errKey }, arg, errKey);
- TestInvokeAllException(cache, entries, new T { ThrowErrPortable = true, ThrowOnKey = errKey },
+ TestInvokeAllException(cache, entries, new T { ThrowErrBinarizable = true, ThrowOnKey = errKey },
arg, errKey);
TestInvokeAllException(cache, entries, new T { ThrowErrNonSerializable = true, ThrowOnKey = errKey },
arg, errKey, "BinaryObjectException");
@@ -3088,20 +3088,20 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(5, cache[1]);
}
- private void TestKeepPortableFlag(bool async)
+ private void TestKeepBinaryFlag(bool async)
{
var cache0 = async ? Cache().WrapAsync() : Cache();
- var cache = cache0.WithKeepBinary<int, PortablePerson>();
+ var cache = cache0.WithKeepBinary<int, BinarizablePerson>();
- var portCache = cache0.WithKeepBinary<int, IBinaryObject>();
+ var binCache = cache0.WithKeepBinary<int, IBinaryObject>();
int cnt = 10;
IList<int> keys = new List<int>();
for (int i = 0; i < cnt; i++ ) {
- cache.Put(i, new PortablePerson("person-" + i, i));
+ cache.Put(i, new BinarizablePerson("person-" + i, i));
keys.Add(i);
}
@@ -3110,7 +3110,7 @@ namespace Apache.Ignite.Core.Tests.Cache
for (int i = 0; i < cnt; i++)
{
- var obj = portCache.Get(i);
+ var obj = binCache.Get(i);
CheckPersonData(obj, "person-" + i, i);
@@ -3125,10 +3125,10 @@ namespace Apache.Ignite.Core.Tests.Cache
CheckPersonData(obj, "person-" + i, i);
}
- // Check keepPortable for GetAll operation.
- var allObjs1 = portCache.GetAll(keys);
+ // Check keepBinary for GetAll operation.
+ var allObjs1 = binCache.GetAll(keys);
- var allObjs2 = portCache.GetAll(keys);
+ var allObjs2 = binCache.GetAll(keys);
for (int i = 0; i < cnt; i++)
{
@@ -3137,7 +3137,7 @@ namespace Apache.Ignite.Core.Tests.Cache
CheckPersonData(allObjs2[i], "person-" + i, i);
}
- // Check keepPortable for Remove operation.
+ // Check keepBinary for Remove operation.
var success0 = cache.Remove(0);
var success1 = cache.Remove(1);
@@ -3150,7 +3150,7 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(expName, obj.GetField<string>("name"));
Assert.AreEqual(expAge, obj.GetField<int>("age"));
- PortablePerson person = obj.Deserialize<PortablePerson>();
+ BinarizablePerson person = obj.Deserialize<BinarizablePerson>();
Assert.AreEqual(expName, person.Name);
Assert.AreEqual(expAge, person.Age);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
index abb9e02..5a1af03 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
@@ -77,10 +77,10 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// Test affinity with portable flag.
+ /// Test affinity with binary flag.
/// </summary>
[Test]
- public void TestAffinityPortable()
+ public void TestAffinityBinary()
{
IIgnite g = Ignition.GetIgnite("grid-0");
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
index 693a664..63443b7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
@@ -109,17 +109,17 @@ namespace Apache.Ignite.Core.Tests.Cache
{
Assert.Throws<ArgumentException>(() =>
{
- Ignition.GetIgnite(GridData).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ Ignition.GetIgnite(GridData).GetCache<CacheTestKey, BinarizablePerson>(CacheDummy);
});
Assert.Throws<ArgumentException>(() =>
{
- Ignition.GetIgnite(GridDataNoCfg).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ Ignition.GetIgnite(GridDataNoCfg).GetCache<CacheTestKey, BinarizablePerson>(CacheDummy);
});
Assert.Throws<ArgumentException>(() =>
{
- Ignition.GetIgnite(GridClient).GetCache<CacheTestKey, PortablePerson>(CacheDummy);
+ Ignition.GetIgnite(GridClient).GetCache<CacheTestKey, BinarizablePerson>(CacheDummy);
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 74c4801..411ef05 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -64,8 +64,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
TypeConfigurations = new[]
{
new BinaryTypeConfiguration(typeof (QueryPerson)),
- new BinaryTypeConfiguration(typeof (PortableScanQueryFilter<QueryPerson>)),
- new BinaryTypeConfiguration(typeof (PortableScanQueryFilter<BinaryObject>))
+ new BinaryTypeConfiguration(typeof (BinarizableScanQueryFilter<QueryPerson>)),
+ new BinaryTypeConfiguration(typeof (BinarizableScanQueryFilter<BinaryObject>))
}
},
JvmClasspath = TestUtils.CreateTestClasspath(),
@@ -359,10 +359,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check SQL query in portable mode.
+ /// Check SQL query in binary mode.
/// </summary>
[Test]
- public void TestSqlQueryPortable()
+ public void TestSqlQueryBinary()
{
CheckSqlQuery(MaxItemCnt, false, true);
}
@@ -377,10 +377,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check local SQL query in portable mode.
+ /// Check local SQL query in binary mode.
/// </summary>
[Test]
- public void TestSqlQueryLocalPortable()
+ public void TestSqlQueryLocalBinary()
{
CheckSqlQuery(MaxItemCnt, true, true);
}
@@ -390,8 +390,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckSqlQuery(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckSqlQuery(int cnt, bool loc, bool keepBinary)
{
var cache = Cache();
@@ -402,7 +402,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
SqlQuery qry = loc ? new SqlQuery(typeof(QueryPerson), "age < 50", true) :
new SqlQuery(typeof(QueryPerson), "age < 50");
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
}
/// <summary>
@@ -479,10 +479,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check SQL query in portable mode.
+ /// Check SQL query in binary mode.
/// </summary>
[Test]
- public void TestTextQueryPortable()
+ public void TestTextQueryBinary()
{
CheckTextQuery(MaxItemCnt, false, true);
}
@@ -497,10 +497,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check local SQL query in portable mode.
+ /// Check local SQL query in binary mode.
/// </summary>
[Test]
- public void TestTextQueryLocalPortable()
+ public void TestTextQueryLocalBinary()
{
CheckTextQuery(MaxItemCnt, true, true);
}
@@ -510,8 +510,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckTextQuery(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckTextQuery(int cnt, bool loc, bool keepBinary)
{
var cache = Cache();
@@ -522,7 +522,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
TextQuery qry = loc ? new TextQuery(typeof(QueryPerson), "1*", true) :
new TextQuery(typeof(QueryPerson), "1*");
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
}
/// <summary>
@@ -535,10 +535,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check scan query in portable mode.
+ /// Check scan query in binary mode.
/// </summary>
[Test]
- public void TestScanQueryPortable()
+ public void TestScanQueryBinary()
{
CheckScanQuery<BinaryObject>(MaxItemCnt, false, true);
}
@@ -553,10 +553,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check local scan query in portable mode.
+ /// Check local scan query in binary mode.
/// </summary>
[Test]
- public void TestScanQueryLocalPortable()
+ public void TestScanQueryLocalBinary()
{
CheckScanQuery<BinaryObject>(MaxItemCnt, true, true);
}
@@ -572,11 +572,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Check scan query with partitions in portable mode.
+ /// Check scan query with partitions in binary mode.
/// </summary>
[Test]
[Ignore("IGNITE-1012")]
- public void TestScanQueryPartitionsPortable([Values(true, false)] bool loc)
+ public void TestScanQueryPartitionsBinary([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<BinaryObject>(MaxItemCnt, loc, true);
}
@@ -609,36 +609,36 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckScanQuery<TV>(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckScanQuery<TV>(int cnt, bool loc, bool keepBinary)
{
var cache = Cache();
// No predicate
var exp = PopulateCache(cache, loc, cnt, x => true);
var qry = new ScanQuery<int, TV>();
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
// Serializable
exp = PopulateCache(cache, loc, cnt, x => x < 50);
qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>());
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ ValidateQueryResults(cache, qry, exp, keepBinary);
- // Portable
+ // Binarizable
exp = PopulateCache(cache, loc, cnt, x => x < 50);
- qry = new ScanQuery<int, TV>(new PortableScanQueryFilter<TV>());
- ValidateQueryResults(cache, qry, exp, keepPortable);
+ qry = new ScanQuery<int, TV>(new BinarizableScanQueryFilter<TV>());
+ ValidateQueryResults(cache, qry, exp, keepBinary);
// Invalid
exp = PopulateCache(cache, loc, cnt, x => x < 50);
qry = new ScanQuery<int, TV>(new InvalidScanQueryFilter<TV>());
- Assert.Throws<BinaryObjectException>(() => ValidateQueryResults(cache, qry, exp, keepPortable));
+ Assert.Throws<BinaryObjectException>(() => ValidateQueryResults(cache, qry, exp, keepBinary));
// Exception
exp = PopulateCache(cache, loc, cnt, x => x < 50);
qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV> {ThrowErr = true});
- var ex = Assert.Throws<IgniteException>(() => ValidateQueryResults(cache, qry, exp, keepPortable));
+ var ex = Assert.Throws<IgniteException>(() => ValidateQueryResults(cache, qry, exp, keepBinary));
Assert.AreEqual(ScanQueryFilter<TV>.ErrMessage, ex.Message);
}
@@ -647,8 +647,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// </summary>
/// <param name="cnt">Amount of cache entries to create.</param>
/// <param name="loc">Local query flag.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
- private void CheckScanQueryPartitions<TV>(int cnt, bool loc, bool keepPortable)
+ /// <param name="keepBinary">Keep binary flag.</param>
+ private void CheckScanQueryPartitions<TV>(int cnt, bool loc, bool keepBinary)
{
StopGrids();
StartGrids();
@@ -669,7 +669,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
var qry = new ScanQuery<int, TV> { Partition = part };
Console.WriteLine("Checking query on partition " + part);
- ValidateQueryResults(cache, qry, exp0, keepPortable);
+ ValidateQueryResults(cache, qry, exp0, keepBinary);
}
// Partitions with predicate
@@ -686,7 +686,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
var qry = new ScanQuery<int, TV>(new ScanQueryFilter<TV>()) { Partition = part };
Console.WriteLine("Checking predicate query on partition " + part);
- ValidateQueryResults(cache, qry, exp0, keepPortable);
+ ValidateQueryResults(cache, qry, exp0, keepBinary);
}
}
@@ -697,11 +697,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// <param name="cache">Cache.</param>
/// <param name="qry">Query.</param>
/// <param name="exp">Expected keys.</param>
- /// <param name="keepPortable">Keep binary flag.</param>
+ /// <param name="keepBinary">Keep binary flag.</param>
private static void ValidateQueryResults(ICache<int, QueryPerson> cache, QueryBase qry, HashSet<int> exp,
- bool keepPortable)
+ bool keepBinary)
{
- if (keepPortable)
+ if (keepBinary)
{
var cache0 = cache.WithKeepBinary<int, IBinaryObject>();
@@ -906,9 +906,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
}
/// <summary>
- /// Portable query filter.
+ /// binary query filter.
/// </summary>
- public class PortableScanQueryFilter<TV> : ScanQueryFilter<TV>, IBinarizable
+ public class BinarizableScanQueryFilter<TV> : ScanQueryFilter<TV>, IBinarizable
{
/** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index b81405b..cb9542f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -69,10 +69,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
private IIgnite grid2;
/** Cache on the first node. */
- private ICache<int, PortableEntry> cache1;
+ private ICache<int, BinarizableEntry> cache1;
/** Cache on the second node. */
- private ICache<int, PortableEntry> cache2;
+ private ICache<int, BinarizableEntry> cache2;
/** Cache name. */
private readonly string cacheName;
@@ -101,9 +101,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableEntry)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(PortableFilter)));
- portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(KeepPortableFilter)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableEntry)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFilter)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(KeepBinaryFilter)));
portCfg.TypeConfigurations = portTypeCfgs;
@@ -114,11 +114,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
cfg.GridName = "grid-1";
grid1 = Ignition.Start(cfg);
- cache1 = grid1.GetCache<int, PortableEntry>(cacheName);
+ cache1 = grid1.GetCache<int, BinarizableEntry>(cacheName);
cfg.GridName = "grid-2";
grid2 = Ignition.Start(cfg);
- cache2 = grid2.GetCache<int, PortableEntry>(cacheName);
+ cache2 = grid2.GetCache<int, BinarizableEntry>(cacheName);
}
/// <summary>
@@ -139,10 +139,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
CB_EVTS = new BlockingCollection<CallbackEvent>();
FILTER_EVTS = new BlockingCollection<FilterEvent>();
- AbstractFilter<PortableEntry>.res = true;
- AbstractFilter<PortableEntry>.err = false;
- AbstractFilter<PortableEntry>.marshErr = false;
- AbstractFilter<PortableEntry>.unmarshErr = false;
+ AbstractFilter<BinarizableEntry>.res = true;
+ AbstractFilter<BinarizableEntry>.err = false;
+ AbstractFilter<BinarizableEntry>.marshErr = false;
+ AbstractFilter<BinarizableEntry>.unmarshErr = false;
cache1.Remove(PrimaryKey(cache1));
cache1.Remove(PrimaryKey(cache2));
@@ -159,7 +159,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
[Test]
public void TestValidation()
{
- Assert.Throws<ArgumentException>(() => { cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(null)); });
+ Assert.Throws<ArgumentException>(() => { cache1.QueryContinuous(new ContinuousQuery<int, BinarizableEntry>(null)); });
}
/// <summary>
@@ -171,8 +171,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
int key1 = PrimaryKey(cache1);
int key2 = PrimaryKey(cache2);
- ContinuousQuery<int, PortableEntry> qry =
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry =
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
IDisposable qryHnd;
@@ -208,9 +208,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
int key1 = PrimaryKey(cache1);
int key2 = PrimaryKey(cache2);
- ContinuousQuery<int, PortableEntry> qry = loc ?
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>(), true) :
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry = loc ?
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>(), true) :
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
using (cache1.QueryContinuous(qry))
{
@@ -260,21 +260,21 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
[Test]
public void TestCallbackInjection()
{
- Listener<PortableEntry> cb = new Listener<PortableEntry>();
+ Listener<BinarizableEntry> cb = new Listener<BinarizableEntry>();
Assert.IsNull(cb.ignite);
- using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb)))
+ using (cache1.QueryContinuous(new ContinuousQuery<int, BinarizableEntry>(cb)))
{
Assert.IsNotNull(cb.ignite);
}
}
/// <summary>
- /// Test portable filter logic.
+ /// Test binarizable filter logic.
/// </summary>
[Test]
- public void TestFilterPortable()
+ public void TestFilterBinarizable()
{
CheckFilter(true, false);
}
@@ -291,17 +291,17 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter.
/// </summary>
- /// <param name="portable">Portable.</param>
+ /// <param name="binarizable">Binarizable.</param>
/// <param name="loc">Local cache flag.</param>
- protected void CheckFilter(bool portable, bool loc)
+ protected void CheckFilter(bool binarizable, bool loc)
{
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>) new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = loc ?
- new ContinuousQuery<int, PortableEntry>(lsnr, filter, true) :
- new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = loc ?
+ new ContinuousQuery<int, BinarizableEntry>(lsnr, filter, true) :
+ new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
using (cache1.QueryContinuous(qry))
{
@@ -326,7 +326,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
CheckCallbackSingle(key2, null, Entry(key2));
}
- AbstractFilter<PortableEntry>.res = false;
+ AbstractFilter<BinarizableEntry>.res = false;
// Ignored put from local node.
cache1.GetAndPut(key1, Entry(key1 + 1));
@@ -346,11 +346,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter error during invoke.
+ /// Test binarizable filter error during invoke.
/// </summary>
[Ignore("IGNITE-521")]
[Test]
- public void TestFilterInvokeErrorPortable()
+ public void TestFilterInvokeErrorBinarizable()
{
CheckFilterInvokeError(true);
}
@@ -368,15 +368,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter error handling logic during invoke.
/// </summary>
- private void CheckFilterInvokeError(bool portable)
+ private void CheckFilterInvokeError(bool binarizable)
{
- AbstractFilter<PortableEntry>.err = true;
+ AbstractFilter<BinarizableEntry>.err = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>) new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>) new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
using (cache1.QueryContinuous(qry))
{
@@ -415,10 +415,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter marshalling error.
+ /// Test binarizable filter marshalling error.
/// </summary>
[Test]
- public void TestFilterMarshalErrorPortable()
+ public void TestFilterMarshalErrorBinarizable()
{
CheckFilterMarshalError(true);
}
@@ -435,16 +435,16 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter marshal error handling.
/// </summary>
- /// <param name="portable">Portable flag.</param>
- private void CheckFilterMarshalError(bool portable)
+ /// <param name="binarizable">Binarizable flag.</param>
+ private void CheckFilterMarshalError(bool binarizable)
{
- AbstractFilter<PortableEntry>.marshErr = true;
+ AbstractFilter<BinarizableEntry>.marshErr = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>)new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
Assert.Throws<Exception>(() =>
{
@@ -470,14 +470,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="loc"></param>
protected void CheckFilterNonSerializable(bool loc)
{
- AbstractFilter<PortableEntry>.unmarshErr = true;
+ AbstractFilter<BinarizableEntry>.unmarshErr = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter = new LocalFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter = new LocalFilter();
- ContinuousQuery<int, PortableEntry> qry = loc
- ? new ContinuousQuery<int, PortableEntry>(lsnr, filter, true)
- : new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = loc
+ ? new ContinuousQuery<int, BinarizableEntry>(lsnr, filter, true)
+ : new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
if (loc)
{
@@ -502,11 +502,11 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter unmarshalling error.
+ /// Test binarizable filter unmarshalling error.
/// </summary>
[Ignore("IGNITE-521")]
[Test]
- public void TestFilterUnmarshalErrorPortable()
+ public void TestFilterUnmarshalErrorBinarizable()
{
CheckFilterUnmarshalError(true);
}
@@ -524,16 +524,16 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Check filter unmarshal error handling.
/// </summary>
- /// <param name="portable">Portable flag.</param>
- private void CheckFilterUnmarshalError(bool portable)
+ /// <param name="binarizable">Binarizable flag.</param>
+ private void CheckFilterUnmarshalError(bool binarizable)
{
- AbstractFilter<PortableEntry>.unmarshErr = true;
+ AbstractFilter<BinarizableEntry>.unmarshErr = true;
- ICacheEntryEventListener<int, PortableEntry> lsnr = new Listener<PortableEntry>();
- ICacheEntryEventFilter<int, PortableEntry> filter =
- portable ? (AbstractFilter<PortableEntry>)new PortableFilter() : new SerializableFilter();
+ ICacheEntryEventListener<int, BinarizableEntry> lsnr = new Listener<BinarizableEntry>();
+ ICacheEntryEventFilter<int, BinarizableEntry> filter =
+ binarizable ? (AbstractFilter<BinarizableEntry>) new BinarizableFilter() : new SerializableFilter();
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(lsnr, filter);
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(lsnr, filter);
using (cache1.QueryContinuous(qry))
{
@@ -566,12 +566,12 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
[Test]
public void TestFilterInjection()
{
- Listener<PortableEntry> cb = new Listener<PortableEntry>();
- PortableFilter filter = new PortableFilter();
+ Listener<BinarizableEntry> cb = new Listener<BinarizableEntry>();
+ BinarizableFilter filter = new BinarizableFilter();
Assert.IsNull(filter.ignite);
- using (cache1.QueryContinuous(new ContinuousQuery<int, PortableEntry>(cb, filter)))
+ using (cache1.QueryContinuous(new ContinuousQuery<int, BinarizableEntry>(cb, filter)))
{
// Local injection.
Assert.IsNotNull(filter.ignite);
@@ -589,15 +589,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
- /// Test "keep-portable" scenario.
+ /// Test "keep-binary" scenario.
/// </summary>
[Test]
- public void TestKeepPortable()
+ public void TestKeepBinary()
{
var cache = cache1.WithKeepBinary<int, IBinaryObject>();
ContinuousQuery<int, IBinaryObject> qry = new ContinuousQuery<int, IBinaryObject>(
- new Listener<IBinaryObject>(), new KeepPortableFilter());
+ new Listener<IBinaryObject>(), new KeepBinaryFilter());
using (cache.QueryContinuous(qry))
{
@@ -611,14 +611,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
Assert.AreEqual(PrimaryKey(cache1), filterEvt.entry.Key);
Assert.AreEqual(null, filterEvt.entry.OldValue);
Assert.AreEqual(Entry(1), (filterEvt.entry.Value as IBinaryObject)
- .Deserialize<PortableEntry>());
+ .Deserialize<BinarizableEntry>());
Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
Assert.AreEqual(1, cbEvt.entries.Count);
Assert.AreEqual(PrimaryKey(cache1), cbEvt.entries.First().Key);
Assert.AreEqual(null, cbEvt.entries.First().OldValue);
Assert.AreEqual(Entry(1), (cbEvt.entries.First().Value as IBinaryObject)
- .Deserialize<PortableEntry>());
+ .Deserialize<BinarizableEntry>());
// 2. Remote put.
cache1.GetAndPut(PrimaryKey(cache2), Entry(2));
@@ -627,14 +627,14 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
Assert.AreEqual(PrimaryKey(cache2), filterEvt.entry.Key);
Assert.AreEqual(null, filterEvt.entry.OldValue);
Assert.AreEqual(Entry(2), (filterEvt.entry.Value as IBinaryObject)
- .Deserialize<PortableEntry>());
+ .Deserialize<BinarizableEntry>());
Assert.IsTrue(CB_EVTS.TryTake(out cbEvt, 500));
Assert.AreEqual(1, cbEvt.entries.Count);
Assert.AreEqual(PrimaryKey(cache2), cbEvt.entries.First().Key);
Assert.AreEqual(null, cbEvt.entries.First().OldValue);
Assert.AreEqual(Entry(2),
- (cbEvt.entries.First().Value as IBinaryObject).Deserialize<PortableEntry>());
+ (cbEvt.entries.First().Value as IBinaryObject).Deserialize<BinarizableEntry>());
}
}
/// <summary>
@@ -697,7 +697,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
// Put two remote keys in advance.
List<int> rmtKeys = PrimaryKeys(cache2, 2);
- ContinuousQuery<int, PortableEntry> qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry = new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
qry.BufferSize = 2;
qry.TimeInterval = TimeSpan.FromMilliseconds(1000000);
@@ -743,8 +743,8 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
int key1 = PrimaryKey(cache1);
int key2 = PrimaryKey(cache2);
- ContinuousQuery<int, PortableEntry> qry =
- new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ ContinuousQuery<int, BinarizableEntry> qry =
+ new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
qry.BufferSize = 2;
qry.TimeInterval = TimeSpan.FromMilliseconds(500);
@@ -791,26 +791,26 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
public void TestInitialQuery()
{
// Scan query, GetAll
- TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.GetAll());
+ TestInitialQuery(new ScanQuery<int, BinarizableEntry>(new InitialQueryScanFilter()), cur => cur.GetAll());
// Scan query, iterator
- TestInitialQuery(new ScanQuery<int, PortableEntry>(new InitialQueryScanFilter()), cur => cur.ToList());
+ TestInitialQuery(new ScanQuery<int, BinarizableEntry>(new InitialQueryScanFilter()), cur => cur.ToList());
// Sql query, GetAll
- TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.GetAll());
+ TestInitialQuery(new SqlQuery(typeof(BinarizableEntry), "val < 33"), cur => cur.GetAll());
// Sql query, iterator
- TestInitialQuery(new SqlQuery(typeof(PortableEntry), "val < 33"), cur => cur.ToList());
+ TestInitialQuery(new SqlQuery(typeof(BinarizableEntry), "val < 33"), cur => cur.ToList());
// Text query, GetAll
- TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.GetAll());
+ TestInitialQuery(new TextQuery(typeof(BinarizableEntry), "1*"), cur => cur.GetAll());
// Text query, iterator
- TestInitialQuery(new TextQuery(typeof(PortableEntry), "1*"), cur => cur.ToList());
+ TestInitialQuery(new TextQuery(typeof(BinarizableEntry), "1*"), cur => cur.ToList());
// Test exception: invalid initial query
var ex = Assert.Throws<IgniteException>(
- () => TestInitialQuery(new TextQuery(typeof (PortableEntry), "*"), cur => cur.GetAll()));
+ () => TestInitialQuery(new TextQuery(typeof (BinarizableEntry), "*"), cur => cur.GetAll()));
Assert.AreEqual("Cannot parse '*': '*' or '?' not allowed as first character in WildcardQuery", ex.Message);
}
@@ -818,10 +818,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Tests the initial query.
/// </summary>
- private void TestInitialQuery(QueryBase initialQry, Func<IQueryCursor<ICacheEntry<int, PortableEntry>>,
- IEnumerable<ICacheEntry<int, PortableEntry>>> getAllFunc)
+ private void TestInitialQuery(QueryBase initialQry, Func<IQueryCursor<ICacheEntry<int, BinarizableEntry>>,
+ IEnumerable<ICacheEntry<int, BinarizableEntry>>> getAllFunc)
{
- var qry = new ContinuousQuery<int, PortableEntry>(new Listener<PortableEntry>());
+ var qry = new ContinuousQuery<int, BinarizableEntry>(new Listener<BinarizableEntry>());
cache1.Put(11, Entry(11));
cache1.Put(12, Entry(12));
@@ -829,7 +829,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
try
{
- IContinuousQueryHandle<ICacheEntry<int, PortableEntry>> contQry;
+ IContinuousQueryHandle<ICacheEntry<int, BinarizableEntry>> contQry;
using (contQry = cache1.QueryContinuous(qry, initialQry))
{
@@ -868,7 +868,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="expKey">Expected key.</param>
/// <param name="expOldVal">Expected old value.</param>
/// <param name="expVal">Expected value.</param>
- private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
+ private void CheckFilterSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal)
{
CheckFilterSingle(expKey, expOldVal, expVal, 1000);
}
@@ -880,7 +880,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="expOldVal">Expected old value.</param>
/// <param name="expVal">Expected value.</param>
/// <param name="timeout">Timeout.</param>
- private void CheckFilterSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
+ private void CheckFilterSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal, int timeout)
{
FilterEvent evt;
@@ -908,7 +908,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="expKey">Expected key.</param>
/// <param name="expOldVal">Expected old value.</param>
/// <param name="expVal">Expected new value.</param>
- private void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal)
+ private void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal)
{
CheckCallbackSingle(expKey, expOldVal, expVal, 1000);
}
@@ -920,7 +920,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <param name="expOldVal">Expected old value.</param>
/// <param name="expVal">Expected new value.</param>
/// <param name="timeout">Timeout.</param>
- private void CheckCallbackSingle(int expKey, PortableEntry expOldVal, PortableEntry expVal, int timeout)
+ private void CheckCallbackSingle(int expKey, BinarizableEntry expOldVal, BinarizableEntry expVal, int timeout)
{
CallbackEvent evt;
@@ -949,9 +949,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// </summary>
/// <param name="val">Value.</param>
/// <returns>Entry.</returns>
- private static PortableEntry Entry(int val)
+ private static BinarizableEntry Entry(int val)
{
- return new PortableEntry(val);
+ return new BinarizableEntry(val);
}
/// <summary>
@@ -1010,9 +1010,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Portable entry.
+ /// Binarizable entry.
/// </summary>
- public class PortableEntry
+ public class BinarizableEntry
{
/** Value. */
public readonly int val;
@@ -1027,7 +1027,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// Constructor.
/// </summary>
/// <param name="val">Value.</param>
- public PortableEntry(int val)
+ public BinarizableEntry(int val)
{
this.val = val;
}
@@ -1035,7 +1035,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/** <inheritDoc /> */
public override bool Equals(object obj)
{
- return obj != null && obj is PortableEntry && ((PortableEntry)obj).val == val;
+ return obj != null && obj is BinarizableEntry && ((BinarizableEntry)obj).val == val;
}
}
@@ -1076,15 +1076,15 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// <summary>
/// Filter which cannot be serialized.
/// </summary>
- public class LocalFilter : AbstractFilter<PortableEntry>
+ public class LocalFilter : AbstractFilter<BinarizableEntry>
{
// No-op.
}
/// <summary>
- /// Portable filter.
+ /// Binarizable filter.
/// </summary>
- public class PortableFilter : AbstractFilter<PortableEntry>, IBinarizable
+ public class BinarizableFilter : AbstractFilter<BinarizableEntry>, IBinarizable
{
/** <inheritDoc /> */
public void WriteBinary(IBinaryWriter writer)
@@ -1105,7 +1105,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// Serializable filter.
/// </summary>
[Serializable]
- public class SerializableFilter : AbstractFilter<PortableEntry>, ISerializable
+ public class SerializableFilter : AbstractFilter<BinarizableEntry>, ISerializable
{
/// <summary>
/// Constructor.
@@ -1135,9 +1135,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Filter for "keep-portable" scenario.
+ /// Filter for "keep-binary" scenario.
/// </summary>
- public class KeepPortableFilter : AbstractFilter<IBinaryObject>
+ public class KeepBinaryFilter : AbstractFilter<IBinaryObject>
{
// No-op.
}
@@ -1173,7 +1173,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
IBinaryType meta = val.GetBinaryType();
- Assert.AreEqual(typeof(PortableEntry).Name, meta.TypeName);
+ Assert.AreEqual(typeof(BinarizableEntry).Name, meta.TypeName);
}
countDown.Signal();
@@ -1225,10 +1225,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
/// ScanQuery filter for InitialQuery test.
/// </summary>
[Serializable]
- private class InitialQueryScanFilter : ICacheEntryFilter<int, PortableEntry>
+ private class InitialQueryScanFilter : ICacheEntryFilter<int, BinarizableEntry>
{
/** <inheritdoc /> */
- public bool Invoke(ICacheEntry<int, PortableEntry> entry)
+ public bool Invoke(ICacheEntry<int, BinarizableEntry> entry)
{
return entry.Key < 33;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
index aa7d627..1d2f1f2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryNoBackupAbstractTest.cs
@@ -43,10 +43,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
/// <summary>
- /// Test portable filter logic.
+ /// Test binary filter logic.
/// </summary>
[Test]
- public void TestFilterPortableLocal()
+ public void TestFilterBinarizableLocal()
{
CheckFilter(true, true);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index eb148f0..1270138 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -117,7 +117,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
public class CacheStoreTest
{
/** */
- private const string PortableStoreCacheName = "portable_store";
+ private const string BinaryStoreCacheName = "binary_store";
/** */
private const string ObjectStoreCacheName = "object_store";
@@ -145,7 +145,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
IgniteConfigurationEx cfg = new IgniteConfigurationEx();
- cfg.GridName = GridName();
+ cfg.GridName = GridName;
cfg.JvmClasspath = TestUtils.CreateTestClasspath();
cfg.JvmOptions = TestUtils.TestJavaOptions();
cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml";
@@ -183,7 +183,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[TearDown]
public void AfterTest()
{
- var cache = Cache();
+ var cache = GetCache();
cache.Clear();
@@ -191,7 +191,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
CacheTestStore.Reset();
- TestUtils.AssertHandleRegistryHasItems(300, _storeCount, Ignition.GetIgnite(GridName()));
+ TestUtils.AssertHandleRegistryHasItems(300, _storeCount, Ignition.GetIgnite(GridName));
Console.WriteLine("Test finished: " + TestContext.CurrentContext.Test.Name);
}
@@ -199,7 +199,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestLoadCache()
{
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -220,7 +220,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestLocalLoadCache()
{
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -237,7 +237,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
{
CacheTestStore.LoadObjects = true;
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -255,7 +255,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestLoadCacheAsync()
{
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -272,7 +272,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestPutLoad()
{
- var cache = Cache();
+ var cache = GetCache();
cache.Put(1, "val");
@@ -290,9 +290,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
}
[Test]
- public void TestPutLoadPortables()
+ public void TestPutLoadBinarizable()
{
- var cache = PortableStoreCache<int, Value>();
+ var cache = GetBinaryStoreCache<int, Value>();
cache.Put(1, new Value(1));
@@ -316,7 +316,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestPutLoadObjects()
{
- var cache = ObjectStoreCache<int, Value>();
+ var cache = GetObjectStoreCache<int, Value>();
cache.Put(1, new Value(1));
@@ -345,7 +345,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
for (int i = 0; i < 10; i++)
putMap.Add(i, "val_" + i);
- var cache = Cache();
+ var cache = GetCache();
cache.PutAll(putMap);
@@ -378,7 +378,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestRemove()
{
- var cache = Cache();
+ var cache = GetCache();
for (int i = 0; i < 10; i++)
cache.Put(i, "val_" + i);
@@ -399,7 +399,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestRemoveAll()
{
- var cache = Cache();
+ var cache = GetCache();
for (int i = 0; i < 10; i++)
cache.Put(i, "val_" + i);
@@ -419,7 +419,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestTx()
{
- var cache = Cache();
+ var cache = GetCache();
using (var tx = cache.Ignite.GetTransactions().TxStart())
{
@@ -444,7 +444,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
{
CacheTestStore.LoadMultithreaded = true;
- var cache = Cache();
+ var cache = GetCache();
Assert.AreEqual(0, cache.GetSize());
@@ -459,7 +459,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestCustomStoreProperties()
{
- var cache = CustomStoreCache();
+ var cache = GetCustomStoreCache();
Assert.IsNotNull(cache);
Assert.AreEqual(42, CacheTestStore.intProperty);
@@ -469,7 +469,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestDynamicStoreStart()
{
- var cache = TemplateStoreCache();
+ var cache = GetTemplateStoreCache();
Assert.IsNotNull(cache);
@@ -483,10 +483,10 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
/// <summary>
/// Get's grid name for this test.
/// </summary>
- /// <returns>Grid name.</returns>
- protected virtual string GridName()
+ /// <value>Grid name.</value>
+ protected virtual string GridName
{
- return null;
+ get { return null; }
}
private IDictionary StoreMap()
@@ -494,31 +494,31 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
return CacheTestStore.Map;
}
- private ICache<int, string> Cache()
+ private ICache<int, string> GetCache()
{
- return PortableStoreCache<int, string>();
+ return GetBinaryStoreCache<int, string>();
}
- private ICache<TK, TV> PortableStoreCache<TK, TV>()
+ private ICache<TK, TV> GetBinaryStoreCache<TK, TV>()
{
- return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(PortableStoreCacheName);
+ return Ignition.GetIgnite(GridName).GetCache<TK, TV>(BinaryStoreCacheName);
}
- private ICache<TK, TV> ObjectStoreCache<TK, TV>()
+ private ICache<TK, TV> GetObjectStoreCache<TK, TV>()
{
- return Ignition.GetIgnite(GridName()).GetCache<TK, TV>(ObjectStoreCacheName);
+ return Ignition.GetIgnite(GridName).GetCache<TK, TV>(ObjectStoreCacheName);
}
- private ICache<int, string> CustomStoreCache()
+ private ICache<int, string> GetCustomStoreCache()
{
- return Ignition.GetIgnite(GridName()).GetCache<int, string>(CustomStoreCacheName);
+ return Ignition.GetIgnite(GridName).GetCache<int, string>(CustomStoreCacheName);
}
- private ICache<int, string> TemplateStoreCache()
+ private ICache<int, string> GetTemplateStoreCache()
{
var cacheName = TemplateStoreCacheName.Replace("*", Guid.NewGuid().ToString());
- return Ignition.GetIgnite(GridName()).GetOrCreateCache<int, string>(cacheName);
+ return Ignition.GetIgnite(GridName).GetOrCreateCache<int, string>(cacheName);
}
}
@@ -528,9 +528,9 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
public class NamedNodeCacheStoreTest : CacheStoreTest
{
/** <inheritDoc /> */
- protected override string GridName()
+ protected override string GridName
{
- return "name";
+ get { return "name"; }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
index 9e96ca2..e3d0d96 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/AbstractTaskTest.cs
@@ -171,7 +171,7 @@ namespace Apache.Ignite.Core.Tests.Compute
ICollection<BinaryTypeConfiguration> portTypeCfgs = new List<BinaryTypeConfiguration>();
- PortableTypeConfigurations(portTypeCfgs);
+ GetBinaryTypeConfigurations(portTypeCfgs);
portCfg.TypeConfigurations = portTypeCfgs;
@@ -206,10 +206,10 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/// <summary>
- /// Define portable types.
+ /// Define binary types.
/// </summary>
- /// <param name="portTypeCfgs">Portable type configurations.</param>
- protected virtual void PortableTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ /// <param name="portTypeCfgs">Binary type configurations.</param>
+ protected virtual void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
{
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
new file mode 100644
index 0000000..b881582
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableClosureTaskTest.cs
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Compute
+{
+ using System;
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Compute;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Closure execution tests for binary objects.
+ /// </summary>
+ public class BinarizableClosureTaskTest : ClosureTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public BinarizableClosureTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected BinarizableClosureTaskTest(bool fork) : base(fork) { }
+
+ /** <inheritDoc /> */
+ protected override void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableOutFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableFunc)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableResult)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableException)));
+ }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object> OutFunc(bool err)
+ {
+ return new BinarizableOutFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override IComputeFunc<object, object> Func(bool err)
+ {
+ return new BinarizableFunc(err);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckResult(object res)
+ {
+ Assert.IsTrue(res != null);
+
+ BinarizableResult res0 = res as BinarizableResult;
+
+ Assert.IsTrue(res0 != null);
+ Assert.AreEqual(1, res0.Res);
+ }
+
+ /** <inheritDoc /> */
+ protected override void CheckError(Exception err)
+ {
+ Assert.IsTrue(err != null);
+
+ BinarizableException err0 = err as BinarizableException;
+
+ Assert.IsTrue(err0 != null);
+ Assert.AreEqual(ErrMsg, err0.Msg);
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableOutFunc : IComputeFunc<object>
+ {
+ /** Error. */
+ private readonly bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public BinarizableOutFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke()
+ {
+ if (_err)
+ throw new BinarizableException(ErrMsg);
+ return new BinarizableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableFunc : IComputeFunc<object, object>
+ {
+ /** Error. */
+ private readonly bool _err;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="err"></param>
+ public BinarizableFunc(bool err)
+ {
+ _err = err;
+ }
+
+ /** <inheritDoc /> */
+ public object Invoke(object arg)
+ {
+ if (_err)
+ throw new BinarizableException(ErrMsg);
+ return new BinarizableResult(1);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableException : Exception, IBinarizable
+ {
+ /** */
+ public string Msg;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="msg"></param>
+ public BinarizableException(string msg)
+ {
+ Msg = msg;
+ }
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.GetRawWriter().WriteString(Msg);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Msg = reader.GetRawReader().ReadString();
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ private class BinarizableResult
+ {
+ /** */
+ public readonly int Res;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="res"></param>
+ public BinarizableResult(int res)
+ {
+ Res = res;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
new file mode 100644
index 0000000..5c1ee34
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/BinarizableTaskTest.cs
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Compute
+{
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cluster;
+ using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Resource;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Task test result.
+ /// </summary>
+ public class BinarizableTaskTest : AbstractTaskTest
+ {
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ public BinarizableTaskTest() : base(false) { }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="fork">Fork flag.</param>
+ protected BinarizableTaskTest(bool fork) : base(fork) { }
+
+ /// <summary>
+ /// Test for task result.
+ /// </summary>
+ [Test]
+ public void TestBinarizableObjectInTask()
+ {
+ var taskArg = new BinarizableWrapper {Item = ToBinary(Grid1, new BinarizableTaskArgument(100))};
+
+ TestTask task = new TestTask(Grid1, taskArg);
+
+ var res = Grid1.GetCompute().Execute(task, taskArg).Item;
+
+ Assert.NotNull(res);
+
+ Assert.AreEqual(400, res.GetField<int>("val"));
+
+ BinarizableTaskResult resObj = res.Deserialize<BinarizableTaskResult>();
+
+ Assert.AreEqual(400, resObj.Val);
+ }
+
+ private static IBinaryObject ToBinary(IIgnite grid, object obj)
+ {
+ var cache = grid.GetCache<object, object>(Cache1Name).WithKeepBinary<object, object>();
+
+ cache.Put(1, obj);
+
+ return (IBinaryObject) cache.Get(1);
+ }
+
+ /** <inheritDoc /> */
+ override protected void GetBinaryTypeConfigurations(ICollection<BinaryTypeConfiguration> portTypeCfgs)
+ {
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJobArgument)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJobResult)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableTaskArgument)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableTaskResult)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableJob)));
+ portTypeCfgs.Add(new BinaryTypeConfiguration(typeof(BinarizableWrapper)));
+ }
+
+ /// <summary>
+ /// Test task.
+ /// </summary>
+ class TestTask : ComputeTaskAdapter<BinarizableWrapper, BinarizableWrapper, BinarizableWrapper>
+ {
+ /** */
+ private readonly IIgnite _grid;
+
+ private readonly BinarizableWrapper _taskArgField;
+
+ public TestTask(IIgnite grid, BinarizableWrapper taskArgField)
+ {
+ _grid = grid;
+ _taskArgField = taskArgField;
+ }
+
+ /** <inheritDoc /> */
+ override public IDictionary<IComputeJob<BinarizableWrapper>, IClusterNode> Map(IList<IClusterNode> subgrid, BinarizableWrapper arg)
+ {
+ Assert.AreEqual(3, subgrid.Count);
+ Assert.NotNull(_grid);
+
+ var taskArg = arg;
+
+ CheckTaskArgument(taskArg);
+
+ CheckTaskArgument(_taskArgField);
+
+ var jobs = new Dictionary<IComputeJob<BinarizableWrapper>, IClusterNode>();
+
+
+ foreach (IClusterNode node in subgrid)
+ {
+ if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
+ {
+ var job = new BinarizableJob
+ {
+ Arg = new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableJobArgument(200))}
+ };
+
+ jobs.Add(job, node);
+ }
+ }
+
+ Assert.AreEqual(2, jobs.Count);
+
+ return jobs;
+ }
+
+ private void CheckTaskArgument(BinarizableWrapper arg)
+ {
+ Assert.IsNotNull(arg);
+
+ var taskArg = arg.Item;
+
+ Assert.IsNotNull(taskArg);
+
+ Assert.AreEqual(100, taskArg.GetField<int>("val"));
+
+ BinarizableTaskArgument taskArgObj = taskArg.Deserialize<BinarizableTaskArgument>();
+
+ Assert.AreEqual(100, taskArgObj.Val);
+ }
+
+ /** <inheritDoc /> */
+ override public BinarizableWrapper Reduce(IList<IComputeJobResult<BinarizableWrapper>> results)
+ {
+ Assert.NotNull(_grid);
+
+ Assert.AreEqual(2, results.Count);
+
+ foreach (var res in results)
+ {
+ var jobRes = res.Data.Item;
+
+ Assert.NotNull(jobRes);
+
+ Assert.AreEqual(300, jobRes.GetField<int>("val"));
+
+ BinarizableJobResult jobResObj = jobRes.Deserialize<BinarizableJobResult>();
+
+ Assert.AreEqual(300, jobResObj.Val);
+ }
+
+ return new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableTaskResult(400))};
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableJobArgument
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableJobArgument(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableJobResult
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableJobResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableTaskArgument
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableTaskArgument(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableTaskResult
+ {
+ /** */
+ public readonly int Val;
+
+ public BinarizableTaskResult(int val)
+ {
+ Val = val;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ class BinarizableJob : IComputeJob<BinarizableWrapper>
+ {
+ [InstanceResource]
+ private readonly IIgnite _grid = null;
+
+ /** */
+ public BinarizableWrapper Arg;
+
+ /** <inheritDoc /> */
+
+ public BinarizableWrapper Execute()
+ {
+ Assert.IsNotNull(Arg);
+
+ var arg = Arg.Item;
+
+ Assert.IsNotNull(arg);
+
+ Assert.AreEqual(200, arg.GetField<int>("val"));
+
+ var argObj = arg.Deserialize<BinarizableJobArgument>();
+
+ Assert.AreEqual(200, argObj.Val);
+
+ return new BinarizableWrapper {Item = ToBinary(_grid, new BinarizableJobResult(300))};
+ }
+
+ public void Cancel()
+ {
+ // No-op.
+ }
+ }
+
+ class BinarizableWrapper
+ {
+ public IBinaryObject Item { get; set; }
+ }
+ }
+}
[47/55] [abbrv] ignite git commit: Merge branch 'ignite-1282' of
https://git-wip-us.apache.org/repos/asf/ignite into ignite-1282
Posted by ag...@apache.org.
Merge branch 'ignite-1282' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a28649e0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a28649e0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a28649e0
Branch: refs/heads/ignite-1.5
Commit: a28649e0d5aa15af82678a67590f0ee238012284
Parents: 0410f0e f37863a
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 15:37:13 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 15:37:13 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryReaderExImpl.java | 65 ++++++++++++--------
.../portable/PortableClassDescriptor.java | 16 +++++
.../platform/cache/PlatformCache.java | 9 ++-
.../Cache/CacheTestAsyncWrapper.cs | 1 -
.../Cache/Query/CacheQueriesTest.cs | 2 -
.../Apache.Ignite.Core/Cache/Query/ScanQuery.cs | 14 +----
.../Impl/Cache/CacheEntryFilterHolder.cs | 15 -----
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 15 +----
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 2 +-
9 files changed, 62 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
[51/55] [abbrv] ignite git commit: IGNITE-1282 - Fixed test.
Posted by ag...@apache.org.
IGNITE-1282 - Fixed test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ae5fb3e3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ae5fb3e3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ae5fb3e3
Branch: refs/heads/ignite-1.5
Commit: ae5fb3e387bb2e349b4a9e12ebf9c72012e3a380
Parents: 80abb06
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 21:05:19 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 21:05:19 2015 +0300
----------------------------------------------------------------------
.../cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ae5fb3e3/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
index e5c9425..4d9456a 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.apache.ignite.marshaller.portable.BinaryMarshaller;
/**
@@ -93,7 +94,7 @@ public class IgniteCacheP2pUnmarshallingQueryErrorTest extends IgniteCacheP2pUnm
private boolean portableMarshaller() {
IgniteEx kernal = (IgniteEx)ignite(0);
- return BinaryMarshaller.class.getSimpleName().equals(kernal.context().config().getMarshaller().getClass()
+ return !OptimizedMarshaller.class.getSimpleName().equals(kernal.context().config().getMarshaller().getClass()
.getSimpleName());
}
}
\ No newline at end of file
[40/55] [abbrv] ignite git commit: Merge branch ignite-1.5 into
ignite-1282
Posted by ag...@apache.org.
Merge branch ignite-1.5 into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9b6adb29
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9b6adb29
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9b6adb29
Branch: refs/heads/ignite-1.5
Commit: 9b6adb2903d69ac6e5cbf6e1677ee2ec9447fb2c
Parents: 3d4ce80
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 14:04:22 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 14:04:22 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheMapEntry.java | 4 +-
.../GridDistributedTxPrepareRequest.java | 3 +-
.../dht/GridPartitionedSingleGetFuture.java | 6 +-
.../dht/colocated/GridDhtColocatedCache.java | 2 +-
.../transactions/IgniteTxLocalAdapter.java | 71 ++++++++++++--------
5 files changed, 50 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b6adb29/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 512a801..2b40351 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -1986,7 +1986,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
(EntryProcessor<Object, Object, ?>)writeObj;
CacheInvokeEntry<Object, Object> entry =
- new CacheInvokeEntry<>(cctx, key, prevVal, version());
+ new CacheInvokeEntry<>(cctx, key, prevVal, version(), keepPortable);
try {
entryProcessor.process(entry, invokeArgs);
@@ -1994,7 +1994,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
evtVal = entry.modified() ?
cctx.toCacheObject(cctx.unwrapTemporary(entry.getValue())) : prevVal;
}
- catch (Exception e) {
+ catch (Exception ignore) {
evtVal = prevVal;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b6adb29/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
index 95176ff..e595942 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxPrepareRequest.java
@@ -329,8 +329,7 @@ public class GridDistributedTxPrepareRequest extends GridDistributedBaseMessage
}
// Marshal txNodes only if there is a node in topology with an older version.
- if (ctx.exchange().minimumNodeVersion(topologyVersion())
- .compareTo(TX_NODES_DIRECT_MARSHALLABLE_SINCE) < 0) {
+ if (ctx.exchange().minimumNodeVersion(topologyVersion()).compareTo(TX_NODES_DIRECT_MARSHALLABLE_SINCE) < 0) {
if (txNodes != null && txNodesBytes == null)
txNodesBytes = ctx.marshaller().marshal(txNodes);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b6adb29/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index 8f2357b..32f4e80 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -347,7 +347,8 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
subjId,
null,
taskName,
- expiryPlc);
+ expiryPlc,
+ true);
if (res != null) {
v = res.get1();
@@ -366,7 +367,8 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
subjId,
null,
taskName,
- expiryPlc);
+ expiryPlc,
+ true);
}
colocated.context().evicts().touch(entry, topVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b6adb29/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 72f5cf5..b69b42c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -239,7 +239,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
}
});
}
- });
+ }, opCtx);
}
AffinityTopologyVersion topVer = tx == null ?
http://git-wip-us.apache.org/repos/asf/ignite/blob/9b6adb29/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index fae7d8c..7c6a1d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -67,7 +67,6 @@ import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException;
import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.GridLongList;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -2047,7 +2046,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
final CacheEntryPredicate[] filter,
final GridCacheReturn ret,
boolean skipStore,
- final boolean singleRmv) {
+ final boolean singleRmv,
+ boolean keepBinary) {
try {
addActiveCache(cacheCtx);
@@ -2076,7 +2076,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
singleRmv,
hasFilters,
needVal,
- needReadVer);
+ needReadVer,
+ keepBinary);
if (loadMissed) {
return loadMissing(cacheCtx,
@@ -2087,7 +2088,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
singleRmv,
hasFilters,
skipStore,
- retval);
+ retval,
+ keepBinary);
}
return new GridFinishedFuture<>();
@@ -2146,8 +2148,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
boolean rmv = lookup == null && invokeMap == null;
- Set<KeyCacheObject> missedForLoad = null;
-
final boolean hasFilters = !F.isEmptyOrNulls(filter) && !F.isAlwaysTrue(filter);
final boolean needVal = singleRmv || retval || hasFilters;
final boolean needReadVer = needVal && (serializable() && optimistic());
@@ -2157,6 +2157,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (invokeMap != null)
transform = true;
+ Set<KeyCacheObject> missedForLoad = null;
+
for (Object key : keys) {
if (key == null) {
rollback();
@@ -2219,7 +2221,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
singleRmv,
hasFilters,
needVal,
- needReadVer);
+ needReadVer,
+ keepBinary);
if (loadMissed) {
if (missedForLoad == null)
@@ -2238,7 +2241,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
singleRmv,
hasFilters,
skipStore,
- retval);
+ retval,
+ keepBinary);
}
return new GridFinishedFuture<>();
@@ -2269,7 +2273,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
final boolean singleRmv,
final boolean hasFilters,
final boolean skipStore,
- final boolean retval) {
+ final boolean retval,
+ final boolean keepBinary) {
GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c =
new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
@Override public void apply(KeyCacheObject key,
@@ -2317,7 +2322,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
else {
boolean success = !hasFilters || isAll(e.context(), key, cacheVal, filter);
- ret.set(cacheCtx, cacheVal, success);
+ ret.set(cacheCtx, cacheVal, success, keepBinary);
}
}
}
@@ -2330,6 +2335,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
keys,
/*skipVals*/singleRmv,
needReadVer,
+ keepBinary,
c);
}
@@ -2341,7 +2347,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
* @param invokeArgs Optional arguments for EntryProcessor.
* @param expiryPlc Explicitly specified expiry policy for entry.
* @param retval Return value flag.
- * @param lockOnly
+ * @param lockOnly Lock only flag.
* @param filter Filter.
* @param drVer DR version.
* @param drTtl DR ttl.
@@ -2358,10 +2364,10 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
*/
private boolean enlistWriteEntry(GridCacheContext cacheCtx,
final KeyCacheObject cacheKey,
- final @Nullable Object val,
- final @Nullable EntryProcessor<?, ?, ?> entryProcessor,
- final @Nullable Object[] invokeArgs,
- final @Nullable ExpiryPolicy expiryPlc,
+ @Nullable final Object val,
+ @Nullable final EntryProcessor<?, ?, ?> entryProcessor,
+ @Nullable final Object[] invokeArgs,
+ @Nullable final ExpiryPolicy expiryPlc,
final boolean retval,
final boolean lockOnly,
final CacheEntryPredicate[] filter,
@@ -2374,7 +2380,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
boolean singleRmv,
boolean hasFilters,
final boolean needVal,
- boolean needReadVer
+ boolean needReadVer,
+ boolean keepBinary
) throws IgniteCheckedException {
boolean loadMissed = false;
@@ -2418,7 +2425,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
CU.subjectId(this, cctx),
entryProcessor,
resolveTaskName(),
- null) : null;
+ null,
+ keepBinary) : null;
if (res != null) {
old = res.get1();
@@ -2437,7 +2445,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
CU.subjectId(this, cctx),
entryProcessor,
resolveTaskName(),
- null);
+ null,
+ keepBinary);
}
}
catch (ClusterTopologyCheckedException e) {
@@ -2450,7 +2459,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
old = retval ? entry.rawGetOrUnmarshal(false) : entry.rawGet();
if (old != null && hasFilters && !filter(entry.context(), cacheKey, old, filter)) {
- ret.set(cacheCtx, old, false);
+ ret.set(cacheCtx, old, false, keepBinary);
if (!readCommitted()) {
// Enlist failed filters as reads for non-read-committed mode,
@@ -2466,7 +2475,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
-1L,
-1L,
null,
- skipStore);
+ skipStore,
+ keepBinary);
txEntry.markValid();
@@ -2497,7 +2507,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
drTtl,
drExpireTime,
drVer,
- skipStore);
+ skipStore,
+ keepBinary);
if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
cacheCtx.evicts().touch(entry, topologyVersion());
@@ -2516,7 +2527,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
assert txEntry.op() != TRANSFORM : txEntry;
if (retval)
- ret.set(cacheCtx, null, true);
+ ret.set(cacheCtx, null, true, keepBinary);
else
ret.success(true);
}
@@ -2529,7 +2540,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
if (retval && !transform)
- ret.set(cacheCtx, old, true);
+ ret.set(cacheCtx, old, true, keepBinary);
else {
if (txEntry.op() == TRANSFORM) {
GridCacheVersion ver;
@@ -2557,7 +2568,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
// Pessimistic.
else {
if (retval && !transform)
- ret.set(cacheCtx, old, true);
+ ret.set(cacheCtx, old, true, keepBinary);
else
ret.success(true);
}
@@ -2583,7 +2594,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (!del) {
if (hasFilters && !filter(entry.context(), cacheKey, v, filter)) {
- ret.set(cacheCtx, v, false);
+ ret.set(cacheCtx, v, false, keepBinary);
return loadMissed;
}
@@ -2602,7 +2613,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
drTtl,
drExpireTime,
drVer,
- skipStore);
+ skipStore,
+ keepBinary);
if (enlisted != null)
enlisted.add(cacheKey);
@@ -2630,7 +2642,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
txEntry.markValid();
if (retval && !transform)
- ret.set(cacheCtx, v, true);
+ ret.set(cacheCtx, v, true, keepBinary);
else
ret.success(true);
}
@@ -2904,7 +2916,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
final GridCacheContext cacheCtx,
K key,
@Nullable V val,
- @Nullable EntryProcessor entryProcessor,
+ @Nullable EntryProcessor<K, V, Object> entryProcessor,
@Nullable final Object[] invokeArgs,
final boolean retval,
@Nullable final CacheEntryPredicate[] filter
@@ -2932,7 +2944,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
filter,
ret,
opCtx != null && opCtx.skipStore(),
- /*singleRmv*/false);
+ /*singleRmv*/false,
+ opCtx != null && opCtx.isKeepBinary());
if (pessimistic()) {
assert loadFut == null || loadFut.isDone() : loadFut;
[43/55] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/ignite-1282' into ignite-1282
Posted by ag...@apache.org.
Merge remote-tracking branch 'origin/ignite-1282' into ignite-1282
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/911ca9dc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/911ca9dc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/911ca9dc
Branch: refs/heads/ignite-1.5
Commit: 911ca9dc876955fa219022e514dda5885d1e0d47
Parents: 3430586 6d4ecfd
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 14:19:32 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 14:19:32 2015 +0300
----------------------------------------------------------------------
modules/camel/README.txt | 34 +
modules/camel/licenses/apache-2.0.txt | 202 ++
modules/camel/pom.xml | 102 +
.../ignite/stream/camel/CamelStreamer.java | 237 ++
.../stream/camel/IgniteCamelStreamerTest.java | 420 ++++
.../camel/IgniteCamelStreamerTestSuite.java | 48 +
.../src/test/resources/camel.test.properties | 18 +
.../ignite/codegen/MessageCodeGenerator.java | 1 +
.../java/org/apache/ignite/IgniteCache.java | 3 +-
.../java/org/apache/ignite/IgniteCompute.java | 3 +-
.../org/apache/ignite/compute/ComputeJob.java | 2 +-
.../internal/GridEventConsumeHandler.java | 22 +-
.../internal/GridMessageListenHandler.java | 18 +
.../ignite/internal/GridUpdateNotifier.java | 2 +-
.../apache/ignite/internal/IgniteKernal.java | 9 +-
.../communication/GridIoMessageFactory.java | 26 +-
.../discovery/GridDiscoveryManager.java | 2 +-
.../processors/cache/GridCacheAdapter.java | 151 +-
.../processors/cache/GridCacheAtomicFuture.java | 6 +
.../cache/GridCacheDeploymentManager.java | 2 +-
.../processors/cache/GridCacheEntryEx.java | 12 +-
.../processors/cache/GridCacheFuture.java | 13 -
.../processors/cache/GridCacheGateway.java | 1 -
.../processors/cache/GridCacheIoManager.java | 50 +-
.../processors/cache/GridCacheMapEntry.java | 158 +-
.../processors/cache/GridCacheMessage.java | 20 +-
.../processors/cache/GridCacheMvcc.java | 7 -
.../processors/cache/GridCacheMvccFuture.java | 7 +
.../processors/cache/GridCacheMvccManager.java | 150 +-
.../GridCachePartitionExchangeManager.java | 59 +-
.../cache/GridCacheSharedContext.java | 38 +-
.../cache/GridCacheUpdateAtomicResult.java | 15 +-
.../cache/GridCacheUpdateTxResult.java | 24 +-
.../processors/cache/IgniteCacheProxy.java | 3 +
.../distributed/GridCacheTxRecoveryFuture.java | 54 +-
.../distributed/GridDistributedBaseMessage.java | 56 -
.../distributed/GridDistributedLockRequest.java | 6 -
.../GridDistributedLockResponse.java | 32 +-
.../distributed/GridDistributedTxMapping.java | 78 -
.../GridDistributedTxPrepareRequest.java | 66 +-
.../GridDistributedTxRemoteAdapter.java | 158 +-
.../dht/CacheDistributedGetFutureAdapter.java | 27 +-
.../cache/distributed/dht/CacheGetFuture.java | 32 +
.../dht/GridClientPartitionTopology.java | 38 +-
.../distributed/dht/GridDhtCacheAdapter.java | 141 ++
.../distributed/dht/GridDhtLocalPartition.java | 35 +
.../distributed/dht/GridDhtLockFuture.java | 79 +-
.../distributed/dht/GridDhtLockRequest.java | 2 +-
.../dht/GridDhtPartitionTopology.java | 26 +-
.../dht/GridDhtPartitionTopologyImpl.java | 112 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 14 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 38 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 112 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 28 +-
.../distributed/dht/GridDhtTxLocalAdapter.java | 89 +-
.../cache/distributed/dht/GridDhtTxMapping.java | 134 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 136 +-
.../dht/GridDhtTxPrepareRequest.java | 54 +-
.../cache/distributed/dht/GridDhtTxRemote.java | 29 +-
.../dht/GridPartitionedGetFuture.java | 69 +-
.../dht/GridPartitionedSingleGetFuture.java | 699 ++++++
.../dht/atomic/GridDhtAtomicCache.java | 206 +-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 159 +-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 121 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 5 -
.../dht/colocated/GridDhtColocatedCache.java | 162 +-
.../colocated/GridDhtColocatedLockFuture.java | 81 +-
.../GridDhtPartitionsExchangeFuture.java | 35 +-
.../preloader/GridDhtPartitionsFullMessage.java | 64 +-
.../GridDhtPartitionsSingleMessage.java | 56 +-
.../distributed/near/CacheVersionedValue.java | 2 +-
.../distributed/near/GridNearAtomicCache.java | 10 +-
.../distributed/near/GridNearCacheAdapter.java | 4 +-
.../distributed/near/GridNearGetFuture.java | 49 +-
.../distributed/near/GridNearGetRequest.java | 1 -
.../distributed/near/GridNearGetResponse.java | 2 -
.../distributed/near/GridNearLockFuture.java | 72 +-
.../distributed/near/GridNearLockRequest.java | 4 +-
...arOptimisticSerializableTxPrepareFuture.java | 124 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 170 +-
...ridNearOptimisticTxPrepareFutureAdapter.java | 72 +-
.../GridNearPessimisticTxPrepareFuture.java | 59 +-
.../near/GridNearSingleGetRequest.java | 396 ++++
.../near/GridNearSingleGetResponse.java | 321 +++
.../near/GridNearTransactionalCache.java | 10 +-
.../near/GridNearTxFinishFuture.java | 103 +-
.../cache/distributed/near/GridNearTxLocal.java | 273 ++-
.../near/GridNearTxPrepareFutureAdapter.java | 20 +-
.../near/GridNearTxPrepareRequest.java | 61 +-
.../distributed/near/GridNearTxRemote.java | 33 +-
.../distributed/near/IgniteTxMappings.java | 75 +
.../distributed/near/IgniteTxMappingsImpl.java | 92 +
.../near/IgniteTxMappingsSingleImpl.java | 101 +
.../processors/cache/local/GridLocalCache.java | 4 +-
.../cache/local/GridLocalLockFuture.java | 5 -
.../CacheContinuousQueryBatchAck.java | 163 ++
.../continuous/CacheContinuousQueryEntry.java | 196 +-
.../continuous/CacheContinuousQueryHandler.java | 811 ++++++-
.../CacheContinuousQueryListener.java | 35 +
.../continuous/CacheContinuousQueryManager.java | 151 +-
.../cache/transactions/IgniteInternalTx.java | 13 +-
.../cache/transactions/IgniteTxAdapter.java | 68 +-
.../cache/transactions/IgniteTxEntry.java | 29 +-
.../cache/transactions/IgniteTxHandler.java | 38 +-
.../IgniteTxImplicitSingleStateImpl.java | 266 +++
.../transactions/IgniteTxLocalAdapter.java | 1441 ++++++-----
.../cache/transactions/IgniteTxLocalEx.java | 30 +-
.../cache/transactions/IgniteTxLocalState.java | 44 +
.../transactions/IgniteTxLocalStateAdapter.java | 41 +
.../cache/transactions/IgniteTxManager.java | 21 +-
.../cache/transactions/IgniteTxMap.java | 3 +-
.../cache/transactions/IgniteTxRemoteEx.java | 18 +-
.../IgniteTxRemoteSingleStateImpl.java | 108 +
.../cache/transactions/IgniteTxRemoteState.java | 34 +
.../IgniteTxRemoteStateAdapter.java | 115 +
.../transactions/IgniteTxRemoteStateImpl.java | 124 +
.../cache/transactions/IgniteTxState.java | 177 ++
.../cache/transactions/IgniteTxStateImpl.java | 414 ++++
.../clock/GridClockSyncProcessor.java | 28 +-
.../continuous/GridContinuousBatch.java | 44 +
.../continuous/GridContinuousBatchAdapter.java | 46 +
.../continuous/GridContinuousHandler.java | 22 +
.../continuous/GridContinuousProcessor.java | 221 +-
.../StartRoutineAckDiscoveryMessage.java | 14 +-
.../StartRoutineDiscoveryMessage.java | 21 +-
.../internal/util/UUIDCollectionMessage.java | 114 +
.../util/future/GridCompoundFuture.java | 15 +-
.../ignite/internal/util/lang/GridFunc.java | 8 +-
.../ignite/internal/util/nio/GridNioServer.java | 13 +-
.../ignite/marshaller/MarshallerExclusions.java | 4 +-
.../org/apache/ignite/mxbean/IgniteMXBean.java | 8 +-
.../org/apache/ignite/stream/StreamAdapter.java | 18 +-
.../IgniteClientReconnectCacheTest.java | 11 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 75 +
.../GridCacheConcurrentTxMultiNodeTest.java | 15 -
.../cache/GridCachePartitionedGetSelfTest.java | 3 +-
.../processors/cache/GridCacheTestEntryEx.java | 10 +-
.../IgniteCacheAbstractStopBusySelfTest.java | 27 +-
.../IgniteCacheP2pUnmarshallingErrorTest.java | 184 +-
.../CacheGetFutureHangsSelfTest.java | 6 +
.../GridCacheAbstractNodeRestartSelfTest.java | 2 +
.../IgniteCacheSingleGetMessageTest.java | 357 +++
.../GridCacheReplicatedMetricsSelfTest.java | 9 -
.../IgniteCacheTxStoreSessionTest.java | 2 +-
...ContinuousQueryFailoverAbstractSelfTest.java | 2235 ++++++++++++++++++
...ryFailoverAtomicNearEnabledSelfSelfTest.java | 46 +
...FailoverAtomicPrimaryWriteOrderSelfTest.java | 44 +
...usQueryFailoverAtomicReplicatedSelfTest.java | 40 +
...inuousQueryFailoverTxReplicatedSelfTest.java | 32 +
.../CacheContinuousQueryFailoverTxSelfTest.java | 39 +
...ridCacheContinuousQueryAbstractSelfTest.java | 153 +-
.../GridCacheContinuousQueryTxSelfTest.java | 49 +
...CacheContinuousQueryClientReconnectTest.java | 187 ++
.../IgniteCacheContinuousQueryClientTest.java | 157 +-
...cheContinuousQueryClientTxReconnectTest.java | 32 +
.../p2p/GridP2PSameClassLoaderSelfTest.java | 16 +-
.../testframework/junits/GridAbstractTest.java | 2 +-
.../junits/common/GridCommonAbstractTest.java | 3 +
.../testsuites/IgniteCacheTestSuite3.java | 2 +
.../testsuites/IgniteCacheTestSuite4.java | 3 +
.../ignite/util/mbeans/GridMBeanSelfTest.java | 33 +-
modules/flume/README.txt | 72 +
modules/flume/licenses/apache-2.0.txt | 202 ++
modules/flume/pom.xml | 77 +
.../ignite/stream/flume/EventTransformer.java | 36 +
.../apache/ignite/stream/flume/IgniteSink.java | 186 ++
.../stream/flume/IgniteSinkConstants.java | 35 +
.../ignite/stream/flume/IgniteSinkTest.java | 142 ++
.../stream/flume/IgniteSinkTestSuite.java | 37 +
.../stream/flume/TestEventTransformer.java | 66 +
.../flume/src/test/resources/example-ignite.xml | 71 +
.../IgniteCacheQuerySelfTestSuite.java | 16 +-
.../GridSpringResourceInjectionSelfTest.java | 143 ++
.../processors/resource/spring-resource.xml | 27 +
.../testsuites/IgniteResourceSelfTestSuite.java | 2 +
modules/twitter/README.txt | 32 +
modules/twitter/licenses/apache-2.0.txt | 202 ++
modules/twitter/pom.xml | 122 +
.../ignite/stream/twitter/OAuthSettings.java | 86 +
.../ignite/stream/twitter/TwitterStreamer.java | 295 +++
.../twitter/IgniteTwitterStreamerTest.java | 234 ++
.../twitter/IgniteTwitterStreamerTestSuite.java | 32 +
.../stream/twitter/TwitterStreamerImpl.java | 79 +
.../config/benchmark-multicast.properties | 6 +-
.../benchmark-query-put-separated.properties | 87 +
.../yardstick/cache/CacheEntryEventProbe.java | 156 ++
.../cache/IgniteSqlQueryPutBenchmark.java | 31 +-
.../IgniteSqlQueryPutSeparatedBenchmark.java | 84 +
parent/pom.xml | 1 +
pom.xml | 3 +
190 files changed, 15622 insertions(+), 2791 deletions(-)
----------------------------------------------------------------------
[24/55] [abbrv] ignite git commit: IGNITE-1917: Binary protocol
performance optimizations.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
index e5fd71b..2f6ad5c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
@@ -163,4 +163,34 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
shift(cnt);
}
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteShort(short val) {
+ super.unsafeWriteShort(Short.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteShort(int pos, short val) {
+ super.unsafeWriteShort(pos, Short.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteChar(char val) {
+ super.unsafeWriteChar(Character.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteInt(int val) {
+ super.unsafeWriteInt(Integer.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteInt(int pos, int val) {
+ super.unsafeWriteInt(pos, Integer.reverseBytes(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteLong(long val) {
+ super.unsafeWriteLong(Long.reverseBytes(val));
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
index 16b1567..670dd28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
@@ -223,6 +223,69 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
}
/** {@inheritDoc} */
+ @Override public void unsafeEnsure(int cap) {
+ ensureCapacity(pos + cap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteByte(byte val) {
+ UNSAFE.putByte(data + pos++, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteBoolean(boolean val) {
+ unsafeWriteByte(val ? (byte) 1 : (byte) 0);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteShort(short val) {
+ UNSAFE.putShort(data + pos, val);
+
+ shift(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteShort(int pos, short val) {
+ UNSAFE.putShort(data + pos, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteChar(char val) {
+ UNSAFE.putChar(data + pos, val);
+
+ shift(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteInt(int val) {
+ UNSAFE.putInt(data + pos, val);
+
+ shift(4);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteInt(int pos, int val) {
+ UNSAFE.putInt(data + pos, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteLong(long val) {
+ UNSAFE.putLong(data + pos, val);
+
+ shift(8);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteFloat(float val) {
+ unsafeWriteInt(Float.floatToIntBits(val));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unsafeWriteDouble(double val) {
+ unsafeWriteLong(Double.doubleToLongBits(val));
+ }
+
+ /** {@inheritDoc} */
@Override public void synchronize() {
PlatformMemoryUtils.length(mem.pointer(), pos);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java
deleted file mode 100644
index f84c1e5..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridEnumCache.java
+++ /dev/null
@@ -1,56 +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.util;
-
-import java.util.concurrent.ConcurrentMap;
-import org.jsr166.ConcurrentHashMap8;
-
-/**
- * Cache for enum constants.
- */
-public class GridEnumCache {
- /** Cache for enum constants. */
- private static final ConcurrentMap<Class<?>, Object[]> ENUM_CACHE = new ConcurrentHashMap8<>();
-
- /**
- * Gets enum constants for provided class.
- *
- * @param cls Class.
- * @return Enum constants.
- */
- public static Object[] get(Class<?> cls) {
- assert cls != null;
-
- Object[] vals = ENUM_CACHE.get(cls);
-
- if (vals == null) {
- vals = cls.getEnumConstants();
-
- ENUM_CACHE.putIfAbsent(cls, vals);
- }
-
- return vals;
- }
-
- /**
- * Clears cache.
- */
- public static void clear() {
- ENUM_CACHE.clear();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
index 9809a7e..17ec7d6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryMarshallerSelfTest.java
@@ -68,7 +68,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
-import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
+import static org.apache.ignite.internal.portable.streams.PortableMemoryAllocator.INSTANCE;
import static org.junit.Assert.assertArrayEquals;
/**
@@ -93,7 +93,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testByte() throws Exception {
- assertEquals((byte)100, marshalUnmarshal((byte)100).byteValue());
+ assertEquals((byte) 100, marshalUnmarshal((byte) 100).byteValue());
}
/**
@@ -1492,11 +1492,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1, 2, 3}));
- assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
+ assertArrayEquals(new byte[]{1, 2, 3}, copy.<byte[]>field("bArr"));
SimpleObject obj0 = copy.deserialize();
- assertArrayEquals(new byte[] {1, 2, 3}, obj0.bArr);
+ assertArrayEquals(new byte[]{1, 2, 3}, obj0.bArr);
}
/**
@@ -1741,7 +1741,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
assertEquals("str555", obj0.str);
assertEquals(newObj, obj0.inner);
- assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
+ assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
}
/**
@@ -1769,7 +1769,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
map.put("inner", newObj);
map.put("s", (short)2323);
map.put("bArr", new byte[]{6, 7, 9});
- map.put("b", (byte)111);
+ map.put("b", (byte) 111);
BinaryObject copy = copy(po, map);
@@ -1786,8 +1786,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
assertEquals("str555", obj0.str);
assertEquals(newObj, obj0.inner);
assertEquals((short)2323, obj0.s);
- assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
- assertEquals((byte)111, obj0.b);
+ assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
+ assertEquals((byte) 111, obj0.b);
}
/**
@@ -2069,28 +2069,28 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*/
public void testThreadLocalArrayReleased() throws Exception {
// Checking the writer directly.
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ assertEquals(false, INSTANCE.isAcquired());
PortableMarshaller marsh0 = createMarshaller();
-
+
try (BinaryWriterExImpl writer = new BinaryWriterExImpl(portableContext(marsh0))) {
- assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ assertEquals(true, INSTANCE.isAcquired());
writer.writeString("Thread local test");
writer.array();
- assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ assertEquals(true, INSTANCE.isAcquired());
}
// Checking the portable marshaller.
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ assertEquals(false, INSTANCE.isAcquired());
PortableMarshaller marsh = createMarshaller();
marsh.marshal(new SimpleObject());
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ assertEquals(false, INSTANCE.isAcquired());
// Checking the builder.
PortableMarshaller marsh2 = createMarshaller();
@@ -2102,7 +2102,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryObject portableObj = builder.build();
- assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired());
+ assertEquals(false, INSTANCE.isAcquired());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 3e41979..bee9990 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -61,7 +61,7 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
import org.apache.ignite.internal.util.GridClassLoaderCache;
-import org.apache.ignite.internal.util.GridEnumCache;
+import org.apache.ignite.internal.portable.BinaryEnumCache;
import org.apache.ignite.internal.util.GridTestClockTimer;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.F;
@@ -1365,7 +1365,7 @@ public abstract class GridAbstractTest extends TestCase {
GridClassLoaderCache.clear();
U.clearClassCache();
MarshallerExclusions.clearCache();
- GridEnumCache.clear();
+ BinaryEnumCache.clear();
}
Thread.currentThread().setContextClassLoader(clsLdr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 411ef05..08a98f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -565,7 +565,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// Check scan query with partitions.
/// </summary>
[Test]
- [Ignore("IGNITE-1012")]
public void TestScanQueryPartitions([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<QueryPerson>(MaxItemCnt, loc, false);
@@ -575,7 +574,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// Check scan query with partitions in binary mode.
/// </summary>
[Test]
- [Ignore("IGNITE-1012")]
public void TestScanQueryPartitionsBinary([Values(true, false)] bool loc)
{
CheckScanQueryPartitions<BinaryObject>(MaxItemCnt, loc, true);
[10/55] [abbrv] ignite git commit: IGNITE-1847: Added "field" method
to BinaryType and reworked internal metadata handling.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
index 98b619e..117eece 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectBinaryProcessorImpl.java
@@ -17,41 +17,26 @@
package org.apache.ignite.internal.processors.cache.portable;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-import javax.cache.Cache;
-import javax.cache.CacheException;
-import javax.cache.event.CacheEntryEvent;
-import javax.cache.event.CacheEntryListenerException;
-import javax.cache.event.CacheEntryUpdatedListener;
-import javax.cache.event.EventType;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.cluster.ClusterTopologyException;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
-import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.cluster.ClusterTopologyException;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.portable.GridPortableMarshaller;
-import org.apache.ignite.internal.portable.PortableContext;
-import org.apache.ignite.internal.portable.PortableMetaDataHandler;
-import org.apache.ignite.internal.portable.BinaryMetaDataImpl;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.portable.BinaryMetadata;
import org.apache.ignite.internal.portable.BinaryObjectImpl;
import org.apache.ignite.internal.portable.BinaryObjectOffheapImpl;
+import org.apache.ignite.internal.portable.BinaryTypeImpl;
+import org.apache.ignite.internal.portable.GridPortableMarshaller;
+import org.apache.ignite.internal.portable.PortableContext;
+import org.apache.ignite.internal.portable.BinaryMetadataHandler;
import org.apache.ignite.internal.portable.PortableUtils;
import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.portable.streams.PortableInputStream;
@@ -82,51 +67,33 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import sun.misc.Unsafe;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.BYTE_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CHAR_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLASS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.COL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DATE_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DECIMAL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DECIMAL_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DOUBLE;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.DOUBLE_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.ENUM;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.ENUM_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLOAT;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLOAT_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.INT_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENTRY;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.PORTABLE_OBJ;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.event.EventType;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
/**
* Portable processor implementation.
@@ -134,9 +101,6 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_AR
public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorImpl implements
CacheObjectBinaryProcessor {
/** */
- public static final String[] FIELD_TYPE_NAMES;
-
- /** */
private static final Unsafe UNSAFE = GridUnsafe.unsafe();
/** */
@@ -146,17 +110,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private final boolean clientNode;
/** */
- private volatile IgniteCacheProxy<PortableMetaDataKey, BinaryType> metaDataCache;
+ private volatile IgniteCacheProxy<PortableMetadataKey, BinaryMetadata> metaDataCache;
/** */
- private final ConcurrentHashMap8<PortableMetaDataKey, BinaryType> clientMetaDataCache;
+ private final ConcurrentHashMap8<Integer, BinaryTypeImpl> clientMetaDataCache;
/** Predicate to filter portable meta data in utility cache. */
private final CacheEntryPredicate metaPred = new CacheEntryPredicateAdapter() {
private static final long serialVersionUID = 0L;
@Override public boolean apply(GridCacheEntryEx e) {
- return e.key().value(e.context().cacheObjectContext(), false) instanceof PortableMetaDataKey;
+ return e.key().value(e.context().cacheObjectContext(), false) instanceof PortableMetadataKey;
}
};
@@ -174,98 +138,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private IgniteBinary portables;
/** Metadata updates collected before metadata cache is initialized. */
- private final Map<Integer, BinaryType> metaBuf = new ConcurrentHashMap<>();
+ private final Map<Integer, BinaryMetadata> metaBuf = new ConcurrentHashMap<>();
/** */
private UUID metaCacheQryId;
/**
- *
- */
- static {
- FIELD_TYPE_NAMES = new String[104];
-
- FIELD_TYPE_NAMES[BYTE] = "byte";
- FIELD_TYPE_NAMES[SHORT] = "short";
- FIELD_TYPE_NAMES[INT] = "int";
- FIELD_TYPE_NAMES[LONG] = "long";
- FIELD_TYPE_NAMES[BOOLEAN] = "boolean";
- FIELD_TYPE_NAMES[FLOAT] = "float";
- FIELD_TYPE_NAMES[DOUBLE] = "double";
- FIELD_TYPE_NAMES[CHAR] = "char";
- FIELD_TYPE_NAMES[UUID] = "UUID";
- FIELD_TYPE_NAMES[DECIMAL] = "decimal";
- FIELD_TYPE_NAMES[STRING] = "String";
- FIELD_TYPE_NAMES[DATE] = "Date";
- FIELD_TYPE_NAMES[TIMESTAMP] = "Timestamp";
- FIELD_TYPE_NAMES[ENUM] = "Enum";
- FIELD_TYPE_NAMES[OBJ] = "Object";
- FIELD_TYPE_NAMES[PORTABLE_OBJ] = "Object";
- FIELD_TYPE_NAMES[COL] = "Collection";
- FIELD_TYPE_NAMES[MAP] = "Map";
- FIELD_TYPE_NAMES[MAP_ENTRY] = "Entry";
- FIELD_TYPE_NAMES[CLASS] = "Class";
- FIELD_TYPE_NAMES[BYTE_ARR] = "byte[]";
- FIELD_TYPE_NAMES[SHORT_ARR] = "short[]";
- FIELD_TYPE_NAMES[INT_ARR] = "int[]";
- FIELD_TYPE_NAMES[LONG_ARR] = "long[]";
- FIELD_TYPE_NAMES[BOOLEAN_ARR] = "boolean[]";
- FIELD_TYPE_NAMES[FLOAT_ARR] = "float[]";
- FIELD_TYPE_NAMES[DOUBLE_ARR] = "double[]";
- FIELD_TYPE_NAMES[CHAR_ARR] = "char[]";
- FIELD_TYPE_NAMES[UUID_ARR] = "UUID[]";
- FIELD_TYPE_NAMES[DECIMAL_ARR] = "decimal[]";
- FIELD_TYPE_NAMES[STRING_ARR] = "String[]";
- FIELD_TYPE_NAMES[DATE_ARR] = "Date[]";
- FIELD_TYPE_NAMES[TIMESTAMP_ARR] = "Timestamp[]";
- FIELD_TYPE_NAMES[OBJ_ARR] = "Object[]";
- FIELD_TYPE_NAMES[ENUM_ARR] = "Enum[]";
- }
-
- /**
- * @param typeName Field type name.
- * @return Field type ID;
- */
- @SuppressWarnings("StringEquality")
- public static int fieldTypeId(String typeName) {
- for (int i = 0; i < FIELD_TYPE_NAMES.length; i++) {
- String typeName0 = FIELD_TYPE_NAMES[i];
-
- if (typeName.equals(typeName0))
- return i;
- }
-
- throw new IllegalArgumentException("Invalid metadata type name: " + typeName);
- }
-
- /**
- * @param typeId Field type ID.
- * @return Field type name.
- */
- public static String fieldTypeName(int typeId) {
- assert typeId >= 0 && typeId < FIELD_TYPE_NAMES.length : typeId;
-
- String typeName = FIELD_TYPE_NAMES[typeId];
-
- assert typeName != null : typeId;
-
- return typeName;
- }
-
- /**
- * @param typeIds Field type IDs.
- * @return Field type names.
- */
- public static Map<String, String> fieldTypeNames(Map<String, Integer> typeIds) {
- Map<String, String> names = U.newHashMap(typeIds.size());
-
- for (Map.Entry<String, Integer> e : typeIds.entrySet())
- names.put(e.getKey(), fieldTypeName(e.getValue()));
-
- return names;
- }
-
- /**
* @param ctx Kernal context.
*/
public CacheObjectBinaryProcessorImpl(GridKernalContext ctx) {
@@ -275,28 +153,31 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
clientNode = this.ctx.clientNode();
- clientMetaDataCache = clientNode ? new ConcurrentHashMap8<PortableMetaDataKey, BinaryType>() : null;
+ clientMetaDataCache = clientNode ? new ConcurrentHashMap8<Integer, BinaryTypeImpl>() : null;
}
/** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
if (marsh instanceof PortableMarshaller) {
- PortableMetaDataHandler metaHnd = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType newMeta)
- throws BinaryObjectException {
+ BinaryMetadataHandler metaHnd = new BinaryMetadataHandler() {
+ @Override public void addMeta(int typeId, BinaryType newMeta) throws BinaryObjectException {
+ assert newMeta != null;
+ assert newMeta instanceof BinaryTypeImpl;
+
+ BinaryMetadata newMeta0 = ((BinaryTypeImpl)newMeta).metadata();
+
if (metaDataCache == null) {
- BinaryType oldMeta = metaBuf.get(typeId);
+ BinaryMetadata oldMeta = metaBuf.get(typeId);
- if (oldMeta == null || checkMeta(typeId, oldMeta, newMeta, null)) {
+ if (oldMeta == null || checkMeta(typeId, oldMeta, newMeta0, null)) {
synchronized (this) {
- Map<String, String> fields = new HashMap<>();
+ Map<String, Integer> fields = new HashMap<>();
- if (checkMeta(typeId, oldMeta, newMeta, fields)) {
- newMeta = new BinaryMetaDataImpl(newMeta.typeName(),
- fields,
- newMeta.affinityKeyFieldName());
+ if (checkMeta(typeId, oldMeta, newMeta0, fields)) {
+ newMeta0 = new BinaryMetadata(typeId, newMeta0.typeName(), fields,
+ newMeta0.affinityKeyFieldName());
- metaBuf.put(typeId, newMeta);
+ metaBuf.put(typeId, newMeta0);
}
else
return;
@@ -311,7 +192,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
return;
}
- CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta);
+ CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta0.wrap(portableCtx));
}
@Override public BinaryType metadata(int typeId) throws BinaryObjectException {
@@ -357,7 +238,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
GridCacheQueryManager qryMgr = metaDataCache.context().queries();
- CacheQuery<Map.Entry<PortableMetaDataKey, BinaryType>> qry =
+ CacheQuery<Map.Entry<PortableMetadataKey, BinaryMetadata>> qry =
qryMgr.createScanQuery(new MetaDataPredicate(), null, false);
qry.keepAll(false);
@@ -365,9 +246,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
qry.projection(ctx.cluster().get().forNode(oldestSrvNode));
try {
- CacheQueryFuture<Map.Entry<PortableMetaDataKey, BinaryType>> fut = qry.execute();
+ CacheQueryFuture<Map.Entry<PortableMetadataKey, BinaryMetadata>> fut = qry.execute();
- Map.Entry<PortableMetaDataKey, BinaryType> next;
+ Map.Entry<PortableMetadataKey, BinaryMetadata> next;
while ((next = fut.next()) != null) {
assert next.getKey() != null : next;
@@ -395,8 +276,8 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
startLatch.countDown();
- for (Map.Entry<Integer, BinaryType> e : metaBuf.entrySet())
- addMeta(e.getKey(), e.getValue());
+ for (Map.Entry<Integer, BinaryMetadata> e : metaBuf.entrySet())
+ addMeta(e.getKey(), e.getValue().wrap(portableCtx));
metaBuf.clear();
}
@@ -413,20 +294,24 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
* @param key Metadata key.
* @param newMeta Metadata.
*/
- private void addClientCacheMetaData(PortableMetaDataKey key, final BinaryType newMeta) {
- clientMetaDataCache.compute(key,
- new ConcurrentHashMap8.BiFun<PortableMetaDataKey, BinaryType, BinaryType>() {
- @Override public BinaryType apply(PortableMetaDataKey key, BinaryType oldMeta) {
- BinaryType res;
+ private void addClientCacheMetaData(PortableMetadataKey key, final BinaryMetadata newMeta) {
+ int key0 = key.typeId();
+
+ clientMetaDataCache.compute(key0,
+ new ConcurrentHashMap8.BiFun<Integer, BinaryTypeImpl, BinaryTypeImpl>() {
+ @Override public BinaryTypeImpl apply(Integer key, BinaryTypeImpl oldMeta) {
+ BinaryMetadata res;
+
+ BinaryMetadata oldMeta0 = oldMeta != null ? oldMeta.metadata() : null;
try {
- res = checkMeta(key.typeId(), oldMeta, newMeta, null) ? newMeta : oldMeta;
+ res = checkMeta(key, oldMeta0, newMeta, null) ? newMeta : oldMeta0;
}
catch (BinaryObjectException e) {
- res = oldMeta;
+ res = oldMeta0;
}
- return res;
+ return res != null ? res.wrap(portableCtx) : null;
}
}
);
@@ -480,6 +365,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Override public Object marshalToPortable(@Nullable Object obj) throws BinaryObjectException {
if (obj == null)
return null;
@@ -564,21 +450,23 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public void updateMetaData(int typeId, String typeName, @Nullable String affKeyFieldName,
Map<String, Integer> fieldTypeIds) throws BinaryObjectException {
- portableCtx.updateMetaData(typeId,
- new BinaryMetaDataImpl(typeName, fieldTypeNames(fieldTypeIds), affKeyFieldName));
+ portableCtx.updateMetaData(typeId, new BinaryMetadata(typeId, typeName, fieldTypeIds, affKeyFieldName));
}
/** {@inheritDoc} */
@Override public void addMeta(final int typeId, final BinaryType newMeta) throws BinaryObjectException {
assert newMeta != null;
+ assert newMeta instanceof BinaryTypeImpl;
+
+ BinaryMetadata newMeta0 = ((BinaryTypeImpl)newMeta).metadata();
- final PortableMetaDataKey key = new PortableMetaDataKey(typeId);
+ final PortableMetadataKey key = new PortableMetadataKey(typeId);
try {
- BinaryType oldMeta = metaDataCache.localPeek(key);
+ BinaryMetadata oldMeta = metaDataCache.localPeek(key);
- if (oldMeta == null || checkMeta(typeId, oldMeta, newMeta, null)) {
- BinaryObjectException err = metaDataCache.invoke(key, new MetaDataProcessor(typeId, newMeta));
+ if (oldMeta == null || checkMeta(typeId, oldMeta, newMeta0, null)) {
+ BinaryObjectException err = metaDataCache.invoke(key, new MetaDataProcessor(typeId, newMeta0));
if (err != null)
throw err;
@@ -593,9 +481,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@Nullable @Override public BinaryType metadata(final int typeId) throws BinaryObjectException {
try {
if (clientNode)
- return clientMetaDataCache.get(new PortableMetaDataKey(typeId));
+ return clientMetaDataCache.get(typeId);
+ else {
+ BinaryMetadata meta = metaDataCache.localPeek(new PortableMetadataKey(typeId));
- return metaDataCache.localPeek(new PortableMetaDataKey(typeId));
+ return meta != null ? meta.wrap(portableCtx) : null;
+ }
}
catch (CacheException e) {
throw new BinaryObjectException(e);
@@ -606,17 +497,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@Override public Map<Integer, BinaryType> metadata(Collection<Integer> typeIds)
throws BinaryObjectException {
try {
- Collection<PortableMetaDataKey> keys = new ArrayList<>(typeIds.size());
+ Collection<PortableMetadataKey> keys = new ArrayList<>(typeIds.size());
for (Integer typeId : typeIds)
- keys.add(new PortableMetaDataKey(typeId));
+ keys.add(new PortableMetadataKey(typeId));
- Map<PortableMetaDataKey, BinaryType> meta = metaDataCache.getAll(keys);
+ Map<PortableMetadataKey, BinaryMetadata> meta = metaDataCache.getAll(keys);
Map<Integer, BinaryType> res = U.newHashMap(meta.size());
- for (Map.Entry<PortableMetaDataKey, BinaryType> e : meta.entrySet())
- res.put(e.getKey().typeId(), e.getValue());
+ for (Map.Entry<PortableMetadataKey, BinaryMetadata> e : meta.entrySet())
+ res.put(e.getKey().typeId(), e.getValue().wrap(portableCtx));
return res;
}
@@ -629,17 +520,21 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
@SuppressWarnings("unchecked")
@Override public Collection<BinaryType> metadata() throws BinaryObjectException {
if (clientNode)
- return new ArrayList<>(clientMetaDataCache.values());
-
- return F.viewReadOnly(metaDataCache.entrySetx(metaPred),
- new C1<Cache.Entry<PortableMetaDataKey, BinaryType>, BinaryType>() {
- private static final long serialVersionUID = 0L;
-
- @Override public BinaryType apply(
- Cache.Entry<PortableMetaDataKey, BinaryType> e) {
- return e.getValue();
+ return F.viewReadOnly(clientMetaDataCache.values(), new IgniteClosure<BinaryTypeImpl, BinaryType>() {
+ @Override public BinaryType apply(BinaryTypeImpl meta) {
+ return meta;
}
});
+ else {
+ return F.viewReadOnly(metaDataCache.entrySetx(metaPred),
+ new C1<Cache.Entry<PortableMetadataKey, BinaryMetadata>, BinaryType>() {
+ private static final long serialVersionUID = 0L;
+
+ @Override public BinaryType apply(Cache.Entry<PortableMetadataKey, BinaryMetadata> e) {
+ return e.getValue().wrap(portableCtx);
+ }
+ });
+ }
}
/** {@inheritDoc} */
@@ -839,12 +734,12 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
* @return Whether meta is changed.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
- private static boolean checkMeta(int typeId, @Nullable BinaryType oldMeta,
- BinaryType newMeta, @Nullable Map<String, String> fields) throws BinaryObjectException {
+ private static boolean checkMeta(int typeId, @Nullable BinaryMetadata oldMeta,
+ BinaryMetadata newMeta, @Nullable Map<String, Integer> fields) throws BinaryObjectException {
assert newMeta != null;
- Map<String, String> oldFields = oldMeta != null ? ((BinaryMetaDataImpl)oldMeta).fieldsMeta() : null;
- Map<String, String> newFields = ((BinaryMetaDataImpl)newMeta).fieldsMeta();
+ Map<String, Integer> oldFields = oldMeta != null ? oldMeta.fieldsMap() : null;
+ Map<String, Integer> newFields = newMeta.fieldsMap();
boolean changed = false;
@@ -875,17 +770,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
else
changed = true;
- for (Map.Entry<String, String> e : newFields.entrySet()) {
- String typeName = oldFields != null ? oldFields.get(e.getKey()) : null;
+ for (Map.Entry<String, Integer> e : newFields.entrySet()) {
+ Integer oldTypeId = oldFields != null ? oldFields.get(e.getKey()) : null;
- if (typeName != null) {
- if (!typeName.equals(e.getValue())) {
+ if (oldTypeId != null) {
+ if (!oldTypeId.equals(e.getValue())) {
throw new BinaryObjectException(
"Portable field has different types on different clients [" +
"typeName=" + newMeta.typeName() +
", fieldName=" + e.getKey() +
- ", fieldTypeName1=" + typeName +
- ", fieldTypeName2=" + e.getValue() +
+ ", fieldTypeName1=" + PortableUtils.fieldTypeName(oldTypeId) +
+ ", fieldTypeName2=" + PortableUtils.fieldTypeName(e.getValue()) +
']'
);
}
@@ -904,7 +799,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
*/
private static class MetaDataProcessor implements
- EntryProcessor<PortableMetaDataKey, BinaryType, BinaryObjectException>, Externalizable {
+ EntryProcessor<PortableMetadataKey, BinaryMetadata, BinaryObjectException>, Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -912,7 +807,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private int typeId;
/** */
- private BinaryType newMeta;
+ private BinaryMetadata newMeta;
/**
* For {@link Externalizable}.
@@ -925,7 +820,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
* @param typeId Type ID.
* @param newMeta New metadata.
*/
- private MetaDataProcessor(int typeId, BinaryType newMeta) {
+ private MetaDataProcessor(int typeId, BinaryMetadata newMeta) {
assert newMeta != null;
this.typeId = typeId;
@@ -934,16 +829,15 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public BinaryObjectException process(
- MutableEntry<PortableMetaDataKey, BinaryType> entry,
+ MutableEntry<PortableMetadataKey, BinaryMetadata> entry,
Object... args) {
try {
- BinaryType oldMeta = entry.getValue();
+ BinaryMetadata oldMeta = entry.getValue();
- Map<String, String> fields = new HashMap<>();
+ Map<String, Integer> fields = new HashMap<>();
if (checkMeta(typeId, oldMeta, newMeta, fields)) {
- BinaryType res = new BinaryMetaDataImpl(newMeta.typeName(),
- fields,
+ BinaryMetadata res = new BinaryMetadata(typeId, newMeta.typeName(), fields,
newMeta.affinityKeyFieldName());
entry.setValue(res);
@@ -967,7 +861,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
typeId = in.readInt();
- newMeta = (BinaryType)in.readObject();
+ newMeta = (BinaryMetadata)in.readObject();
}
/** {@inheritDoc} */
@@ -979,17 +873,17 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/**
*
*/
- class MetaDataEntryListener implements CacheEntryUpdatedListener<PortableMetaDataKey, BinaryType> {
+ class MetaDataEntryListener implements CacheEntryUpdatedListener<PortableMetadataKey, BinaryMetadata> {
/** {@inheritDoc} */
@Override public void onUpdated(
- Iterable<CacheEntryEvent<? extends PortableMetaDataKey, ? extends BinaryType>> evts)
+ Iterable<CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata>> evts)
throws CacheEntryListenerException {
- for (CacheEntryEvent<? extends PortableMetaDataKey, ? extends BinaryType> evt : evts) {
+ for (CacheEntryEvent<? extends PortableMetadataKey, ? extends BinaryMetadata> evt : evts) {
assert evt.getEventType() == EventType.CREATED || evt.getEventType() == EventType.UPDATED : evt;
- PortableMetaDataKey key = evt.getKey();
+ PortableMetadataKey key = evt.getKey();
- final BinaryType newMeta = evt.getValue();
+ final BinaryMetadata newMeta = evt.getValue();
assert newMeta != null : evt;
@@ -1012,7 +906,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean evaluate(CacheEntryEvent<?, ?> evt) throws CacheEntryListenerException {
- return evt.getKey() instanceof PortableMetaDataKey;
+ return evt.getKey() instanceof PortableMetadataKey;
}
/** {@inheritDoc} */
@@ -1030,7 +924,7 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public boolean apply(Object key, Object val) {
- return key instanceof PortableMetaDataKey;
+ return key instanceof PortableMetadataKey;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java
index 2a98778..f838c82 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/PortableMetaDataKey.java
@@ -27,7 +27,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Key for portable meta data.
*/
-class PortableMetaDataKey extends GridCacheUtilityKey<PortableMetaDataKey> implements Externalizable {
+class PortableMetadataKey extends GridCacheUtilityKey<PortableMetadataKey> implements Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -37,14 +37,14 @@ class PortableMetaDataKey extends GridCacheUtilityKey<PortableMetaDataKey> imple
/**
* For {@link Externalizable}.
*/
- public PortableMetaDataKey() {
+ public PortableMetadataKey() {
// No-op.
}
/**
* @param typeId Type ID.
*/
- PortableMetaDataKey(int typeId) {
+ PortableMetadataKey(int typeId) {
this.typeId = typeId;
}
@@ -66,7 +66,7 @@ class PortableMetaDataKey extends GridCacheUtilityKey<PortableMetaDataKey> imple
}
/** {@inheritDoc} */
- @Override protected boolean equalsx(PortableMetaDataKey key) {
+ @Override protected boolean equalsx(PortableMetadataKey key) {
return typeId == key.typeId;
}
@@ -77,6 +77,6 @@ class PortableMetaDataKey extends GridCacheUtilityKey<PortableMetaDataKey> imple
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(PortableMetaDataKey.class, this);
+ return S.toString(PortableMetadataKey.class, this);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index c513600..05d3515 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -34,7 +34,7 @@ import org.apache.ignite.events.SwapSpaceEvent;
import org.apache.ignite.events.TaskEvent;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.portable.GridPortableMarshaller;
-import org.apache.ignite.internal.portable.BinaryMetaDataImpl;
+import org.apache.ignite.internal.portable.BinaryMetadata;
import org.apache.ignite.internal.portable.BinaryRawReaderEx;
import org.apache.ignite.internal.portable.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
@@ -68,7 +68,6 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformReaderClosur
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T4;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.binary.BinaryType;
import org.jetbrains.annotations.Nullable;
@@ -391,12 +390,7 @@ public class PlatformContextImpl implements PlatformContext {
else {
writer.writeBoolean(true);
- Map<String, String> metaFields = ((BinaryMetaDataImpl)meta).fields0();
-
- Map<String, Integer> fields = U.newHashMap(metaFields.size());
-
- for (Map.Entry<String, String> metaField : metaFields.entrySet())
- fields.put(metaField.getKey(), CacheObjectBinaryProcessorImpl.fieldTypeId(metaField.getValue()));
+ Map<String, Integer> fields = ((BinaryMetadata)meta).fieldsMap();
writer.writeInt(typeId);
writer.writeString(meta.typeName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 60c0693..d0462e9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -22,10 +22,10 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.portable.BinaryNoopMetadataHandler;
+import org.apache.ignite.internal.portable.BinaryRawWriterEx;
import org.apache.ignite.internal.portable.GridPortableMarshaller;
import org.apache.ignite.internal.portable.PortableContext;
-import org.apache.ignite.internal.portable.PortableMetaDataHandler;
-import org.apache.ignite.internal.portable.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
@@ -36,11 +36,9 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
+import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryType;
import java.util.ArrayList;
import java.util.Collections;
@@ -228,16 +226,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
@SuppressWarnings("deprecation")
private static GridPortableMarshaller marshaller() {
try {
- PortableContext ctx = new PortableContext(new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType meta)
- throws BinaryObjectException {
- // No-op.
- }
-
- @Override public BinaryType metadata(int typeId) throws BinaryObjectException {
- return null;
- }
- }, new IgniteConfiguration());
+ PortableContext ctx = new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
PortableMarshaller marsh = new PortableMarshaller();
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index c4deaa0..4d1145d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1875,7 +1875,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
if (field0 == null)
{
- field0 = obj.fieldDescriptor(propName);
+ field0 = obj.type().field(propName);
assert field0 != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
index 4fa80b4..14fc6f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
@@ -17,15 +17,14 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.binary.BinaryField;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryField;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import java.math.BigDecimal;
@@ -38,17 +37,6 @@ import java.util.UUID;
* Contains tests for portable object fields.
*/
public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTest {
- /** Dummy metadata handler. */
- protected static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType meta) {
- // No-op.
- }
-
- @Override public BinaryType metadata(int typeId) {
- return null;
- }
- };
-
/** Marshaller. */
protected PortableMarshaller dfltMarsh;
@@ -59,7 +47,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
* @throws Exception If failed.
*/
protected static PortableMarshaller createMarshaller() throws Exception {
- PortableContext ctx = new PortableContext(META_HND, new IgniteConfiguration());
+ PortableContext ctx = new PortableContext(new TestCachingMetadataHandler(), new IgniteConfiguration());
PortableMarshaller marsh = new PortableMarshaller();
@@ -485,7 +473,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
BinaryObjectEx portObj = toPortable(marsh, obj);
- BinaryField field = portObj.fieldDescriptor(fieldName);
+ BinaryField field = portObj.type().field(fieldName);
return new TestContext(obj, portObj, field);
}
@@ -508,7 +496,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
assert portObj != null;
- BinaryField field = portObj.fieldDescriptor(fieldName);
+ BinaryField field = portObj.type().field(fieldName);
return new TestContext(obj, portObj, field);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
index e62d12e..11b54ae 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
@@ -998,7 +998,7 @@ public class GridBinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstrac
BinaryType metadata = portables().metadata(c.getClass());
- assertTrue(metadata.fields().containsAll(Arrays.asList("intField", "intArrField", "arrField", "strField",
+ assertTrue(metadata.fieldNames().containsAll(Arrays.asList("intField", "intArrField", "arrField", "strField",
"colField", "mapField", "enumField", "enumArrField")));
assertEquals("int", metadata.fieldTypeName("intField"));
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
index ccebd73..a74315b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
@@ -789,7 +789,7 @@ public class GridBinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
assertEquals("MetaTest", meta.typeName());
- Collection<String> fields = meta.fields();
+ Collection<String> fields = meta.fieldNames();
assertEquals(2, fields.size());
@@ -812,7 +812,7 @@ public class GridBinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
assertEquals("MetaTest", meta.typeName());
- fields = meta.fields();
+ fields = meta.fieldNames();
assertEquals(3, fields.size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
index ee91167..747f8ea 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
@@ -17,38 +17,27 @@
package org.apache.ignite.internal.portable;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Arrays;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.MarshallerContextAdapter;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Arrays;
+
/**
*
*/
public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstractTest {
- /** */
- protected static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType meta) {
- // No-op.
- }
-
- @Override public BinaryType metadata(int typeId) {
- return null;
- }
- };
-
/**
* @throws Exception If failed.
*/
@@ -56,7 +45,7 @@ public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstrac
PortableMarshaller marsh = new PortableMarshaller();
marsh.setContext(new MarshallerContextWithNoStorage());
- PortableContext context = new PortableContext(META_HND, new IgniteConfiguration());
+ PortableContext context = new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", context);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index b5a24b1..d0a5709 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -82,17 +82,6 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
/** */
protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
- /** */
- protected static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType meta) {
- // No-op.
- }
-
- @Override public BinaryType metadata(int typeId) {
- return null;
- }
- };
-
/**
* @throws Exception If failed.
*/
@@ -2414,7 +2403,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
protected PortableContext initPortableContext(PortableMarshaller marsh) throws IgniteCheckedException {
IgniteConfiguration iCfg = new IgniteConfiguration();
- PortableContext ctx = new PortableContext(META_HND, iCfg);
+ PortableContext ctx = new PortableContext(BinaryNoopMetadataHandler.instance(), iCfg);
marsh.setContext(new MarshallerContextTestImpl(null));
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
index c0e2563..2a367a8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMetaDataSelfTest.java
@@ -93,7 +93,7 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
switch (meta.typeName()) {
case "TestObject1":
- fields = meta.fields();
+ fields = meta.fieldNames();
assertEquals(7, fields.size());
@@ -116,7 +116,7 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
break;
case "TestObject2":
- fields = meta.fields();
+ fields = meta.fieldNames();
assertEquals(7, fields.size());
@@ -165,7 +165,7 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
assertEquals("TestObject1", meta.typeName());
- Collection<String> fields = meta.fields();
+ Collection<String> fields = meta.fieldNames();
assertEquals(7, fields.size());
@@ -198,7 +198,7 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
assertEquals("TestObject2", meta.typeName());
- Collection<String> fields = meta.fields();
+ Collection<String> fields = meta.fieldNames();
assertEquals(7, fields.size());
@@ -235,7 +235,7 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
assertEquals("TestObject2", meta.typeName());
- Collection<String> fields = meta.fields();
+ Collection<String> fields = meta.fieldNames();
assertEquals(9, fields.size());
@@ -284,7 +284,7 @@ public class GridPortableMetaDataSelfTest extends GridCommonAbstractTest {
assertEquals("TestObject1", meta.typeName());
- Collection<String> fields = meta.fields();
+ Collection<String> fields = meta.fieldNames();
assertEquals(7, fields.size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
index 7522bf9..52af867 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableWildcardsSelfTest.java
@@ -17,37 +17,26 @@
package org.apache.ignite.internal.portable;
-import java.util.Arrays;
-import java.util.Map;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import java.util.Arrays;
+import java.util.Map;
+
/**
* Wildcards test.
*/
public class GridPortableWildcardsSelfTest extends GridCommonAbstractTest {
- /** */
- private static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType meta) {
- // No-op.
- }
-
- @Override public BinaryType metadata(int typeId) {
- return null;
- }
- };
-
/**
* @return Portable context.
*/
private PortableContext portableContext() {
- return new PortableContext(META_HND, new IgniteConfiguration());
+ return new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
index db3c821..9225b97 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
@@ -17,9 +17,7 @@
package org.apache.ignite.internal.portable;
-import java.util.Arrays;
import org.apache.ignite.binary.BinaryField;
-import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.IgniteUtils;
@@ -27,6 +25,8 @@ import org.apache.ignite.marshaller.MarshallerContextTestImpl;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import java.util.Arrays;
+
/**
* Contains tests for compact offsets.
*/
@@ -37,17 +37,6 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
/** 2 pow 16. */
private static int POW_16 = 1 << 16;
- /** Dummy metadata handler. */
- protected static final PortableMetaDataHandler META_HND = new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType meta) {
- // No-op.
- }
-
- @Override public BinaryType metadata(int typeId) {
- return null;
- }
- };
-
/** Marshaller. */
protected PortableMarshaller marsh;
@@ -58,7 +47,7 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
@Override protected void beforeTest() throws Exception {
super.beforeTest();
- ctx = new PortableContext(META_HND, new IgniteConfiguration());
+ ctx = new PortableContext(new TestCachingMetadataHandler(), new IgniteConfiguration());
marsh = new PortableMarshaller();
@@ -139,8 +128,8 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
assert obj.field2 == field2;
// 2. Test fields API.
- BinaryField field1Desc = portObj.fieldDescriptor("field1");
- BinaryField field2Desc = portObj.fieldDescriptor("field2");
+ BinaryField field1Desc = portObj.type().field("field1");
+ BinaryField field2Desc = portObj.type().field("field2");
assert field1Desc.exists(portObj);
assert field2Desc.exists(portObj);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java
new file mode 100644
index 0000000..e49ebf3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Test metadata handler.
+ */
+public class TestCachingMetadataHandler implements BinaryMetadataHandler {
+ /** Cached metadatas. */
+ private final ConcurrentHashMap<Integer, BinaryType> metas = new ConcurrentHashMap<>();
+
+ /** {@inheritDoc} */
+ @Override public void addMeta(int typeId, BinaryType meta) throws BinaryObjectException {
+ BinaryType otherType = metas.put(typeId, meta);
+
+ if (otherType != null)
+ throw new IllegalStateException("Metadata replacement is not allowed in " +
+ TestCachingMetadataHandler.class.getSimpleName() + '.');
+ }
+
+ /** {@inheritDoc} */
+ @Override public BinaryType metadata(int typeId) throws BinaryObjectException {
+ return metas.get(typeId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
index a33eb7b..d19c1ce 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataMultinodeTest.java
@@ -169,7 +169,7 @@ public class GridCacheClientNodeBinaryObjectMetadataMultinodeTest extends GridCo
assertNull(meta.affinityKeyFieldName());
- assertEquals(10, meta.fields().size());
+ assertEquals(10, meta.fieldNames().size());
}
assertEquals(allTypes.size(), names.size());
@@ -255,7 +255,7 @@ public class GridCacheClientNodeBinaryObjectMetadataMultinodeTest extends GridCo
assertNull(meta.affinityKeyFieldName());
- assertEquals(1, meta.fields().size());
+ assertEquals(1, meta.fieldNames().size());
}
assertEquals(1000, names.size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
index b20adb8..10c06a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCacheClientNodeBinaryObjectMetadataTest.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache.portable;
import java.util.Arrays;
import java.util.Collection;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheKeyConfiguration;
import org.apache.ignite.cache.CacheMode;
@@ -29,9 +28,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -127,7 +124,7 @@ public class GridCacheClientNodeBinaryObjectMetadataTest extends GridCacheAbstra
for (BinaryType m2 : meta1) {
if (m1.typeName().equals(m2.typeName())) {
assertEquals(m1.affinityKeyFieldName(), m2.affinityKeyFieldName());
- assertEquals(m1.fields(), m2.fields());
+ assertEquals(m1.fieldNames(), m2.fieldNames());
found = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
index d277801..2e868da 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridPortableCacheEntryMemorySizeSelfTest.java
@@ -19,15 +19,13 @@ package org.apache.ignite.internal.processors.cache.portable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.portable.BinaryNoopMetadataHandler;
import org.apache.ignite.internal.portable.PortableContext;
-import org.apache.ignite.internal.portable.PortableMetaDataHandler;
import org.apache.ignite.internal.processors.cache.GridCacheEntryMemorySizeSelfTest;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryType;
/**
*
@@ -39,15 +37,7 @@ public class GridPortableCacheEntryMemorySizeSelfTest extends GridCacheEntryMemo
marsh.setContext(new MarshallerContextTestImpl(null));
- PortableContext pCtx = new PortableContext(new PortableMetaDataHandler() {
- @Override public void addMeta(int typeId, BinaryType meta) throws BinaryObjectException {
- // No-op
- }
-
- @Override public BinaryType metadata(int typeId) throws BinaryObjectException {
- return null;
- }
- }, new IgniteConfiguration());
+ PortableContext pCtx = new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", pCtx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/63d55062/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
index 77c7e3a..8eba80b 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformComputeBinarizableArgTask.java
@@ -94,7 +94,7 @@ public class PlatformComputeBinarizableArgTask extends ComputeTaskAdapter<Object
if (meta == null)
throw new IgniteException("Metadata doesn't exist.");
- if (meta.fields() == null || !meta.fields().contains("Field"))
+ if (meta.fieldNames() == null || !meta.fieldNames().contains("Field"))
throw new IgniteException("Field metadata doesn't exist.");
if (!F.eq("int", meta.fieldTypeName("Field")))
[16/55] [abbrv] ignite git commit: IGNITE-1816: Implemented compact
footers.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
deleted file mode 100644
index 11b54ae..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderAdditionalSelfTest.java
+++ /dev/null
@@ -1,1280 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.portable.builder.PortableBuilderEnum;
-import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
-import org.apache.ignite.internal.portable.mutabletest.GridBinaryMarshalerAwareTestClass;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.cache.portable.IgniteBinaryImpl;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.junit.Assert;
-
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Address;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.AddressBook;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.Company;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectArrayList;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectContainer;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectEnum;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectInner;
-import static org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectOuter;
-
-/**
- *
- */
-public class GridBinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTest {
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- CacheConfiguration cacheCfg = new CacheConfiguration();
-
- cacheCfg.setCacheMode(REPLICATED);
-
- cfg.setCacheConfiguration(cacheCfg);
-
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setClassNames(Arrays.asList("org.apache.ignite.internal.portable.mutabletest.*"));
-
- cfg.setMarshaller(marsh);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrids(1);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- jcache(0).clear();
- }
-
- /**
- * @return Portables API.
- */
- protected IgniteBinary portables() {
- return grid(0).binary();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSimpleTypeFieldRead() throws Exception {
- TestObjectAllTypes exp = new TestObjectAllTypes();
-
- exp.setDefaultData();
-
- BinaryObjectBuilder mutPo = wrap(exp);
-
- for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
- Object expVal = field.get(exp);
- Object actVal = mutPo.getField(field.getName());
-
- switch (field.getName()) {
- case "anEnum":
- assertEquals(((PortableBuilderEnum)actVal).getOrdinal(), ((Enum)expVal).ordinal());
- break;
-
- case "enumArr": {
- PortableBuilderEnum[] actArr = (PortableBuilderEnum[])actVal;
- Enum[] expArr = (Enum[])expVal;
-
- assertEquals(expArr.length, actArr.length);
-
- for (int i = 0; i < actArr.length; i++)
- assertEquals(expArr[i].ordinal(), actArr[i].getOrdinal());
-
- break;
- }
-
- case "entry":
- assertEquals(((Map.Entry)expVal).getKey(), ((Map.Entry)actVal).getKey());
- assertEquals(((Map.Entry)expVal).getValue(), ((Map.Entry)actVal).getValue());
- break;
-
- default:
- assertTrue(field.getName(), Objects.deepEquals(expVal, actVal));
- break;
- }
- }
- }
-
- /**
- *
- */
- public void testSimpleTypeFieldSerialize() {
- TestObjectAllTypes exp = new TestObjectAllTypes();
-
- exp.setDefaultData();
-
- BinaryObjectBuilderImpl mutPo = wrap(exp);
-
- TestObjectAllTypes res = mutPo.build().deserialize();
-
- GridTestUtils.deepEquals(exp, res);
- }
-
- /**
- * @throws Exception If any error occurs.
- */
- public void testSimpleTypeFieldOverride() throws Exception {
- TestObjectAllTypes exp = new TestObjectAllTypes();
-
- exp.setDefaultData();
-
- BinaryObjectBuilderImpl mutPo = wrap(new TestObjectAllTypes());
-
- for (Field field : TestObjectAllTypes.class.getDeclaredFields())
- mutPo.setField(field.getName(), field.get(exp));
-
- TestObjectAllTypes res = mutPo.build().deserialize();
-
- GridTestUtils.deepEquals(exp, res);
- }
-
- /**
- * @throws Exception If any error occurs.
- */
- public void testSimpleTypeFieldSetNull() throws Exception {
- TestObjectAllTypes exp = new TestObjectAllTypes();
-
- exp.setDefaultData();
-
- BinaryObjectBuilderImpl mutPo = wrap(exp);
-
- for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
- if (!field.getType().isPrimitive())
- mutPo.setField(field.getName(), null);
- }
-
- TestObjectAllTypes res = mutPo.build().deserialize();
-
- for (Field field : TestObjectAllTypes.class.getDeclaredFields()) {
- if (!field.getType().isPrimitive())
- assertNull(field.getName(), field.get(res));
- }
- }
-
- /**
- * @throws IgniteCheckedException If any error occurs.
- */
- public void testMakeCyclicDependency() throws IgniteCheckedException {
- TestObjectOuter outer = new TestObjectOuter();
- outer.inner = new TestObjectInner();
-
- BinaryObjectBuilderImpl mutOuter = wrap(outer);
-
- BinaryObjectBuilderImpl mutInner = mutOuter.getField("inner");
-
- mutInner.setField("outer", mutOuter);
- mutInner.setField("foo", mutInner);
-
- TestObjectOuter res = mutOuter.build().deserialize();
-
- assertEquals(res, res.inner.outer);
- assertEquals(res.inner, res.inner.foo);
- }
-
- /**
- *
- */
- public void testDateArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.dateArr = new Date[] {new Date(11111), new Date(11111), new Date(11111)};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Date[] arr = mutObj.getField("dateArr");
- arr[0] = new Date(22222);
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new Date[] {new Date(22222), new Date(11111), new Date(11111)}, res.dateArr);
- }
-
- /**
- *
- */
- public void testTimestampArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.tsArr = new Timestamp[] {new Timestamp(111222333), new Timestamp(222333444)};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Timestamp[] arr = mutObj.getField("tsArr");
- arr[0] = new Timestamp(333444555);
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new Timestamp[] {new Timestamp(333444555), new Timestamp(222333444)}, res.tsArr);
- }
-
- /**
- *
- */
- public void testUUIDArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.uuidArr = new UUID[] {new UUID(1, 1), new UUID(1, 1), new UUID(1, 1)};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- UUID[] arr = mutObj.getField("uuidArr");
- arr[0] = new UUID(2, 2);
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new UUID[] {new UUID(2, 2), new UUID(1, 1), new UUID(1, 1)}, res.uuidArr);
- }
-
- /**
- *
- */
- public void testDecimalArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.bdArr = new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- BigDecimal[] arr = mutObj.getField("bdArr");
- arr[0] = new BigDecimal(2000);
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new BigDecimal[] {new BigDecimal(1000), new BigDecimal(1000), new BigDecimal(1000)},
- res.bdArr);
- }
-
- /**
- *
- */
- public void testBooleanArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.zArr = new boolean[] {false, false, false};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- boolean[] arr = mutObj.getField("zArr");
- arr[0] = true;
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- boolean[] expected = new boolean[] {true, false, false};
-
- assertEquals(expected.length, res.zArr.length);
-
- for (int i = 0; i < expected.length; i++)
- assertEquals(expected[i], res.zArr[i]);
- }
-
- /**
- *
- */
- public void testCharArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.cArr = new char[] {'a', 'a', 'a'};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- char[] arr = mutObj.getField("cArr");
- arr[0] = 'b';
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new char[] {'b', 'a', 'a'}, res.cArr);
- }
-
- /**
- *
- */
- public void testDoubleArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.dArr = new double[] {1.0, 1.0, 1.0};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- double[] arr = mutObj.getField("dArr");
- arr[0] = 2.0;
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new double[] {2.0, 1.0, 1.0}, res.dArr, 0);
- }
-
- /**
- *
- */
- public void testFloatArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.fArr = new float[] {1.0f, 1.0f, 1.0f};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- float[] arr = mutObj.getField("fArr");
- arr[0] = 2.0f;
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new float[] {2.0f, 1.0f, 1.0f}, res.fArr, 0);
- }
-
- /**
- *
- */
- public void testLongArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.lArr = new long[] {1, 1, 1};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- long[] arr = mutObj.getField("lArr");
- arr[0] = 2;
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new long[] {2, 1, 1}, res.lArr);
- }
-
- /**
- *
- */
- public void testIntArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.iArr = new int[] {1, 1, 1};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- int[] arr = mutObj.getField("iArr");
- arr[0] = 2;
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new int[] {2, 1, 1}, res.iArr);
- }
-
- /**
- *
- */
- public void testShortArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.sArr = new short[] {1, 1, 1};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- short[] arr = mutObj.getField("sArr");
- arr[0] = 2;
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new short[] {2, 1, 1}, res.sArr);
- }
-
- /**
- *
- */
- public void testByteArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.bArr = new byte[] {1, 1, 1};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- byte[] arr = mutObj.getField("bArr");
- arr[0] = 2;
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new byte[] {2, 1, 1}, res.bArr);
- }
-
- /**
- *
- */
- public void testStringArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.strArr = new String[] {"a", "a", "a"};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- String[] arr = mutObj.getField("strArr");
- arr[0] = "b";
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new String[] {"b", "a", "a"}, res.strArr);
- }
-
- /**
- *
- */
- public void testModifyObjectArray() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = new Object[] {"a"};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Object[] arr = mutObj.getField("foo");
-
- Assert.assertArrayEquals(new Object[] {"a"}, arr);
-
- arr[0] = "b";
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new Object[] {"b"}, (Object[])res.foo);
- }
-
- /**
- *
- */
- public void testOverrideObjectArrayField() {
- BinaryObjectBuilderImpl mutObj = wrap(new TestObjectContainer());
-
- Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
-
- mutObj.setField("foo", createdArr.clone());
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- createdArr[0] = res;
-
- assertTrue(Objects.deepEquals(createdArr, res.foo));
- }
-
- /**
- *
- */
- public void testDeepArray() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = new Object[] {new Object[] {"a", obj}};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Object[] arr = (Object[])mutObj.<Object[]>getField("foo")[0];
-
- assertEquals("a", arr[0]);
- assertSame(mutObj, arr[1]);
-
- arr[0] = mutObj;
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- arr = (Object[])((Object[])res.foo)[0];
-
- assertSame(arr[0], res);
- assertSame(arr[0], arr[1]);
- }
-
- /**
- *
- */
- public void testArrayListRead() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Lists.newArrayList(obj, "a");
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- List<Object> list = mutObj.getField("foo");
-
- assert list.equals(Lists.newArrayList(mutObj, "a"));
- }
-
- /**
- *
- */
- public void testArrayListOverride() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- ArrayList<Object> list = Lists.newArrayList(mutObj, "a", Lists.newArrayList(1, 2));
-
- mutObj.setField("foo", list);
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- list.set(0, res);
-
- assertNotSame(list, res.foo);
- assertEquals(list, res.foo);
- }
-
- /**
- *
- */
- public void testArrayListModification() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Lists.newArrayList("a", "b", "c");
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- List<String> list = mutObj.getField("foo");
-
- list.add("!"); // "a", "b", "c", "!"
- list.add(0, "_"); // "_", "a", "b", "c", "!"
-
- String s = list.remove(1); // "_", "b", "c", "!"
- assertEquals("a", s);
-
- assertEquals(Arrays.asList("c", "!"), list.subList(2, 4));
- assertEquals(1, list.indexOf("b"));
- assertEquals(1, list.lastIndexOf("b"));
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- assertTrue(res.foo instanceof ArrayList);
- assertEquals(Arrays.asList("_", "b", "c", "!"), res.foo);
- }
-
- /**
- *
- */
- public void testArrayListClear() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Lists.newArrayList("a", "b", "c");
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- List<String> list = mutObj.getField("foo");
-
- list.clear();
-
- assertEquals(Collections.emptyList(), mutObj.build().<TestObjectContainer>deserialize().foo);
- }
-
- /**
- *
- */
- public void testArrayListWriteUnmodifiable() {
- TestObjectContainer obj = new TestObjectContainer();
-
- ArrayList<Object> src = Lists.newArrayList(obj, "a", "b", "c");
-
- obj.foo = src;
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- TestObjectContainer deserialized = mutObj.build().deserialize();
-
- List<Object> res = (List<Object>)deserialized.foo;
-
- src.set(0, deserialized);
-
- assertEquals(src, res);
- }
-
- /**
- *
- */
- public void testLinkedListRead() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Lists.newLinkedList(Arrays.asList(obj, "a"));
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- List<Object> list = mutObj.getField("foo");
-
- assert list.equals(Lists.newLinkedList(Arrays.asList(mutObj, "a")));
- }
-
- /**
- *
- */
- public void testLinkedListOverride() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- List<Object> list = Lists.newLinkedList(Arrays.asList(mutObj, "a", Lists.newLinkedList(Arrays.asList(1, 2))));
-
- mutObj.setField("foo", list);
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- list.set(0, res);
-
- assertNotSame(list, res.foo);
- assertEquals(list, res.foo);
- }
-
- /**
- *
- */
- public void testLinkedListModification() {
- TestObjectContainer obj = new TestObjectContainer();
-
- obj.foo = Lists.newLinkedList(Arrays.asList("a", "b", "c"));
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- List<String> list = mutObj.getField("foo");
-
- list.add("!"); // "a", "b", "c", "!"
- list.add(0, "_"); // "_", "a", "b", "c", "!"
-
- String s = list.remove(1); // "_", "b", "c", "!"
- assertEquals("a", s);
-
- assertEquals(Arrays.asList("c", "!"), list.subList(2, 4));
- assertEquals(1, list.indexOf("b"));
- assertEquals(1, list.lastIndexOf("b"));
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- assertTrue(res.foo instanceof LinkedList);
- assertEquals(Arrays.asList("_", "b", "c", "!"), res.foo);
- }
-
- /**
- *
- */
- public void testLinkedListWriteUnmodifiable() {
- TestObjectContainer obj = new TestObjectContainer();
-
- LinkedList<Object> src = Lists.newLinkedList(Arrays.asList(obj, "a", "b", "c"));
-
- obj.foo = src;
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- TestObjectContainer deserialized = mutObj.build().deserialize();
-
- List<Object> res = (List<Object>)deserialized.foo;
-
- src.set(0, deserialized);
-
- assertEquals(src, res);
- }
-
- /**
- *
- */
- public void testHashSetRead() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Sets.newHashSet(obj, "a");
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Set<Object> set = mutObj.getField("foo");
-
- assert set.equals(Sets.newHashSet(mutObj, "a"));
- }
-
- /**
- *
- */
- public void testHashSetOverride() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Set<Object> c = Sets.newHashSet(mutObj, "a", Sets.newHashSet(1, 2));
-
- mutObj.setField("foo", c);
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- c.remove(mutObj);
- c.add(res);
-
- assertNotSame(c, res.foo);
- assertEquals(c, res.foo);
- }
-
- /**
- *
- */
- public void testHashSetModification() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Sets.newHashSet("a", "b", "c");
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Set<String> set = mutObj.getField("foo");
-
- set.remove("b");
- set.add("!");
-
- assertEquals(Sets.newHashSet("a", "!", "c"), set);
- assertTrue(set.contains("a"));
- assertTrue(set.contains("!"));
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- assertTrue(res.foo instanceof HashSet);
- assertEquals(Sets.newHashSet("a", "!", "c"), res.foo);
- }
-
- /**
- *
- */
- public void testHashSetWriteUnmodifiable() {
- TestObjectContainer obj = new TestObjectContainer();
-
- Set<Object> src = Sets.newHashSet(obj, "a", "b", "c");
-
- obj.foo = src;
-
- TestObjectContainer deserialized = wrap(obj).build().deserialize();
-
- Set<Object> res = (Set<Object>)deserialized.foo;
-
- src.remove(obj);
- src.add(deserialized);
-
- assertEquals(src, res);
- }
-
- /**
- *
- */
- public void testMapRead() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Maps.newHashMap(ImmutableMap.of(obj, "a", "b", obj));
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Map<Object, Object> map = mutObj.getField("foo");
-
- assert map.equals(ImmutableMap.of(mutObj, "a", "b", mutObj));
- }
-
- /**
- *
- */
- public void testMapOverride() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Map<Object, Object> map = Maps.newHashMap(ImmutableMap.of(mutObj, "a", "b", mutObj));
-
- mutObj.setField("foo", map);
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- assertEquals(ImmutableMap.of(res, "a", "b", res), res.foo);
- }
-
- /**
- *
- */
- public void testMapModification() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Maps.newHashMap(ImmutableMap.of(1, "a", 2, "b"));
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- Map<Object, Object> map = mutObj.getField("foo");
-
- map.put(3, mutObj);
- Object rmv = map.remove(1);
-
- assertEquals("a", rmv);
-
- TestObjectContainer res = mutObj.build().deserialize();
-
- assertEquals(ImmutableMap.of(2, "b", 3, res), res.foo);
- }
-
- /**
- *
- */
- public void testEnumArrayModification() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
-
- obj.enumArr = new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B};
-
- BinaryObjectBuilderImpl mutObj = wrap(obj);
-
- PortableBuilderEnum[] arr = mutObj.getField("enumArr");
- arr[0] = new PortableBuilderEnum(mutObj.typeId(), TestObjectEnum.B);
-
- TestObjectAllTypes res = mutObj.build().deserialize();
-
- Assert.assertArrayEquals(new TestObjectEnum[] {TestObjectEnum.A, TestObjectEnum.B}, res.enumArr);
- }
-
- /**
- *
- */
- public void testEditObjectWithRawData() {
- GridBinaryMarshalerAwareTestClass obj = new GridBinaryMarshalerAwareTestClass();
-
- obj.s = "a";
- obj.sRaw = "aa";
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- mutableObj.setField("s", "z");
-
- GridBinaryMarshalerAwareTestClass res = mutableObj.build().deserialize();
- assertEquals("z", res.s);
- assertEquals("aa", res.sRaw);
- }
-
- /**
- *
- */
- public void testHashCode() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- assertEquals(obj.hashCode(), mutableObj.build().hashCode());
-
- mutableObj.hashCode(25);
-
- assertEquals(25, mutableObj.build().hashCode());
- }
-
- /**
- *
- */
- public void testCollectionsInCollection() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = Lists.newArrayList(
- Lists.newArrayList(1, 2),
- Lists.newLinkedList(Arrays.asList(1, 2)),
- Sets.newHashSet("a", "b"),
- Sets.newLinkedHashSet(Arrays.asList("a", "b")),
- Maps.newHashMap(ImmutableMap.of(1, "a", 2, "b")));
-
- TestObjectContainer deserialized = wrap(obj).build().deserialize();
-
- assertEquals(obj.foo, deserialized.foo);
- }
-
- /**
- *
- */
- public void testMapEntryModification() {
- TestObjectContainer obj = new TestObjectContainer();
- obj.foo = ImmutableMap.of(1, "a").entrySet().iterator().next();
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- Map.Entry<Object, Object> entry = mutableObj.getField("foo");
-
- assertEquals(1, entry.getKey());
- assertEquals("a", entry.getValue());
-
- entry.setValue("b");
-
- TestObjectContainer res = mutableObj.build().deserialize();
-
- assertEquals(new GridMapEntry<>(1, "b"), res.foo);
- }
-
- /**
- *
- */
- public void testMapEntryOverride() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- mutableObj.setField("foo", new GridMapEntry<>(1, "a"));
-
- TestObjectContainer res = mutableObj.build().deserialize();
-
- assertEquals(new GridMapEntry<>(1, "a"), res.foo);
- }
-
- /**
- *
- */
- public void testMetadataChangingDoublePut() {
- BinaryObjectBuilderImpl mutableObj = wrap(new TestObjectContainer());
-
- mutableObj.setField("xx567", "a");
- mutableObj.setField("xx567", "b");
-
- mutableObj.build();
-
- BinaryType metadata = portables().metadata(TestObjectContainer.class);
-
- assertEquals("String", metadata.fieldTypeName("xx567"));
- }
-
- /**
- *
- */
- public void testMetadataChangingDoublePut2() {
- BinaryObjectBuilderImpl mutableObj = wrap(new TestObjectContainer());
-
- mutableObj.setField("xx567", "a");
- mutableObj.setField("xx567", "b");
-
- mutableObj.build();
-
- BinaryType metadata = portables().metadata(TestObjectContainer.class);
-
- assertEquals("String", metadata.fieldTypeName("xx567"));
- }
-
- /**
- *
- */
- public void testMetadataChanging() {
- TestObjectContainer c = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutableObj = wrap(c);
-
- mutableObj.setField("intField", 1);
- mutableObj.setField("intArrField", new int[] {1});
- mutableObj.setField("arrField", new String[] {"1"});
- mutableObj.setField("strField", "1");
- mutableObj.setField("colField", Lists.newArrayList("1"));
- mutableObj.setField("mapField", Maps.newHashMap(ImmutableMap.of(1, "1")));
- mutableObj.setField("enumField", TestObjectEnum.A);
- mutableObj.setField("enumArrField", new Enum[] {TestObjectEnum.A});
-
- mutableObj.build();
-
- BinaryType metadata = portables().metadata(c.getClass());
-
- assertTrue(metadata.fieldNames().containsAll(Arrays.asList("intField", "intArrField", "arrField", "strField",
- "colField", "mapField", "enumField", "enumArrField")));
-
- assertEquals("int", metadata.fieldTypeName("intField"));
- assertEquals("int[]", metadata.fieldTypeName("intArrField"));
- assertEquals("String[]", metadata.fieldTypeName("arrField"));
- assertEquals("String", metadata.fieldTypeName("strField"));
- assertEquals("Collection", metadata.fieldTypeName("colField"));
- assertEquals("Map", metadata.fieldTypeName("mapField"));
- assertEquals("Enum", metadata.fieldTypeName("enumField"));
- assertEquals("Enum[]", metadata.fieldTypeName("enumArrField"));
- }
-
- /**
- *
- */
- public void testDateInObjectField() {
- TestObjectContainer obj = new TestObjectContainer();
-
- obj.foo = new Date();
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- assertEquals(Date.class, mutableObj.getField("foo").getClass());
- }
-
- /**
- *
- */
- public void testTimestampInObjectField() {
- TestObjectContainer obj = new TestObjectContainer();
-
- obj.foo = new Timestamp(100020003);
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- assertEquals(Timestamp.class, mutableObj.getField("foo").getClass());
- }
-
- /**
- *
- */
- public void testDateInCollection() {
- TestObjectContainer obj = new TestObjectContainer();
-
- obj.foo = Lists.newArrayList(new Date());
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- assertEquals(Date.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
- }
-
- /**
- *
- */
- public void testTimestampInCollection() {
- TestObjectContainer obj = new TestObjectContainer();
-
- obj.foo = Lists.newArrayList(new Timestamp(100020003));
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- assertEquals(Timestamp.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
- }
-
- /**
- *
- */
- @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
- public void testDateArrayOverride() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- Date[] arr = { new Date() };
-
- mutableObj.setField("foo", arr);
-
- TestObjectContainer res = mutableObj.build().deserialize();
-
- assertEquals(Date[].class, res.foo.getClass());
- assertTrue(Objects.deepEquals(arr, res.foo));
- }
-
- /**
- *
- */
- @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
- public void testTimestampArrayOverride() {
- TestObjectContainer obj = new TestObjectContainer();
-
- BinaryObjectBuilderImpl mutableObj = wrap(obj);
-
- Timestamp[] arr = { new Timestamp(100020003) };
-
- mutableObj.setField("foo", arr);
-
- TestObjectContainer res = mutableObj.build().deserialize();
-
- assertEquals(Timestamp[].class, res.foo.getClass());
- assertTrue(Objects.deepEquals(arr, res.foo));
- }
-
- /**
- *
- */
- public void testChangeMap() {
- AddressBook addrBook = new AddressBook();
-
- addrBook.addCompany(new Company(1, "Google inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 53), "occupation"));
- addrBook.addCompany(new Company(2, "Apple inc", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 54), "occupation"));
- addrBook.addCompany(new Company(3, "Microsoft", 100, new Address("Saint-Petersburg", "Torzhkovskya", 1, 55), "occupation"));
- addrBook.addCompany(new Company(4, "Oracle", 100, new Address("Saint-Petersburg", "Nevskiy", 1, 1), "occupation"));
-
- BinaryObjectBuilderImpl mutableObj = wrap(addrBook);
-
- Map<String, List<BinaryObjectBuilderImpl>> map = mutableObj.getField("companyByStreet");
-
- List<BinaryObjectBuilderImpl> list = map.get("Torzhkovskya");
-
- BinaryObjectBuilderImpl company = list.get(0);
-
- assert "Google inc".equals(company.<String>getField("name"));
-
- list.remove(0);
-
- AddressBook res = mutableObj.build().deserialize();
-
- assertEquals(Arrays.asList("Nevskiy", "Torzhkovskya"), new ArrayList<>(res.getCompanyByStreet().keySet()));
-
- List<Company> torzhkovskyaCompanies = res.getCompanyByStreet().get("Torzhkovskya");
-
- assertEquals(2, torzhkovskyaCompanies.size());
- assertEquals("Apple inc", torzhkovskyaCompanies.get(0).name);
- }
-
- /**
- *
- */
- public void testSavingObjectWithNotZeroStart() {
- TestObjectOuter out = new TestObjectOuter();
- TestObjectInner inner = new TestObjectInner();
-
- out.inner = inner;
- inner.outer = out;
-
- BinaryObjectBuilderImpl builder = wrap(out);
-
- BinaryObjectBuilderImpl innerBuilder = builder.getField("inner");
-
- TestObjectInner res = innerBuilder.build().deserialize();
-
- assertSame(res, res.outer.inner);
- }
-
- /**
- *
- */
- public void testPortableObjectField() {
- TestObjectContainer container = new TestObjectContainer(toPortable(new TestObjectArrayList()));
-
- BinaryObjectBuilderImpl wrapper = wrap(container);
-
- assertTrue(wrapper.getField("foo") instanceof BinaryObject);
-
- TestObjectContainer deserialized = wrapper.build().deserialize();
- assertTrue(deserialized.foo instanceof BinaryObject);
- }
-
- /**
- *
- */
- public void testAssignPortableObject() {
- TestObjectContainer container = new TestObjectContainer();
-
- BinaryObjectBuilderImpl wrapper = wrap(container);
-
- wrapper.setField("foo", toPortable(new TestObjectArrayList()));
-
- TestObjectContainer deserialized = wrapper.build().deserialize();
- assertTrue(deserialized.foo instanceof TestObjectArrayList);
- }
-
- /**
- *
- */
- public void testRemoveFromNewObject() {
- BinaryObjectBuilderImpl wrapper = newWrapper(TestObjectAllTypes.class);
-
- wrapper.setField("str", "a");
-
- wrapper.removeField("str");
-
- assertNull(wrapper.build().<TestObjectAllTypes>deserialize().str);
- }
-
- /**
- *
- */
- public void testRemoveFromExistingObject() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
- obj.setDefaultData();
-
- BinaryObjectBuilderImpl wrapper = wrap(toPortable(obj));
-
- wrapper.removeField("str");
-
- assertNull(wrapper.build().<TestObjectAllTypes>deserialize().str);
- }
-
- /**
- *
- */
- public void testCyclicArrays() {
- TestObjectContainer obj = new TestObjectContainer();
-
- Object[] arr1 = new Object[1];
- Object[] arr2 = new Object[] {arr1};
-
- arr1[0] = arr2;
-
- obj.foo = arr1;
-
- TestObjectContainer res = toPortable(obj).deserialize();
-
- Object[] resArr = (Object[])res.foo;
-
- assertSame(((Object[])resArr[0])[0], resArr);
- }
-
- /**
- *
- */
- @SuppressWarnings("TypeMayBeWeakened")
- public void testCyclicArrayList() {
- TestObjectContainer obj = new TestObjectContainer();
-
- List<Object> arr1 = new ArrayList<>();
- List<Object> arr2 = new ArrayList<>();
-
- arr1.add(arr2);
- arr2.add(arr1);
-
- obj.foo = arr1;
-
- TestObjectContainer res = toPortable(obj).deserialize();
-
- List<?> resArr = (List<?>)res.foo;
-
- assertSame(((List<Object>)resArr.get(0)).get(0), resArr);
- }
-
- /**
- * @param obj Object.
- * @return Object in portable format.
- */
- private BinaryObject toPortable(Object obj) {
- return portables().toBinary(obj);
- }
-
- /**
- * @param obj Object.
- * @return GridMutablePortableObject.
- */
- private BinaryObjectBuilderImpl wrap(Object obj) {
- return BinaryObjectBuilderImpl.wrap(toPortable(obj));
- }
-
- /**
- * @param aCls Class.
- * @return Wrapper.
- */
- private BinaryObjectBuilderImpl newWrapper(Class<?> aCls) {
- CacheObjectBinaryProcessorImpl processor = (CacheObjectBinaryProcessorImpl)(
- (IgniteBinaryImpl)portables()).processor();
-
- return new BinaryObjectBuilderImpl(processor.portableContext(), processor.typeId(aCls.getName()),
- aCls.getSimpleName());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
deleted file mode 100644
index a74315b..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridBinaryObjectBuilderSelfTest.java
+++ /dev/null
@@ -1,1053 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.portable.builder.BinaryObjectBuilderImpl;
-import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectAllTypes;
-import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectContainer;
-import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectInner;
-import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectOuter;
-import org.apache.ignite.internal.portable.mutabletest.GridPortableTestClasses.TestObjectPlainPortable;
-import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import sun.misc.Unsafe;
-
-/**
- * Portable builder test.
- */
-public class GridBinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
- /** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName(),
- "org.gridgain.grid.internal.util.portable.mutabletest.*"));
-
- BinaryTypeConfiguration customIdMapper = new BinaryTypeConfiguration();
-
- customIdMapper.setClassName(CustomIdMapper.class.getName());
- customIdMapper.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return ~PortableContext.DFLT_ID_MAPPER.typeId(clsName);
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return typeId + ~PortableContext.DFLT_ID_MAPPER.fieldId(typeId, fieldName);
- }
- });
-
- marsh.setTypeConfigurations(Collections.singleton(customIdMapper));
-
- cfg.setMarshaller(marsh);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrids(1);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /**
- *
- */
- public void testAllFieldsSerialization() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
- obj.setDefaultData();
- obj.enumArr = null;
-
- TestObjectAllTypes deserialized = builder(toPortable(obj)).build().deserialize();
-
- GridTestUtils.deepEquals(obj, deserialized);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testByteField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("byteField", (byte)1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testShortField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("shortField", (short)1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals((short)1, po.<Short>field("shortField").shortValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testIntField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("intField", 1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1, po.<Integer>field("intField").intValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLongField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("longField", 1L);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1L, po.<Long>field("longField").longValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testFloatField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("floatField", 1.0f);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDoubleField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("doubleField", 1.0d);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCharField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("charField", (char)1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals((char)1, po.<Character>field("charField").charValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBooleanField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("booleanField", true);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(po.<Boolean>field("booleanField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDecimalField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("decimalField", BigDecimal.TEN);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(BigDecimal.TEN, po.<String>field("decimalField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testStringField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("stringField", "str");
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals("str", po.<String>field("stringField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDateField() throws Exception {
- Date date = new Date();
-
- assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTimestampField() throws Exception {
- Timestamp ts = new Timestamp(new Date().getTime());
- ts.setNanos(1000);
-
- assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUuidField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- UUID uuid = UUID.randomUUID();
-
- builder.setField("uuidField", uuid);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(uuid, po.<UUID>field("uuidField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testByteArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("byteArrayField", new byte[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new byte[] {1, 2, 3}, po.<byte[]>field("byteArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testShortArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("shortArrayField", new short[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new short[] {1, 2, 3}, po.<short[]>field("shortArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testIntArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("intArrayField", new int[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("intArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLongArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("longArrayField", new long[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new long[] {1, 2, 3}, po.<long[]>field("longArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testFloatArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("floatArrayField", new float[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new float[] {1, 2, 3}, po.<float[]>field("floatArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDoubleArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("doubleArrayField", new double[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new double[] {1, 2, 3}, po.<double[]>field("doubleArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCharArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("charArrayField", new char[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new char[] {1, 2, 3}, po.<char[]>field("charArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBooleanArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("booleanArrayField", new boolean[] {true, false});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- boolean[] arr = po.field("booleanArrayField");
-
- assertEquals(2, arr.length);
-
- assertTrue(arr[0]);
- assertFalse(arr[1]);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDecimalArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("decimalArrayField", new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN}, po.<String[]>field("decimalArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testStringArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("stringArrayField", new String[] {"str1", "str2", "str3"});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new String[] {"str1", "str2", "str3"}, po.<String[]>field("stringArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDateArrayField() throws Exception {
- Date date1 = new Date();
- Date date2 = new Date(date1.getTime() + 1000);
-
- Date[] dateArr = new Date[] { date1, date2 };
-
- assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTimestampArrayField() throws Exception {
- Timestamp ts1 = new Timestamp(new Date().getTime());
- Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
-
- ts1.setNanos(1000);
- ts2.setNanos(2000);
-
- Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
-
- assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUuidArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID()};
-
- builder.setField("uuidArrayField", arr);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testObjectField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("objectField", new Value(1));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testObjectArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("objectArrayField", new Value[] {new Value(1), new Value(2)});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- Object[] arr = po.field("objectArrayField");
-
- assertEquals(2, arr.length);
-
- assertEquals(1, ((BinaryObject)arr[0]).<Value>deserialize().i);
- assertEquals(2, ((BinaryObject)arr[1]).<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCollectionField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- List<BinaryObject> list = po.field("collectionField");
-
- assertEquals(2, list.size());
-
- assertEquals(1, list.get(0).<Value>deserialize().i);
- assertEquals(2, list.get(1).<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMapField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- Map<BinaryObject, BinaryObject> map = po.field("mapField");
-
- assertEquals(2, map.size());
-
- for (Map.Entry<BinaryObject, BinaryObject> e : map.entrySet())
- assertEquals(e.getKey().<Key>deserialize().i, e.getValue().<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSeveralFields() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("i", 111);
- builder.setField("f", 111.111f);
- builder.setField("iArr", new int[] {1, 2, 3});
- builder.setField("obj", new Key(1));
- builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(111, po.<Integer>field("i").intValue());
- assertEquals(111.111f, po.<Float>field("f").floatValue(), 0);
- assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("iArr")));
- assertEquals(1, po.<BinaryObject>field("obj").<Key>deserialize().i);
-
- List<BinaryObject> list = po.field("col");
-
- assertEquals(2, list.size());
-
- assertEquals(1, list.get(0).<Value>deserialize().i);
- assertEquals(2, list.get(1).<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testOffheapPortable() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("i", 111);
- builder.setField("f", 111.111f);
- builder.setField("iArr", new int[] {1, 2, 3});
- builder.setField("obj", new Key(1));
- builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
-
- BinaryObject po = builder.build();
-
- byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
-
- long ptr = UNSAFE.allocateMemory(arr.length + 5);
-
- try {
- long ptr0 = ptr;
-
- UNSAFE.putBoolean(null, ptr0++, false);
-
- UNSAFE.putInt(ptr0, arr.length);
-
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
-
- BinaryObject offheapObj = (BinaryObject)
- ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
-
- assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
-
- assertEquals("class".hashCode(), offheapObj.typeId());
- assertEquals(100, offheapObj.hashCode());
-
- assertEquals(111, offheapObj.<Integer>field("i").intValue());
- assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
- assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
- assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);
-
- List<BinaryObject> list = offheapObj.field("col");
-
- assertEquals(2, list.size());
-
- assertEquals(1, list.get(0).<Value>deserialize().i);
- assertEquals(2, list.get(1).<Value>deserialize().i);
-
- assertEquals(po, offheapObj);
- assertEquals(offheapObj, po);
- }
- finally {
- UNSAFE.freeMemory(ptr);
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBuildAndDeserialize() throws Exception {
- BinaryObjectBuilder builder = builder(Value.class.getName());
-
- builder.hashCode(100);
-
- builder.setField("i", 1);
-
- BinaryObject po = builder.build();
-
- assertEquals("value".hashCode(), po.typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1, po.<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMetaData2() throws Exception {
- BinaryObjectBuilder builder = builder("org.test.MetaTest2");
-
- builder.setField("objectField", "a", Object.class);
-
- BinaryObject po = builder.build();
-
- BinaryType meta = po.type();
-
- assertEquals("MetaTest2", meta.typeName());
- assertEquals("Object", meta.fieldTypeName("objectField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMetaData() throws Exception {
- BinaryObjectBuilder builder = builder("org.test.MetaTest");
-
- builder.hashCode(100);
-
- builder.setField("intField", 1);
- builder.setField("byteArrayField", new byte[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- BinaryType meta = po.type();
-
- assertEquals("MetaTest", meta.typeName());
-
- Collection<String> fields = meta.fieldNames();
-
- assertEquals(2, fields.size());
-
- assertTrue(fields.contains("intField"));
- assertTrue(fields.contains("byteArrayField"));
-
- assertEquals("int", meta.fieldTypeName("intField"));
- assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
-
- builder = builder("org.test.MetaTest");
-
- builder.hashCode(100);
-
- builder.setField("intField", 2);
- builder.setField("uuidField", UUID.randomUUID());
-
- po = builder.build();
-
- meta = po.type();
-
- assertEquals("MetaTest", meta.typeName());
-
- fields = meta.fieldNames();
-
- assertEquals(3, fields.size());
-
- assertTrue(fields.contains("intField"));
- assertTrue(fields.contains("byteArrayField"));
- assertTrue(fields.contains("uuidField"));
-
- assertEquals("int", meta.fieldTypeName("intField"));
- assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
- assertEquals("UUID", meta.fieldTypeName("uuidField"));
- }
-
- /**
- *
- */
- public void testGetFromCopiedObj() {
- BinaryObject objStr = builder(TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
-
- BinaryObjectBuilderImpl builder = builder(objStr);
- assertEquals("aaa", builder.getField("str"));
-
- builder.setField("str", "bbb");
- assertEquals("bbb", builder.getField("str"));
-
- assertNull(builder.getField("i_"));
- assertEquals("bbb", builder.build().<TestObjectAllTypes>deserialize().str);
- }
-
- /**
- *
- */
- public void testCopyFromInnerObjects() {
- ArrayList<Object> list = new ArrayList<>();
- list.add(new TestObjectAllTypes());
- list.add(list.get(0));
-
- TestObjectContainer c = new TestObjectContainer(list);
-
- BinaryObjectBuilderImpl builder = builder(toPortable(c));
- builder.<List>getField("foo").add("!!!");
-
- BinaryObject res = builder.build();
-
- TestObjectContainer deserialized = res.deserialize();
-
- List deserializedList = (List)deserialized.foo;
-
- assertSame(deserializedList.get(0), deserializedList.get(1));
- assertEquals("!!!", deserializedList.get(2));
- assertTrue(deserializedList.get(0) instanceof TestObjectAllTypes);
- }
-
- /**
- *
- */
- public void testSetPortableObject() {
- BinaryObject portableObj = builder(TestObjectContainer.class.getName())
- .setField("foo", toPortable(new TestObjectAllTypes()))
- .build();
-
- assertTrue(portableObj.<TestObjectContainer>deserialize().foo instanceof TestObjectAllTypes);
- }
-
- /**
- *
- */
- public void testPlainPortableObjectCopyFrom() {
- TestObjectPlainPortable obj = new TestObjectPlainPortable(toPortable(new TestObjectAllTypes()));
-
- BinaryObjectBuilderImpl builder = builder(toPortable(obj));
- assertTrue(builder.getField("plainPortable") instanceof BinaryObject);
-
- TestObjectPlainPortable deserialized = builder.build().deserialize();
- assertTrue(deserialized.plainPortable instanceof BinaryObject);
- }
-
- /**
- *
- */
- public void testRemoveFromNewObject() {
- BinaryObjectBuilder builder = builder(TestObjectAllTypes.class.getName());
-
- builder.setField("str", "a");
-
- builder.removeField("str");
-
- assertNull(builder.build().<TestObjectAllTypes>deserialize().str);
- }
-
- /**
- *
- */
- public void testRemoveFromExistingObject() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
- obj.setDefaultData();
- obj.enumArr = null;
-
- BinaryObjectBuilder builder = builder(toPortable(obj));
-
- builder.removeField("str");
-
- assertNull(builder.build().<TestObjectAllTypes>deserialize().str);
- }
-
- /**
- *
- */
- public void testRemoveFromExistingObjectAfterGet() {
- TestObjectAllTypes obj = new TestObjectAllTypes();
- obj.setDefaultData();
- obj.enumArr = null;
-
- BinaryObjectBuilderImpl builder = builder(toPortable(obj));
-
- builder.getField("i_");
-
- builder.removeField("str");
-
- assertNull(builder.build().<TestObjectAllTypes>deserialize().str);
- }
-
- /**
- * @throws IgniteCheckedException If any error occurs.
- */
- public void testDontBrokeCyclicDependency() throws IgniteCheckedException {
- TestObjectOuter outer = new TestObjectOuter();
- outer.inner = new TestObjectInner();
- outer.inner.outer = outer;
- outer.foo = "a";
-
- BinaryObjectBuilder builder = builder(toPortable(outer));
-
- builder.setField("foo", "b");
-
- TestObjectOuter res = builder.build().deserialize();
-
- assertEquals("b", res.foo);
- assertSame(res, res.inner.outer);
- }
-
- /**
- * @return Portables.
- */
- private IgniteBinary portables() {
- return grid(0).binary();
- }
-
- /**
- * @param obj Object.
- * @return Portable object.
- */
- private BinaryObject toPortable(Object obj) {
- return portables().toBinary(obj);
- }
-
- /**
- * @return Builder.
- */
- private <T> BinaryObjectBuilder builder(String clsName) {
- return portables().builder(clsName);
- }
-
- /**
- * @return Builder.
- */
- private <T> BinaryObjectBuilderImpl builder(BinaryObject obj) {
- return (BinaryObjectBuilderImpl)portables().builder(obj);
- }
-
- /**
- *
- */
- private static class CustomIdMapper {
- /** */
- private String str = "a";
-
- /** */
- private int i = 10;
- }
-
- /**
- */
- private static class Key {
- /** */
- private int i;
-
- /**
- */
- private Key() {
- // No-op.
- }
-
- /**
- * @param i Index.
- */
- private Key(int i) {
- this.i = i;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- Key key = (Key)o;
-
- return i == key.i;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return i;
- }
- }
-
- /**
- */
- private static class Value {
- /** */
- private int i;
-
- /**
- */
- private Value() {
- // No-op.
- }
-
- /**
- * @param i Index.
- */
- private Value(int i) {
- this.i = i;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
index 747f8ea..9c0824e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
@@ -45,7 +45,7 @@ public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstrac
PortableMarshaller marsh = new PortableMarshaller();
marsh.setContext(new MarshallerContextWithNoStorage());
- PortableContext context = new PortableContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration());
+ PortableContext context = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", context);
[26/55] [abbrv] ignite git commit: IGNITE-1917: Binary protocol
performance optimizations.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderHandles.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderHandles.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderHandles.java
new file mode 100644
index 0000000..0024db0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderHandles.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.jetbrains.annotations.Nullable;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Reader handles.
+ */
+public class BinaryReaderHandles {
+ /** Mode: empty. */
+ private static final int MODE_EMPTY = 0;
+
+ /** Mode: single object. */
+ private static final int MODE_SINGLE = 1;
+
+ /** Mode: multiple objects. */
+ private static final int MODE_MULTIPLE = 2;
+
+ /** Position. */
+ private int singlePos;
+
+ /** Data. This is either an object or a map. */
+ private Object data;
+
+ /** Mode. */
+ private int mode = MODE_EMPTY;
+
+ /**
+ * Get object by position.
+ *
+ * @param pos Position.
+ * @return Object.
+ */
+ @SuppressWarnings("unchecked")
+ public @Nullable <T> T get(int pos) {
+ switch (mode) {
+ case MODE_EMPTY:
+ return null;
+
+ case MODE_SINGLE:
+ return (T)data;
+
+ default:
+ assert mode == MODE_MULTIPLE;
+
+ return (T)((Map<Integer, Object>)data).get(pos);
+ }
+ }
+
+ /**
+ * Put object to registry and return previous position (if any).
+ *
+ * @param pos Position.
+ * @param obj Object.
+ */
+ @SuppressWarnings("unchecked")
+ public void put(int pos, Object obj) {
+ assert pos >= 0;
+ assert obj != null;
+
+ switch (mode) {
+ case MODE_EMPTY:
+ this.singlePos = pos;
+ this.data = obj;
+ this.mode = MODE_SINGLE;
+
+ break;
+
+ case MODE_SINGLE:
+ Map<Integer, Object> newData = new HashMap(3, 1.0f);
+
+ newData.put(singlePos, data);
+ newData.put(pos, obj);
+
+ this.singlePos = -1;
+ this.data = newData;
+ this.mode = MODE_MULTIPLE;
+
+ break;
+
+ default:
+ assert mode == MODE_MULTIPLE;
+
+ Map<Integer, Object> data0 = (Map<Integer, Object>)data;
+
+ data0.put(pos, obj);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryThreadLocalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryThreadLocalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryThreadLocalContext.java
new file mode 100644
index 0000000..c6a7fc3
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryThreadLocalContext.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.internal.portable.streams.PortableMemoryAllocator;
+import org.apache.ignite.internal.portable.streams.PortableMemoryAllocatorChunk;
+
+/**
+ * Contains thread-local data for binary marshalling.
+ */
+public class BinaryThreadLocalContext {
+ /** Thread-local instance. */
+ private static final ThreadLocal<BinaryThreadLocalContext> CTX = new ThreadLocal<BinaryThreadLocalContext>() {
+ @Override protected BinaryThreadLocalContext initialValue() {
+ return new BinaryThreadLocalContext();
+ }
+ };
+
+ /** Memory chunk. */
+ private final PortableMemoryAllocatorChunk chunk = PortableMemoryAllocator.INSTANCE.chunk();
+
+ /** Schema holder. */
+ private final BinaryWriterSchemaHolder schema = new BinaryWriterSchemaHolder();
+
+ /**
+ * Get current context.
+ *
+ * @return Context.
+ */
+ public static BinaryThreadLocalContext get() {
+ return CTX.get();
+ }
+
+ /**
+ * Private constructor.
+ */
+ private BinaryThreadLocalContext() {
+ // No-op.
+ }
+
+ /**
+ * @return Memory chunk.
+ */
+ public PortableMemoryAllocatorChunk chunk() {
+ return chunk;
+ }
+
+ /**
+ * @return Schema holder.
+ */
+ public BinaryWriterSchemaHolder schemaHolder() {
+ return schema;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
index 60c135d..2630a40 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryTypeImpl.java
@@ -71,6 +71,7 @@ public class BinaryTypeImpl implements BinaryType {
public PortableContext context() {
return ctx;
}
+
/**
* @return Metadata.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java
new file mode 100644
index 0000000..a26b741
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriteMode.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+/**
+ * Various write modes for binary objects.
+ */
+public enum BinaryWriteMode {
+ /** Primitive byte. */
+ P_BYTE(GridPortableMarshaller.BYTE),
+
+ /** Primitive boolean. */
+ P_BOOLEAN(GridPortableMarshaller.BOOLEAN),
+
+ /** Primitive short. */
+ P_SHORT(GridPortableMarshaller.SHORT),
+
+ /** Primitive char. */
+ P_CHAR(GridPortableMarshaller.CHAR),
+
+ /** Primitive int. */
+ P_INT(GridPortableMarshaller.INT),
+
+ /** Primitive long. */
+ P_LONG(GridPortableMarshaller.LONG),
+
+ /** Primitive float. */
+ P_FLOAT(GridPortableMarshaller.FLOAT),
+
+ /** Primitive int. */
+ P_DOUBLE(GridPortableMarshaller.DOUBLE),
+
+ /** */
+ BYTE(GridPortableMarshaller.BYTE),
+
+ /** */
+ SHORT(GridPortableMarshaller.SHORT),
+
+ /** */
+ INT(GridPortableMarshaller.INT),
+
+ /** */
+ LONG(GridPortableMarshaller.LONG),
+
+ /** */
+ FLOAT(GridPortableMarshaller.FLOAT),
+
+ /** */
+ DOUBLE(GridPortableMarshaller.DOUBLE),
+
+ /** */
+ CHAR(GridPortableMarshaller.CHAR),
+
+ /** */
+ BOOLEAN(GridPortableMarshaller.BOOLEAN),
+
+ /** */
+ DECIMAL(GridPortableMarshaller.DECIMAL),
+
+ /** */
+ STRING(GridPortableMarshaller.STRING),
+
+ /** */
+ UUID(GridPortableMarshaller.UUID),
+
+ /** */
+ DATE(GridPortableMarshaller.DATE),
+
+ /** */
+ TIMESTAMP(GridPortableMarshaller.TIMESTAMP),
+
+ /** */
+ BYTE_ARR(GridPortableMarshaller.BYTE_ARR),
+
+ /** */
+ SHORT_ARR(GridPortableMarshaller.SHORT_ARR),
+
+ /** */
+ INT_ARR(GridPortableMarshaller.INT_ARR),
+
+ /** */
+ LONG_ARR(GridPortableMarshaller.LONG_ARR),
+
+ /** */
+ FLOAT_ARR(GridPortableMarshaller.FLOAT_ARR),
+
+ /** */
+ DOUBLE_ARR(GridPortableMarshaller.DOUBLE_ARR),
+
+ /** */
+ CHAR_ARR(GridPortableMarshaller.CHAR_ARR),
+
+ /** */
+ BOOLEAN_ARR(GridPortableMarshaller.BOOLEAN_ARR),
+
+ /** */
+ DECIMAL_ARR(GridPortableMarshaller.DECIMAL_ARR),
+
+ /** */
+ STRING_ARR(GridPortableMarshaller.STRING_ARR),
+
+ /** */
+ UUID_ARR(GridPortableMarshaller.UUID_ARR),
+
+ /** */
+ DATE_ARR(GridPortableMarshaller.DATE_ARR),
+
+ /** */
+ TIMESTAMP_ARR(GridPortableMarshaller.TIMESTAMP_ARR),
+
+ /** */
+ OBJECT_ARR(GridPortableMarshaller.OBJ_ARR),
+
+ /** */
+ COL(GridPortableMarshaller.COL),
+
+ /** */
+ MAP(GridPortableMarshaller.MAP),
+
+ /** */
+ MAP_ENTRY(GridPortableMarshaller.MAP_ENTRY),
+
+ /** */
+ PORTABLE_OBJ(GridPortableMarshaller.OBJ),
+
+ /** */
+ ENUM(GridPortableMarshaller.ENUM),
+
+ /** */
+ ENUM_ARR(GridPortableMarshaller.ENUM_ARR),
+
+ /** */
+ CLASS(GridPortableMarshaller.CLASS),
+
+ /** */
+ PORTABLE(GridPortableMarshaller.PORTABLE_OBJ),
+
+ /** */
+ EXTERNALIZABLE(GridPortableMarshaller.OBJ),
+
+ /** */
+ OBJECT(GridPortableMarshaller.OBJ),
+
+ /** */
+ EXCLUSION(GridPortableMarshaller.OBJ);
+
+ /** Type ID. */
+ private final int typeId;
+
+ /**
+ * @param typeId Type ID.
+ */
+ private BinaryWriteMode(int typeId) {
+ this.typeId = typeId;
+ }
+
+ /**
+ * @return Type ID.
+ */
+ public int typeId() {
+ return typeId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
index 6cb18fb..7bb4c49 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterExImpl.java
@@ -19,12 +19,12 @@ package org.apache.ignite.internal.portable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream;
-import org.apache.ignite.internal.portable.streams.PortableOutputStream;
-import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream;
+import org.apache.ignite.internal.portable.streams.PortableOutputStream;
+import org.apache.ignite.internal.util.typedef.internal.A;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
@@ -35,7 +35,6 @@ import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Date;
-import java.util.IdentityHashMap;
import java.util.Map;
import java.util.UUID;
@@ -66,7 +65,6 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.LONG_AR
import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.MAP_ENTRY;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.OBJ_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.OPTM_MARSH;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.PORTABLE_OBJ;
@@ -93,44 +91,26 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** Initial capacity. */
private static final int INIT_CAP = 1024;
- /** Maximum offset which fits in 1 byte. */
- private static final int MAX_OFFSET_1 = 1 << 8;
-
- /** Maximum offset which fits in 2 bytes. */
- private static final int MAX_OFFSET_2 = 1 << 16;
-
- /** Thread-local schema. */
- private static final ThreadLocal<SchemaHolder> SCHEMA = new ThreadLocal<>();
-
/** */
private final PortableContext ctx;
- /** */
- private final int start;
+ /** Output stream. */
+ private final PortableOutputStream out;
- /** */
- private Class<?> cls;
+ /** Schema. */
+ private final BinaryWriterSchemaHolder schema;
/** */
private int typeId;
- /** Raw offset position. */
- private int rawOffPos;
-
/** */
- private boolean metaEnabled;
+ private final int start;
- /** */
- private int metaHashSum;
+ /** Raw offset position. */
+ private int rawOffPos;
/** Handles. */
- private Map<Object, Integer> handles;
-
- /** Output stream. */
- private PortableOutputStream out;
-
- /** Schema. */
- private SchemaHolder schema;
+ private BinaryWriterHandles handles;
/** Schema ID. */
private int schemaId = PortableUtils.schemaInitialId();
@@ -144,40 +124,38 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/**
* @param ctx Context.
*/
- BinaryWriterExImpl(PortableContext ctx) {
- this(ctx, new PortableHeapOutputStream(INIT_CAP));
+ public BinaryWriterExImpl(PortableContext ctx) {
+ this(ctx, BinaryThreadLocalContext.get());
}
/**
* @param ctx Context.
- * @param out Output stream.
+ * @param tlsCtx TLS context.
*/
- BinaryWriterExImpl(PortableContext ctx, PortableOutputStream out) {
- this(ctx, out, new IdentityHashMap<Object, Integer>());
+ public BinaryWriterExImpl(PortableContext ctx, BinaryThreadLocalContext tlsCtx) {
+ this(ctx, new PortableHeapOutputStream(INIT_CAP, tlsCtx.chunk()), tlsCtx.schemaHolder(), null);
}
- /**
- * @param ctx Context.
- * @param out Output stream.
- * @param handles Handles.
- */
- private BinaryWriterExImpl(PortableContext ctx, PortableOutputStream out, Map<Object, Integer> handles) {
- this.ctx = ctx;
- this.out = out;
- this.handles = handles;
+ /**
+ * @param ctx Context.
+ * @param out Output stream.
+ * @param handles Handles.
+ */
+ public BinaryWriterExImpl(PortableContext ctx, PortableOutputStream out, BinaryWriterSchemaHolder schema,
+ BinaryWriterHandles handles) {
+ this.ctx = ctx;
+ this.out = out;
+ this.schema = schema;
+ this.handles = handles;
- start = out.position();
- }
+ start = out.position();
+ }
/**
- * @param ctx Context.
* @param typeId Type ID.
*/
- public BinaryWriterExImpl(PortableContext ctx, int typeId, boolean metaEnabled) {
- this(ctx);
-
+ public void typeId(int typeId) {
this.typeId = typeId;
- this.metaEnabled = metaEnabled;
}
/**
@@ -188,13 +166,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
- * @return Meta data hash sum or {@code null} if meta data is disabled.
- */
- @Nullable Integer metaDataHashSum() {
- return metaEnabled ? metaHashSum : null;
- }
-
- /**
* @param obj Object.
* @throws org.apache.ignite.binary.BinaryObjectException In case of error.
*/
@@ -210,7 +181,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
void marshal(Object obj, boolean enableReplace) throws BinaryObjectException {
assert obj != null;
- cls = obj.getClass();
+ Class<?> cls = obj.getClass();
PortableClassDescriptor desc = ctx.descriptorForClass(cls);
@@ -218,12 +189,13 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
throw new BinaryObjectException("Object is not portable: [class=" + cls + ']');
if (desc.excluded()) {
- doWriteByte(NULL);
+ out.writeByte(NULL);
+
return;
}
if (desc.useOptimizedMarshaller()) {
- writeByte(OPTM_MARSH);
+ out.writeByte(OPTM_MARSH);
try {
byte[] arr = ctx.optimizedMarsh().marshal(obj);
@@ -256,7 +228,8 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
if (replacedObj == null) {
- doWriteByte(NULL);
+ out.writeByte(NULL);
+
return;
}
@@ -265,31 +238,10 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
return;
}
- typeId = desc.typeId();
- metaEnabled = desc.userType();
-
desc.write(obj, this);
}
/**
- * @param obj Object.
- * @return Handle.
- */
- int handle(Object obj) {
- assert obj != null;
-
- Integer h = handles.get(obj);
-
- if (h != null)
- return out.position() - h;
- else {
- handles.put(obj, out.position());
-
- return -1;
- }
- }
-
- /**
* @return Array.
*/
public byte[] array() {
@@ -340,18 +292,18 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (useCompactFooter)
flags |= PortableUtils.FLAG_COMPACT_FOOTER;
-
- if (schema != null) {
+
+ if (fieldCnt != 0) {
flags |= PortableUtils.FLAG_HAS_SCHEMA;
// Write schema ID.
- out.writeInt(start + SCHEMA_ID_POS, schemaId);
+ out.unsafeWriteInt(start + SCHEMA_ID_POS, schemaId);
// Write schema offset.
- out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, out.position() - start);
+ out.unsafeWriteInt(start + SCHEMA_OR_RAW_OFF_POS, out.position() - start);
// Write the schema.
- int offsetByteCnt = schema.write(this, fieldCnt, useCompactFooter);
+ int offsetByteCnt = schema.write(out, fieldCnt, useCompactFooter);
if (offsetByteCnt == PortableUtils.OFFSET_1)
flags |= PortableUtils.FLAG_OFFSET_ONE_BYTE;
@@ -370,28 +322,25 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
// If there are no schema, we are free to write raw offset to schema offset.
flags |= PortableUtils.FLAG_HAS_RAW;
- out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, rawOffPos - start);
+ out.unsafeWriteInt(start + SCHEMA_OR_RAW_OFF_POS, rawOffPos - start);
}
else
- out.writeInt(start + SCHEMA_OR_RAW_OFF_POS, 0);
+ out.unsafeWriteInt(start + SCHEMA_OR_RAW_OFF_POS, 0);
}
// Write flags.
- out.writeShort(start + FLAGS_POS, flags);
+ out.unsafeWriteShort(start + FLAGS_POS, flags);
// Write length.
- out.writeInt(start + TOTAL_LEN_POS, out.position() - start);
+ out.unsafeWriteInt(start + TOTAL_LEN_POS, out.position() - start);
}
/**
* Pop schema.
*/
public void popSchema() {
- if (schema != null) {
- assert fieldCnt > 0;
-
+ if (fieldCnt > 0)
schema.pop(fieldCnt);
- }
}
/**
@@ -415,83 +364,29 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
- * @param val Value.
- */
- public void doWriteByte(byte val) {
- out.writeByte(val);
- }
-
- /**
- * @param val Value.
- */
- public void doWriteShort(short val) {
- out.writeShort(val);
- }
-
- /**
- * @param val Value.
- */
- public void doWriteInt(int val) {
- out.writeInt(val);
- }
-
- /**
- * @param val Value.
- */
- public void doWriteLong(long val) {
- out.writeLong(val);
- }
-
- /**
- * @param val Value.
- */
- public void doWriteFloat(float val) {
- out.writeFloat(val);
- }
-
- /**
- * @param val Value.
- */
- public void doWriteDouble(double val) {
- out.writeDouble(val);
- }
-
- /**
- * @param val Value.
- */
- public void doWriteChar(char val) {
- out.writeChar(val);
- }
-
- /**
- * @param val Value.
- */
- public void doWriteBoolean(boolean val) {
- out.writeBoolean(val);
- }
-
- /**
* @param val String value.
*/
public void doWriteDecimal(@Nullable BigDecimal val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- doWriteByte(DECIMAL);
+ out.unsafeEnsure(1 + 4 + 4);
+
+ out.unsafeWriteByte(DECIMAL);
BigInteger intVal = val.unscaledValue();
if (intVal.signum() == -1) {
intVal = intVal.negate();
- out.writeInt(val.scale() | 0x80000000);
+ out.unsafeWriteInt(val.scale() | 0x80000000);
}
else
- out.writeInt(val.scale());
+ out.unsafeWriteInt(val.scale());
byte[] vals = intVal.toByteArray();
- out.writeInt(vals.length);
+ out.unsafeWriteInt(vals.length);
out.writeByteArray(vals);
}
}
@@ -501,13 +396,13 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
public void doWriteString(@Nullable String val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- doWriteByte(STRING);
-
byte[] strArr = val.getBytes(UTF_8);
- doWriteInt(strArr.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(STRING);
+ out.unsafeWriteInt(strArr.length);
out.writeByteArray(strArr);
}
@@ -518,11 +413,12 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
public void doWriteUuid(@Nullable UUID uuid) {
if (uuid == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- doWriteByte(UUID);
- doWriteLong(uuid.getMostSignificantBits());
- doWriteLong(uuid.getLeastSignificantBits());
+ out.unsafeEnsure(1 + 8 + 8);
+ out.unsafeWriteByte(UUID);
+ out.unsafeWriteLong(uuid.getMostSignificantBits());
+ out.unsafeWriteLong(uuid.getLeastSignificantBits());
}
}
@@ -531,10 +427,11 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
public void doWriteDate(@Nullable Date date) {
if (date == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- doWriteByte(DATE);
- doWriteLong(date.getTime());
+ out.unsafeEnsure(1 + 8);
+ out.unsafeWriteByte(DATE);
+ out.unsafeWriteLong(date.getTime());
}
}
@@ -543,11 +440,12 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
public void doWriteTimestamp(@Nullable Timestamp ts) {
if (ts== null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- doWriteByte(TIMESTAMP);
- doWriteLong(ts.getTime());
- doWriteInt(ts.getNanos() % 1000000);
+ out.unsafeEnsure(1 + 8 + 4);
+ out.unsafeWriteByte(TIMESTAMP);
+ out.unsafeWriteLong(ts.getTime());
+ out.unsafeWriteInt(ts.getNanos() % 1000000);
}
}
@@ -559,9 +457,9 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
public void doWriteObject(@Nullable Object obj) throws BinaryObjectException {
if (obj == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, handles);
+ BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, schema, handles());
writer.marshal(obj);
}
@@ -572,13 +470,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteByteArray(@Nullable byte[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(BYTE_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(BYTE_ARR);
+ out.unsafeWriteInt(val.length);
out.writeByteArray(val);
}
@@ -589,13 +488,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteShortArray(@Nullable short[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(SHORT_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(SHORT_ARR);
+ out.unsafeWriteInt(val.length);
out.writeShortArray(val);
}
@@ -606,13 +506,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteIntArray(@Nullable int[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(INT_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(INT_ARR);
+ out.unsafeWriteInt(val.length);
out.writeIntArray(val);
}
@@ -623,13 +524,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteLongArray(@Nullable long[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(LONG_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(LONG_ARR);
+ out.unsafeWriteInt(val.length);
out.writeLongArray(val);
}
@@ -640,13 +542,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteFloatArray(@Nullable float[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(FLOAT_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(FLOAT_ARR);
+ out.unsafeWriteInt(val.length);
out.writeFloatArray(val);
}
@@ -657,13 +560,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteDoubleArray(@Nullable double[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(DOUBLE_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(DOUBLE_ARR);
+ out.unsafeWriteInt(val.length);
out.writeDoubleArray(val);
}
@@ -674,13 +578,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteCharArray(@Nullable char[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(CHAR_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(CHAR_ARR);
+ out.unsafeWriteInt(val.length);
out.writeCharArray(val);
}
@@ -691,13 +596,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteBooleanArray(@Nullable boolean[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(BOOLEAN_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(BOOLEAN_ARR);
+ out.unsafeWriteInt(val.length);
out.writeBooleanArray(val);
}
@@ -708,13 +614,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteDecimalArray(@Nullable BigDecimal[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(DECIMAL_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(DECIMAL_ARR);
+ out.unsafeWriteInt(val.length);
for (BigDecimal str : val)
doWriteDecimal(str);
@@ -726,13 +633,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteStringArray(@Nullable String[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(STRING_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(STRING_ARR);
+ out.unsafeWriteInt(val.length);
for (String str : val)
doWriteString(str);
@@ -744,13 +652,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteUuidArray(@Nullable UUID[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(UUID_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(UUID_ARR);
+ out.unsafeWriteInt(val.length);
for (UUID uuid : val)
doWriteUuid(uuid);
@@ -762,13 +671,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteDateArray(@Nullable Date[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(DATE_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(DATE_ARR);
+ out.unsafeWriteInt(val.length);
for (Date date : val)
doWriteDate(date);
@@ -780,13 +690,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteTimestampArray(@Nullable Timestamp[] val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
- doWriteByte(TIMESTAMP_ARR);
- doWriteInt(val.length);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(TIMESTAMP_ARR);
+ out.unsafeWriteInt(val.length);
for (Timestamp ts : val)
doWriteTimestamp(ts);
@@ -799,23 +710,25 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteObjectArray(@Nullable Object[] val) throws BinaryObjectException {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(val))
return;
PortableClassDescriptor desc = ctx.descriptorForClass(val.getClass().getComponentType());
- doWriteByte(OBJ_ARR);
+ out.unsafeEnsure(1 + 4);
+ out.unsafeWriteByte(OBJ_ARR);
if (desc.registered())
- doWriteInt(desc.typeId());
+ out.unsafeWriteInt(desc.typeId());
else {
- doWriteInt(UNREGISTERED_TYPE_ID);
+ out.unsafeWriteInt(UNREGISTERED_TYPE_ID);
+
doWriteString(val.getClass().getComponentType().getName());
}
- doWriteInt(val.length);
+ out.writeInt(val.length);
for (Object obj : val)
doWriteObject(obj);
@@ -828,14 +741,15 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteCollection(@Nullable Collection<?> col) throws BinaryObjectException {
if (col == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(col))
return;
- doWriteByte(COL);
- doWriteInt(col.size());
- doWriteByte(ctx.collectionType(col.getClass()));
+ out.unsafeEnsure(1 + 4 + 1);
+ out.unsafeWriteByte(COL);
+ out.unsafeWriteInt(col.size());
+ out.unsafeWriteByte(ctx.collectionType(col.getClass()));
for (Object obj : col)
doWriteObject(obj);
@@ -848,14 +762,15 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteMap(@Nullable Map<?, ?> map) throws BinaryObjectException {
if (map == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(map))
return;
- doWriteByte(MAP);
- doWriteInt(map.size());
- doWriteByte(ctx.mapType(map.getClass()));
+ out.unsafeEnsure(1 + 4 + 1);
+ out.unsafeWriteByte(MAP);
+ out.unsafeWriteInt(map.size());
+ out.unsafeWriteByte(ctx.mapType(map.getClass()));
for (Map.Entry<?, ?> e : map.entrySet()) {
doWriteObject(e.getKey());
@@ -870,12 +785,12 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteMapEntry(@Nullable Map.Entry<?, ?> e) throws BinaryObjectException {
if (e == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
if (tryWriteAsHandle(e))
return;
- doWriteByte(MAP_ENTRY);
+ out.writeByte(MAP_ENTRY);
doWriteObject(e.getKey());
doWriteObject(e.getValue());
}
@@ -886,20 +801,22 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteEnum(@Nullable Enum<?> val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
PortableClassDescriptor desc = ctx.descriptorForClass(val.getClass());
- doWriteByte(ENUM);
+ out.unsafeEnsure(1 + 4);
+
+ out.unsafeWriteByte(ENUM);
if (desc.registered())
- doWriteInt(desc.typeId());
+ out.unsafeWriteInt(desc.typeId());
else {
- doWriteInt(UNREGISTERED_TYPE_ID);
+ out.unsafeWriteInt(UNREGISTERED_TYPE_ID);
doWriteString(val.getClass().getName());
}
- doWriteInt(val.ordinal());
+ out.writeInt(val.ordinal());
}
}
@@ -910,19 +827,23 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
assert val == null || val.getClass().getComponentType().isEnum();
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
PortableClassDescriptor desc = ctx.descriptorForClass(val.getClass().getComponentType());
- doWriteByte(ENUM_ARR);
+
+ out.unsafeEnsure(1 + 4);
+
+ out.unsafeWriteByte(ENUM_ARR);
if (desc.registered())
- doWriteInt(desc.typeId());
+ out.unsafeWriteInt(desc.typeId());
else {
- doWriteInt(UNREGISTERED_TYPE_ID);
+ out.unsafeWriteInt(UNREGISTERED_TYPE_ID);
+
doWriteString(val.getClass().getComponentType().getName());
}
- doWriteInt(val.length);
+ out.writeInt(val.length);
// TODO: Denis: Redundant data for each element of the array.
for (Object o : val)
@@ -935,16 +856,19 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void doWriteClass(@Nullable Class val) {
if (val == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
PortableClassDescriptor desc = ctx.descriptorForClass(val);
- doWriteByte(CLASS);
+ out.unsafeEnsure(1 + 4);
+
+ out.unsafeWriteByte(CLASS);
if (desc.registered())
- doWriteInt(desc.typeId());
+ out.unsafeWriteInt(desc.typeId());
else {
- doWriteInt(UNREGISTERED_TYPE_ID);
+ out.unsafeWriteInt(UNREGISTERED_TYPE_ID);
+
doWriteString(val.getClass().getName());
}
}
@@ -955,30 +879,37 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
public void doWritePortableObject(@Nullable BinaryObjectImpl po) {
if (po == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- doWriteByte(PORTABLE_OBJ);
-
byte[] poArr = po.array();
- doWriteInt(poArr.length);
+ out.unsafeEnsure(1 + 4 + poArr.length + 4);
+ out.unsafeWriteByte(PORTABLE_OBJ);
+ out.unsafeWriteInt(poArr.length);
out.writeByteArray(poArr);
-
- doWriteInt(po.start());
+ out.unsafeWriteInt(po.start());
}
}
/**
* @param val Value.
*/
+ void writeByteFieldPrimitive(byte val) {
+ out.unsafeEnsure(1 + 1);
+
+ out.unsafeWriteByte(BYTE);
+ out.unsafeWriteByte(val);
+ }
+
+ /**
+ * @param val Value.
+ */
void writeByteField(@Nullable Byte val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(BYTE);
- doWriteByte(val);
- }
+ out.writeByte(NULL);
+ else
+ writeByteFieldPrimitive(val);
}
/**
@@ -991,13 +922,31 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/**
* @param val Value.
*/
+ void writeShortFieldPrimitive(short val) {
+ out.unsafeEnsure(1 + 2);
+
+ out.unsafeWriteByte(SHORT);
+ out.unsafeWriteShort(val);
+ }
+
+ /**
+ * @param val Value.
+ */
void writeShortField(@Nullable Short val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(SHORT);
- doWriteShort(val);
- }
+ out.writeByte(NULL);
+ else
+ writeShortFieldPrimitive(val);
+ }
+
+ /**
+ * @param val Value.
+ */
+ void writeIntFieldPrimitive(int val) {
+ out.unsafeEnsure(1 + 4);
+
+ out.unsafeWriteByte(INT);
+ out.unsafeWriteInt(val);
}
/**
@@ -1005,11 +954,19 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void writeIntField(@Nullable Integer val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(INT);
- doWriteInt(val);
- }
+ out.writeByte(NULL);
+ else
+ writeIntFieldPrimitive(val);
+ }
+
+ /**
+ * @param val Value.
+ */
+ void writeLongFieldPrimitive(long val) {
+ out.unsafeEnsure(1 + 8);
+
+ out.unsafeWriteByte(LONG);
+ out.unsafeWriteLong(val);
}
/**
@@ -1017,11 +974,19 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void writeLongField(@Nullable Long val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(LONG);
- doWriteLong(val);
- }
+ out.writeByte(NULL);
+ else
+ writeLongFieldPrimitive(val);
+ }
+
+ /**
+ * @param val Value.
+ */
+ void writeFloatFieldPrimitive(float val) {
+ out.unsafeEnsure(1 + 4);
+
+ out.unsafeWriteByte(FLOAT);
+ out.unsafeWriteFloat(val);
}
/**
@@ -1029,11 +994,19 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void writeFloatField(@Nullable Float val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(FLOAT);
- doWriteFloat(val);
- }
+ out.writeByte(NULL);
+ else
+ writeFloatFieldPrimitive(val);
+ }
+
+ /**
+ * @param val Value.
+ */
+ void writeDoubleFieldPrimitive(double val) {
+ out.unsafeEnsure(1 + 8);
+
+ out.unsafeWriteByte(DOUBLE);
+ out.unsafeWriteDouble(val);
}
/**
@@ -1041,11 +1014,19 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void writeDoubleField(@Nullable Double val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(DOUBLE);
- doWriteDouble(val);
- }
+ out.writeByte(NULL);
+ else
+ writeDoubleFieldPrimitive(val);
+ }
+
+ /**
+ * @param val Value.
+ */
+ void writeCharFieldPrimitive(char val) {
+ out.unsafeEnsure(1 + 2);
+
+ out.unsafeWriteByte(CHAR);
+ out.unsafeWriteChar(val);
}
/**
@@ -1053,11 +1034,19 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void writeCharField(@Nullable Character val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(CHAR);
- doWriteChar(val);
- }
+ out.writeByte(NULL);
+ else
+ writeCharFieldPrimitive(val);
+ }
+
+ /**
+ * @param val Value.
+ */
+ void writeBooleanFieldPrimitive(boolean val) {
+ out.unsafeEnsure(1 + 1);
+
+ out.unsafeWriteByte(BOOLEAN);
+ out.unsafeWriteBoolean(val);
}
/**
@@ -1065,11 +1054,9 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
*/
void writeBooleanField(@Nullable Boolean val) {
if (val == null)
- doWriteByte(NULL);
- else {
- doWriteByte(BOOLEAN);
- doWriteBoolean(val);
- }
+ out.writeByte(NULL);
+ else
+ writeBooleanFieldPrimitive(val);
}
/**
@@ -1262,95 +1249,95 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeByte(String fieldName, byte val) throws BinaryObjectException {
- writeFieldId(fieldName, BYTE);
+ writeFieldId(fieldName);
writeByteField(val);
}
/** {@inheritDoc} */
@Override public void writeByte(byte val) throws BinaryObjectException {
- doWriteByte(val);
+ out.writeByte(val);
}
/** {@inheritDoc} */
@Override public void writeShort(String fieldName, short val) throws BinaryObjectException {
- writeFieldId(fieldName, SHORT);
+ writeFieldId(fieldName);
writeShortField(val);
}
/** {@inheritDoc} */
@Override public void writeShort(short val) throws BinaryObjectException {
- doWriteShort(val);
+ out.writeShort(val);
}
/** {@inheritDoc} */
@Override public void writeInt(String fieldName, int val) throws BinaryObjectException {
- writeFieldId(fieldName, INT);
+ writeFieldId(fieldName);
writeIntField(val);
}
/** {@inheritDoc} */
@Override public void writeInt(int val) throws BinaryObjectException {
- doWriteInt(val);
+ out.writeInt(val);
}
/** {@inheritDoc} */
@Override public void writeLong(String fieldName, long val) throws BinaryObjectException {
- writeFieldId(fieldName, LONG);
+ writeFieldId(fieldName);
writeLongField(val);
}
/** {@inheritDoc} */
@Override public void writeLong(long val) throws BinaryObjectException {
- doWriteLong(val);
+ out.writeLong(val);
}
/** {@inheritDoc} */
@Override public void writeFloat(String fieldName, float val) throws BinaryObjectException {
- writeFieldId(fieldName, FLOAT);
+ writeFieldId(fieldName);
writeFloatField(val);
}
/** {@inheritDoc} */
@Override public void writeFloat(float val) throws BinaryObjectException {
- doWriteFloat(val);
+ out.writeFloat(val);
}
/** {@inheritDoc} */
@Override public void writeDouble(String fieldName, double val) throws BinaryObjectException {
- writeFieldId(fieldName, DOUBLE);
+ writeFieldId(fieldName);
writeDoubleField(val);
}
/** {@inheritDoc} */
@Override public void writeDouble(double val) throws BinaryObjectException {
- doWriteDouble(val);
+ out.writeDouble(val);
}
/** {@inheritDoc} */
@Override public void writeChar(String fieldName, char val) throws BinaryObjectException {
- writeFieldId(fieldName, CHAR);
+ writeFieldId(fieldName);
writeCharField(val);
}
/** {@inheritDoc} */
@Override public void writeChar(char val) throws BinaryObjectException {
- doWriteChar(val);
+ out.writeChar(val);
}
/** {@inheritDoc} */
@Override public void writeBoolean(String fieldName, boolean val) throws BinaryObjectException {
- writeFieldId(fieldName, BOOLEAN);
+ writeFieldId(fieldName);
writeBooleanField(val);
}
/** {@inheritDoc} */
@Override public void writeBoolean(boolean val) throws BinaryObjectException {
- doWriteBoolean(val);
+ out.writeBoolean(val);
}
/** {@inheritDoc} */
@Override public void writeDecimal(String fieldName, @Nullable BigDecimal val) throws BinaryObjectException {
- writeFieldId(fieldName, DECIMAL);
+ writeFieldId(fieldName);
writeDecimalField(val);
}
@@ -1361,7 +1348,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeString(String fieldName, @Nullable String val) throws BinaryObjectException {
- writeFieldId(fieldName, STRING);
+ writeFieldId(fieldName);
writeStringField(val);
}
@@ -1372,7 +1359,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeUuid(String fieldName, @Nullable UUID val) throws BinaryObjectException {
- writeFieldId(fieldName, UUID);
+ writeFieldId(fieldName);
writeUuidField(val);
}
@@ -1383,7 +1370,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeDate(String fieldName, @Nullable Date val) throws BinaryObjectException {
- writeFieldId(fieldName, DATE);
+ writeFieldId(fieldName);
writeDateField(val);
}
@@ -1394,7 +1381,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws BinaryObjectException {
- writeFieldId(fieldName, TIMESTAMP);
+ writeFieldId(fieldName);
writeTimestampField(val);
}
@@ -1405,7 +1392,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeObject(String fieldName, @Nullable Object obj) throws BinaryObjectException {
- writeFieldId(fieldName, OBJ);
+ writeFieldId(fieldName);
writeObjectField(obj);
}
@@ -1417,9 +1404,9 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeObjectDetached(@Nullable Object obj) throws BinaryObjectException {
if (obj == null)
- doWriteByte(NULL);
+ out.writeByte(NULL);
else {
- BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, new IdentityHashMap<Object, Integer>());
+ BinaryWriterExImpl writer = new BinaryWriterExImpl(ctx, out, schema, null);
writer.marshal(obj);
}
@@ -1427,7 +1414,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeByteArray(String fieldName, @Nullable byte[] val) throws BinaryObjectException {
- writeFieldId(fieldName, BYTE_ARR);
+ writeFieldId(fieldName);
writeByteArrayField(val);
}
@@ -1438,7 +1425,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeShortArray(String fieldName, @Nullable short[] val) throws BinaryObjectException {
- writeFieldId(fieldName, SHORT_ARR);
+ writeFieldId(fieldName);
writeShortArrayField(val);
}
@@ -1449,7 +1436,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeIntArray(String fieldName, @Nullable int[] val) throws BinaryObjectException {
- writeFieldId(fieldName, INT_ARR);
+ writeFieldId(fieldName);
writeIntArrayField(val);
}
@@ -1460,7 +1447,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeLongArray(String fieldName, @Nullable long[] val) throws BinaryObjectException {
- writeFieldId(fieldName, LONG_ARR);
+ writeFieldId(fieldName);
writeLongArrayField(val);
}
@@ -1471,7 +1458,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeFloatArray(String fieldName, @Nullable float[] val) throws BinaryObjectException {
- writeFieldId(fieldName, FLOAT_ARR);
+ writeFieldId(fieldName);
writeFloatArrayField(val);
}
@@ -1483,7 +1470,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeDoubleArray(String fieldName, @Nullable double[] val)
throws BinaryObjectException {
- writeFieldId(fieldName, DOUBLE_ARR);
+ writeFieldId(fieldName);
writeDoubleArrayField(val);
}
@@ -1494,7 +1481,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeCharArray(String fieldName, @Nullable char[] val) throws BinaryObjectException {
- writeFieldId(fieldName, CHAR_ARR);
+ writeFieldId(fieldName);
writeCharArrayField(val);
}
@@ -1506,7 +1493,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeBooleanArray(String fieldName, @Nullable boolean[] val)
throws BinaryObjectException {
- writeFieldId(fieldName, BOOLEAN_ARR);
+ writeFieldId(fieldName);
writeBooleanArrayField(val);
}
@@ -1518,7 +1505,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeDecimalArray(String fieldName, @Nullable BigDecimal[] val)
throws BinaryObjectException {
- writeFieldId(fieldName, DECIMAL_ARR);
+ writeFieldId(fieldName);
writeDecimalArrayField(val);
}
@@ -1530,7 +1517,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeStringArray(String fieldName, @Nullable String[] val)
throws BinaryObjectException {
- writeFieldId(fieldName, STRING_ARR);
+ writeFieldId(fieldName);
writeStringArrayField(val);
}
@@ -1541,7 +1528,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeUuidArray(String fieldName, @Nullable UUID[] val) throws BinaryObjectException {
- writeFieldId(fieldName, UUID_ARR);
+ writeFieldId(fieldName);
writeUuidArrayField(val);
}
@@ -1552,7 +1539,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeDateArray(String fieldName, @Nullable Date[] val) throws BinaryObjectException {
- writeFieldId(fieldName, DATE_ARR);
+ writeFieldId(fieldName);
writeDateArrayField(val);
}
@@ -1563,7 +1550,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws BinaryObjectException {
- writeFieldId(fieldName, TIMESTAMP_ARR);
+ writeFieldId(fieldName);
writeTimestampArrayField(val);
}
@@ -1574,7 +1561,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws BinaryObjectException {
- writeFieldId(fieldName, OBJ_ARR);
+ writeFieldId(fieldName);
writeObjectArrayField(val);
}
@@ -1586,7 +1573,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public <T> void writeCollection(String fieldName, @Nullable Collection<T> col)
throws BinaryObjectException {
- writeFieldId(fieldName, COL);
+ writeFieldId(fieldName);
writeCollectionField(col);
}
@@ -1598,7 +1585,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public <K, V> void writeMap(String fieldName, @Nullable Map<K, V> map)
throws BinaryObjectException {
- writeFieldId(fieldName, MAP);
+ writeFieldId(fieldName);
writeMapField(map);
}
@@ -1609,7 +1596,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public <T extends Enum<?>> void writeEnum(String fieldName, T val) throws BinaryObjectException {
- writeFieldId(fieldName, ENUM);
+ writeFieldId(fieldName);
writeEnumField(val);
}
@@ -1620,7 +1607,7 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public <T extends Enum<?>> void writeEnumArray(String fieldName, T[] val) throws BinaryObjectException {
- writeFieldId(fieldName, ENUM_ARR);
+ writeFieldId(fieldName);
writeEnumArrayField(val);
}
@@ -1672,22 +1659,22 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** {@inheritDoc} */
@Override public void writeByte(int v) throws IOException {
- doWriteByte((byte) v);
+ out.writeByte((byte) v);
}
/** {@inheritDoc} */
@Override public void writeShort(int v) throws IOException {
- doWriteShort((short) v);
+ out.writeShort((short) v);
}
/** {@inheritDoc} */
@Override public void writeChar(int v) throws IOException {
- doWriteChar((char) v);
+ out.writeChar((char) v);
}
/** {@inheritDoc} */
@Override public void write(int b) throws IOException {
- doWriteByte((byte) b);
+ out.writeByte((byte) b);
}
/** {@inheritDoc} */
@@ -1709,12 +1696,11 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
* @param fieldName Field name.
* @throws org.apache.ignite.binary.BinaryObjectException If fields are not allowed.
*/
- private void writeFieldId(String fieldName, byte fieldType) throws BinaryObjectException {
+ private void writeFieldId(String fieldName) throws BinaryObjectException {
A.notNull(fieldName, "fieldName");
if (rawOffPos != 0)
- throw new BinaryObjectException("Individual field can't be written after raw writer is acquired " +
- "via rawWriter() method. Consider fixing serialization logic for class: " + cls.getName());
+ throw new BinaryObjectException("Individual field can't be written after raw writer is acquired.");
if (idMapper == null)
idMapper = ctx.userTypeIdMapper(typeId);
@@ -1722,9 +1708,6 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
int id = idMapper.fieldId(typeId, fieldName);
writeFieldId(id);
-
- if (metaEnabled)
- metaHashSum = 31 * metaHashSum + (id + fieldType);
}
/**
@@ -1734,17 +1717,22 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
public void writeFieldId(int fieldId) {
int fieldOff = out.position() - start;
- if (schema == null) {
- schema = SCHEMA.get();
+ // Advance schema hash.
+ schemaId = PortableUtils.updateSchemaId(schemaId, fieldId);
- if (schema == null) {
- schema = new SchemaHolder();
+ schema.push(fieldId, fieldOff);
- SCHEMA.set(schema);
- }
- }
+ fieldCnt++;
+ }
- schemaId = PortableUtils.updateSchemaId(schemaId, fieldId);
+ /**
+ * Write field ID without schema ID update. This method should be used when schema ID is stable because class
+ * is seializable.
+ *
+ * @param fieldId Field ID.
+ */
+ public void writeFieldIdNoSchemaUpdate(int fieldId) {
+ int fieldOff = out.position() - start;
schema.push(fieldId, fieldOff);
@@ -1752,7 +1740,14 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
- * @return Current schema ID.
+ * @param schemaId Schema ID.
+ */
+ public void schemaId(int schemaId) {
+ this.schemaId = schemaId;
+ }
+
+ /**
+ * @return Schema ID.
*/
public int schemaId() {
return schemaId;
@@ -1771,22 +1766,43 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
+ * Get current handles. If they are {@code null}, then we should create them. Otherwise we will not see updates
+ * performed by child writers.
+ *
+ * @return Handles.
+ */
+ private BinaryWriterHandles handles() {
+ if (handles == null)
+ handles = new BinaryWriterHandles();
+
+ return handles;
+ }
+
+ /**
* Attempts to write the object as a handle.
*
* @param obj Object to write.
* @return {@code true} if the object has been written as a handle.
*/
boolean tryWriteAsHandle(Object obj) {
- int handle = handle(obj);
+ assert obj != null;
- if (handle >= 0) {
- doWriteByte(GridPortableMarshaller.HANDLE);
- doWriteInt(handle);
+ int pos = out.position();
+
+ BinaryWriterHandles handles0 = handles();
+
+ int old = handles0.put(obj, pos);
+
+ if (old == BinaryWriterHandles.POS_NULL)
+ return false;
+ else {
+ out.unsafeEnsure(1 + 4);
+
+ out.unsafeWriteByte(GridPortableMarshaller.HANDLE);
+ out.unsafeWriteInt(pos - old);
return true;
}
-
- return false;
}
/**
@@ -1796,9 +1812,9 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
* @return New writer.
*/
public BinaryWriterExImpl newWriter(int typeId) {
- BinaryWriterExImpl res = new BinaryWriterExImpl(ctx, out, handles);
+ BinaryWriterExImpl res = new BinaryWriterExImpl(ctx, out, schema, handles());
- res.typeId = typeId;
+ res.typeId(typeId);
return res;
}
@@ -1809,138 +1825,4 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
public PortableContext context() {
return ctx;
}
-
- /**
- * Schema holder.
- */
- private static class SchemaHolder {
- /** Grow step. */
- private static final int GROW_STEP = 64;
-
- /** Maximum stable size. */
- private static final int MAX_SIZE = 1024;
-
- /** Data. */
- private int[] data;
-
- /** Index. */
- private int idx;
-
- /**
- * Constructor.
- */
- public SchemaHolder() {
- data = new int[GROW_STEP];
- }
-
- /**
- * Push another frame.
- *
- * @param id Field ID.
- * @param off Field offset.
- */
- public void push(int id, int off) {
- if (idx == data.length) {
- int[] data0 = new int[data.length + GROW_STEP];
-
- System.arraycopy(data, 0, data0, 0, data.length);
-
- data = data0;
- }
-
- data[idx] = id;
- data[idx + 1] = off;
-
- idx += 2;
- }
-
- /**
- * Build the schema.
- *
- * @param builder Builder.
- * @param fieldCnt Fields count.
- */
- public void build(PortableSchema.Builder builder, int fieldCnt) {
- for (int curIdx = idx - fieldCnt * 2; curIdx < idx; curIdx += 2)
- builder.addField(data[curIdx]);
- }
-
- /**
- * Write collected frames and pop them.
- *
- * @param writer Writer.
- * @param fieldCnt Count.
- * @param compactFooter Whether footer should be written in compact form.
- * @return Amount of bytes dedicated to each field offset. Could be 1, 2 or 4.
- */
- public int write(BinaryWriterExImpl writer, int fieldCnt, boolean compactFooter) {
- int startIdx = idx - fieldCnt * 2;
-
- assert startIdx >= 0;
-
- int lastOffset = data[idx - 1];
-
- int res;
-
- if (compactFooter) {
- if (lastOffset < MAX_OFFSET_1) {
- for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
- writer.writeByte((byte)data[curIdx]);
-
- res = PortableUtils.OFFSET_1;
- }
- else if (lastOffset < MAX_OFFSET_2) {
- for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
- writer.writeShort((short)data[curIdx]);
-
- res = PortableUtils.OFFSET_2;
- }
- else {
- for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
- writer.writeInt(data[curIdx]);
-
- res = PortableUtils.OFFSET_4;
- }
- }
- else {
- if (lastOffset < MAX_OFFSET_1) {
- for (int curIdx = startIdx; curIdx < idx;) {
- writer.writeInt(data[curIdx++]);
- writer.writeByte((byte) data[curIdx++]);
- }
-
- res = PortableUtils.OFFSET_1;
- }
- else if (lastOffset < MAX_OFFSET_2) {
- for (int curIdx = startIdx; curIdx < idx;) {
- writer.writeInt(data[curIdx++]);
- writer.writeShort((short)data[curIdx++]);
- }
-
- res = PortableUtils.OFFSET_2;
- }
- else {
- for (int curIdx = startIdx; curIdx < idx;) {
- writer.writeInt(data[curIdx++]);
- writer.writeInt(data[curIdx++]);
- }
-
- res = PortableUtils.OFFSET_4;
- }
- }
-
- return res;
- }
-
- /**
- * Pop current object's frame.
- */
- public void pop(int fieldCnt) {
- idx = idx - fieldCnt * 2;
-
- // Shrink data array if needed.
- if (idx == 0 && data.length > MAX_SIZE)
- data = new int[MAX_SIZE];
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterHandles.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterHandles.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterHandles.java
new file mode 100644
index 0000000..2a47a2b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterHandles.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import java.util.IdentityHashMap;
+
+/**
+ * Writer handles. Aimed to delay hash map allocation for some time until it is clearly evident that it is needed.
+ */
+public class BinaryWriterHandles {
+ /** Value denoting null position. */
+ public static final int POS_NULL = -1;
+
+ /** Mode: empty. */
+ private static final int MODE_EMPTY = 0;
+
+ /** Mode: single object. */
+ private static final int MODE_SINGLE = 1;
+
+ /** Mode: multiple objects. */
+ private static final int MODE_MULTIPLE = 2;
+
+ /** Data. This is either an object or a map. */
+ private Object data;
+
+ /** Position. */
+ private int singlePos;
+
+ /** Mode. */
+ private int mode = MODE_EMPTY;
+
+ /**
+ * Put object to registry and return previous position (if any).
+ *
+ * @param obj Object.
+ * @param pos Position.
+ * @return Old position.
+ */
+ @SuppressWarnings("unchecked")
+ public int put(Object obj, int pos) {
+ assert obj != null;
+ assert pos >= 0;
+
+ switch (mode) {
+ case MODE_EMPTY:
+ this.data = obj;
+ this.singlePos = pos;
+ this.mode = MODE_SINGLE;
+
+ return POS_NULL;
+
+ case MODE_SINGLE:
+ if (this.data == obj)
+ return singlePos;
+ else {
+ IdentityHashMap<Object, Integer> newData = new IdentityHashMap<>(2);
+
+ newData.put(data, singlePos);
+ newData.put(obj, pos);
+
+ this.data = newData;
+ this.singlePos = -1;
+ this.mode = MODE_MULTIPLE;
+
+ return POS_NULL;
+ }
+
+ default:
+ assert mode == MODE_MULTIPLE;
+
+ IdentityHashMap<Object, Integer> data0 = (IdentityHashMap<Object, Integer>)data;
+
+ Integer oldPos = data0.put(obj, pos);
+
+ if (oldPos != null) {
+ // Restore initial position and return it.
+ data0.put(obj, oldPos);
+
+ return oldPos;
+ }
+ else
+ return POS_NULL;
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterSchemaHolder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterSchemaHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterSchemaHolder.java
new file mode 100644
index 0000000..c7400d0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryWriterSchemaHolder.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.internal.portable.streams.PortableOutputStream;
+
+/**
+ * Binary writer schema holder.
+ */
+public class BinaryWriterSchemaHolder {
+ /** Maximum offset which fits in 1 byte. */
+ private static final int MAX_OFFSET_1 = 1 << 8;
+
+ /** Maximum offset which fits in 2 bytes. */
+ private static final int MAX_OFFSET_2 = 1 << 16;
+
+ /** Grow step. */
+ private static final int GROW_STEP = 64;
+
+ /** Data. */
+ private int[] data = new int[GROW_STEP];
+
+ /** Index. */
+ private int idx;
+
+ /**
+ * Push another frame.
+ *
+ * @param id Field ID.
+ * @param off Field offset.
+ */
+ public void push(int id, int off) {
+ if (idx == data.length) {
+ int[] data0 = new int[data.length + GROW_STEP];
+
+ System.arraycopy(data, 0, data0, 0, data.length);
+
+ data = data0;
+ }
+
+ data[idx] = id;
+ data[idx + 1] = off;
+
+ idx += 2;
+ }
+
+ /**
+ * Build the schema.
+ *
+ * @param builder Builder.
+ * @param fieldCnt Fields count.
+ */
+ public void build(PortableSchema.Builder builder, int fieldCnt) {
+ for (int curIdx = idx - fieldCnt * 2; curIdx < idx; curIdx += 2)
+ builder.addField(data[curIdx]);
+ }
+
+ /**
+ * Write collected frames and pop them.
+ *
+ * @param out Output stream.
+ * @param fieldCnt Count.
+ * @param compactFooter Whether footer should be written in compact form.
+ * @return Amount of bytes dedicated to each field offset. Could be 1, 2 or 4.
+ */
+ public int write(PortableOutputStream out, int fieldCnt, boolean compactFooter) {
+ int startIdx = idx - fieldCnt * 2;
+ assert startIdx >= 0;
+
+ // Ensure there are at least 8 bytes for each field to allow for unsafe writes.
+ out.unsafeEnsure(fieldCnt << 3);
+
+ int lastOffset = data[idx - 1];
+
+ int res;
+
+ if (compactFooter) {
+ if (lastOffset < MAX_OFFSET_1) {
+ for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
+ out.unsafeWriteByte((byte)data[curIdx]);
+
+ res = PortableUtils.OFFSET_1;
+ }
+ else if (lastOffset < MAX_OFFSET_2) {
+ for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
+ out.unsafeWriteShort((short) data[curIdx]);
+
+ res = PortableUtils.OFFSET_2;
+ }
+ else {
+ for (int curIdx = startIdx + 1; curIdx < idx; curIdx += 2)
+ out.unsafeWriteInt(data[curIdx]);
+
+ res = PortableUtils.OFFSET_4;
+ }
+ }
+ else {
+ if (lastOffset < MAX_OFFSET_1) {
+ for (int curIdx = startIdx; curIdx < idx;) {
+ out.unsafeWriteInt(data[curIdx++]);
+ out.unsafeWriteByte((byte) data[curIdx++]);
+ }
+
+ res = PortableUtils.OFFSET_1;
+ }
+ else if (lastOffset < MAX_OFFSET_2) {
+ for (int curIdx = startIdx; curIdx < idx;) {
+ out.unsafeWriteInt(data[curIdx++]);
+ out.unsafeWriteShort((short) data[curIdx++]);
+ }
+
+ res = PortableUtils.OFFSET_2;
+ }
+ else {
+ for (int curIdx = startIdx; curIdx < idx;) {
+ out.unsafeWriteInt(data[curIdx++]);
+ out.unsafeWriteInt(data[curIdx++]);
+ }
+
+ res = PortableUtils.OFFSET_4;
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Pop current object's frame.
+ */
+ public void pop(int fieldCnt) {
+ idx = idx - fieldCnt * 2;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4a1af37e/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index 056a7c7..9c61ef2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
import org.apache.ignite.internal.portable.streams.PortableInputStream;
import org.apache.ignite.internal.portable.streams.PortableOutputStream;
import org.apache.ignite.binary.BinaryObjectException;
@@ -254,7 +255,8 @@ public class GridPortableMarshaller {
@Nullable public <T> T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws BinaryObjectException {
assert bytes != null;
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, bytes, 0, clsLdr);
+ BinaryReaderExImpl reader =
+ new BinaryReaderExImpl(ctx, PortableHeapInputStream.create(bytes, 0), clsLdr, new BinaryReaderHandles());
return (T)reader.unmarshal();
}
@@ -283,7 +285,8 @@ public class GridPortableMarshaller {
if (arr[0] == NULL)
return null;
- BinaryReaderExImpl reader = new BinaryReaderExImpl(ctx, arr, 0, ldr);
+ BinaryReaderExImpl reader =
+ new BinaryReaderExImpl(ctx, PortableHeapInputStream.create(arr, 0), ldr, new BinaryReaderHandles());
return (T)reader.deserialize();
}
@@ -295,7 +298,7 @@ public class GridPortableMarshaller {
* @return Writer.
*/
public BinaryWriterExImpl writer(PortableOutputStream out) {
- return new BinaryWriterExImpl(ctx, out);
+ return new BinaryWriterExImpl(ctx, out, BinaryThreadLocalContext.get().schemaHolder(), null);
}
/**
@@ -306,7 +309,7 @@ public class GridPortableMarshaller {
*/
public BinaryReaderExImpl reader(PortableInputStream in) {
// TODO: IGNITE-1272 - Is class loader needed here?
- return new BinaryReaderExImpl(ctx, in, in.position(), null);
+ return new BinaryReaderExImpl(ctx, in, null, new BinaryReaderHandles());
}
/**
[14/55] [abbrv] ignite git commit: IGNITE-1816: Implemented compact
footers.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
deleted file mode 100644
index 9225b97..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.binary.BinaryField;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.IgniteUtils;
-import org.apache.ignite.marshaller.MarshallerContextTestImpl;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import java.util.Arrays;
-
-/**
- * Contains tests for compact offsets.
- */
-public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonAbstractTest {
- /** 2 pow 8. */
- private static int POW_8 = 1 << 8;
-
- /** 2 pow 16. */
- private static int POW_16 = 1 << 16;
-
- /** Marshaller. */
- protected PortableMarshaller marsh;
-
- /** Portable context. */
- protected PortableContext ctx;
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- super.beforeTest();
-
- ctx = new PortableContext(new TestCachingMetadataHandler(), new IgniteConfiguration());
-
- marsh = new PortableMarshaller();
-
- marsh.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
- marsh.setContext(new MarshallerContextTestImpl(null));
-
- IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", ctx);
- }
-
- /**
- * Test 1 byte.
- *
- * @throws Exception If failed.
- */
- public void test1Byte() throws Exception {
- check(POW_8 >> 2);
- }
-
- /**
- * Test 1 byte with sign altering.
- *
- * @throws Exception If failed.
- */
- public void test1ByteSign() throws Exception {
- check(POW_8 >> 1);
- }
-
- /**
- * Test 2 bytes.
- *
- * @throws Exception If failed.
- */
- public void test2Bytes() throws Exception {
- check(POW_16 >> 2);
- }
-
- /**
- * Test 2 bytes with sign altering.
- *
- * @throws Exception If failed.
- */
- public void test2BytesSign() throws Exception {
- check(POW_16 >> 1);
- }
-
- /**
- * Test 4 bytes.
- *
- * @throws Exception If failed.
- */
- public void test4Bytes() throws Exception {
- check(POW_16 << 2);
- }
-
- /**
- * Main check routine.
- *
- * @param len Length of the first field.
- *
- * @throws Exception If failed.
- */
- private void check(int len) throws Exception {
- TestObject obj = new TestObject(len);
-
- BinaryObjectEx portObj = toPortable(marsh, obj);
-
- // 1. Test portable object content.
- assert portObj.hasField("field1");
- assert portObj.hasField("field2");
-
- byte[] field1 = portObj.field("field1");
- Integer field2 = portObj.field("field2");
-
- assert field1 != null;
- assert field2 != null;
-
- assert Arrays.equals(obj.field1, field1);
- assert obj.field2 == field2;
-
- // 2. Test fields API.
- BinaryField field1Desc = portObj.type().field("field1");
- BinaryField field2Desc = portObj.type().field("field2");
-
- assert field1Desc.exists(portObj);
- assert field2Desc.exists(portObj);
-
- assert Arrays.equals(obj.field1, (byte[])field1Desc.value(portObj));
- assert obj.field2 == (Integer)field2Desc.value(portObj);
-
- // 3. Test deserialize.
- TestObject objRestored = portObj.deserialize();
-
- assert objRestored != null;
-
- assert Arrays.equals(obj.field1, objRestored.field1);
- assert obj.field2 == objRestored.field2;
- }
-
- /**
- * Convert object to portable object.
- *
- * @param marsh Marshaller.
- * @param obj Object.
- * @return Portable object.
- * @throws Exception If failed.
- */
- protected abstract BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception;
-
- /**
- * Test object.
- */
- public static class TestObject {
- /** First field with variable length. */
- public byte[] field1;
-
- /** Second field. */
- public int field2;
-
- /**
- * Default constructor.
- */
- public TestObject() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param len Array length.
- */
- public TestObject(int len) {
- field1 = new byte[len];
-
- field1[0] = 1;
- field1[len - 1] = 2;
-
- field2 = len;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java
deleted file mode 100644
index ebdef38..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsHeapSelfTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-
-/**
- * Compact offsets tests for heap portable objects.
- */
-public class PortableCompactOffsetsHeapSelfTest extends PortableCompactOffsetsAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
- byte[] bytes = marsh.marshal(obj);
-
- return new BinaryObjectImpl(ctx, bytes, 0);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java
deleted file mode 100644
index e3b6bda..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsOffheapSelfTest.java
+++ /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.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.eclipse.jetty.util.ConcurrentHashSet;
-import sun.misc.Unsafe;
-
-/**
- * Compact offsets tests for offheap portable objects.
- */
-public class PortableCompactOffsetsOffheapSelfTest extends PortableCompactOffsetsAbstractSelfTest {
- /** Unsafe instance. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Byte array offset for unsafe mechanics. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** Allocated unsafe pointer. */
- private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- // Cleanup allocated objects.
- for (Long ptr : ptrs)
- UNSAFE.freeMemory(ptr);
-
- ptrs.clear();
- }
-
- /** {@inheritDoc} */
- @Override protected BinaryObjectEx toPortable(PortableMarshaller marsh, Object obj) throws Exception {
- byte[] arr = marsh.marshal(obj);
-
- long ptr = UNSAFE.allocateMemory(arr.length);
-
- ptrs.add(ptr);
-
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
-
- return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
new file mode 100644
index 0000000..9e7619f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsHeapNonCompactSelfTest.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.noncompact;
+
+import org.apache.ignite.internal.portable.BinaryFieldsAbstractSelfTest;
+import org.apache.ignite.internal.portable.BinaryFieldsHeapSelfTest;
+import org.apache.ignite.internal.portable.BinaryObjectEx;
+import org.apache.ignite.internal.portable.BinaryObjectImpl;
+import org.apache.ignite.marshaller.portable.PortableMarshaller;
+
+/**
+ * Field tests for heap-based portables with non-compact footer.
+ */
+public class BinaryFieldsHeapNonCompactSelfTest extends BinaryFieldsHeapSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java
new file mode 100644
index 0000000..0bca601
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFieldsOffheapNonCompactSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.noncompact;
+
+import org.apache.ignite.internal.portable.BinaryFieldsOffheapSelfTest;
+
+/**
+ * Field tests for offheap-based portables with non-compact footer.
+ */
+public class BinaryFieldsOffheapNonCompactSelfTest extends BinaryFieldsOffheapSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java
new file mode 100644
index 0000000..8fba738
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsHeapNonCompactSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.noncompact;
+
+import org.apache.ignite.internal.portable.BinaryFooterOffsetsHeapSelfTest;
+
+/**
+ * Compact offsets tests for heap portable objects with non-compact footer.
+ */
+public class BinaryFooterOffsetsHeapNonCompactSelfTest extends BinaryFooterOffsetsHeapSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java
new file mode 100644
index 0000000..b52bd83
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryFooterOffsetsOffheapNonCompactSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.noncompact;
+
+import org.apache.ignite.internal.portable.BinaryFooterOffsetsOffheapSelfTest;
+
+/**
+ * Compact offsets tests for offheap portable objects with non-compact footer.
+ */
+public class BinaryFooterOffsetsOffheapNonCompactSelfTest extends BinaryFooterOffsetsOffheapSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java
new file mode 100644
index 0000000..0484dea
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryMarshallerNonCompactSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.noncompact;
+
+import org.apache.ignite.internal.portable.BinaryMarshallerSelfTest;
+
+/**
+ * Basic marshaller test with non-compact footer.
+ */
+public class BinaryMarshallerNonCompactSelfTest extends BinaryMarshallerSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java
new file mode 100644
index 0000000..8811029
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderAdditionalNonCompactSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.noncompact;
+
+import org.apache.ignite.internal.portable.BinaryObjectBuilderAdditionalSelfTest;
+
+/**
+ *
+ */
+public class BinaryObjectBuilderAdditionalNonCompactSelfTest extends BinaryObjectBuilderAdditionalSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
new file mode 100644
index 0000000..0b0916d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable.noncompact;
+
+import org.apache.ignite.internal.portable.BinaryObjectBuilderSelfTest;
+
+/**
+ * Portable builder test for objects with non-compact footer.
+ */
+public class BinaryObjectBuilderNonCompactSelfTest extends BinaryObjectBuilderSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
index 4fe8633..1128d67 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePortableObjectsTestSuite.java
@@ -19,16 +19,23 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.internal.portable.GridPortableAffinityKeySelfTest;
-import org.apache.ignite.internal.portable.GridBinaryObjectBuilderAdditionalSelfTest;
-import org.apache.ignite.internal.portable.GridBinaryObjectBuilderSelfTest;
+import org.apache.ignite.internal.portable.BinaryObjectBuilderAdditionalSelfTest;
+import org.apache.ignite.internal.portable.BinaryObjectBuilderSelfTest;
import org.apache.ignite.internal.portable.GridPortableMarshallerCtxDisabledSelfTest;
-import org.apache.ignite.internal.portable.GridPortableMarshallerSelfTest;
+import org.apache.ignite.internal.portable.BinaryMarshallerSelfTest;
import org.apache.ignite.internal.portable.GridPortableMetaDataSelfTest;
import org.apache.ignite.internal.portable.GridPortableWildcardsSelfTest;
-import org.apache.ignite.internal.portable.PortableCompactOffsetsHeapSelfTest;
-import org.apache.ignite.internal.portable.PortableCompactOffsetsOffheapSelfTest;
+import org.apache.ignite.internal.portable.BinaryFooterOffsetsHeapSelfTest;
+import org.apache.ignite.internal.portable.BinaryFooterOffsetsOffheapSelfTest;
import org.apache.ignite.internal.portable.BinaryFieldsHeapSelfTest;
import org.apache.ignite.internal.portable.BinaryFieldsOffheapSelfTest;
+import org.apache.ignite.internal.portable.noncompact.BinaryFieldsHeapNonCompactSelfTest;
+import org.apache.ignite.internal.portable.noncompact.BinaryFieldsOffheapNonCompactSelfTest;
+import org.apache.ignite.internal.portable.noncompact.BinaryFooterOffsetsHeapNonCompactSelfTest;
+import org.apache.ignite.internal.portable.noncompact.BinaryFooterOffsetsOffheapNonCompactSelfTest;
+import org.apache.ignite.internal.portable.noncompact.BinaryMarshallerNonCompactSelfTest;
+import org.apache.ignite.internal.portable.noncompact.BinaryObjectBuilderAdditionalNonCompactSelfTest;
+import org.apache.ignite.internal.portable.noncompact.BinaryObjectBuilderNonCompactSelfTest;
import org.apache.ignite.internal.processors.cache.portable.GridCacheClientNodeBinaryObjectMetadataMultinodeTest;
import org.apache.ignite.internal.processors.cache.portable.GridCacheClientNodeBinaryObjectMetadataTest;
import org.apache.ignite.internal.processors.cache.portable.GridCachePortableStoreObjectsSelfTest;
@@ -57,18 +64,27 @@ public class IgnitePortableObjectsTestSuite extends TestSuite {
public static TestSuite suite() throws Exception {
TestSuite suite = new TestSuite("GridGain Portable Objects Test Suite");
- suite.addTestSuite(GridPortableMarshallerSelfTest.class);
+ suite.addTestSuite(BinaryMarshallerSelfTest.class);
suite.addTestSuite(GridPortableMarshallerCtxDisabledSelfTest.class);
- suite.addTestSuite(GridBinaryObjectBuilderSelfTest.class);
- suite.addTestSuite(GridBinaryObjectBuilderAdditionalSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderAdditionalSelfTest.class);
suite.addTestSuite(BinaryFieldsHeapSelfTest.class);
suite.addTestSuite(BinaryFieldsOffheapSelfTest.class);
- suite.addTestSuite(PortableCompactOffsetsHeapSelfTest.class);
- suite.addTestSuite(PortableCompactOffsetsOffheapSelfTest.class);
+ suite.addTestSuite(BinaryFooterOffsetsHeapSelfTest.class);
+ suite.addTestSuite(BinaryFooterOffsetsOffheapSelfTest.class);
suite.addTestSuite(GridPortableMetaDataSelfTest.class);
suite.addTestSuite(GridPortableAffinityKeySelfTest.class);
suite.addTestSuite(GridPortableWildcardsSelfTest.class);
+ // Tests for objects with non-compact footers.
+ suite.addTestSuite(BinaryMarshallerNonCompactSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderNonCompactSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderAdditionalNonCompactSelfTest.class);
+ suite.addTestSuite(BinaryFieldsHeapNonCompactSelfTest.class);
+ suite.addTestSuite(BinaryFieldsOffheapNonCompactSelfTest.class);
+ suite.addTestSuite(BinaryFooterOffsetsHeapNonCompactSelfTest.class);
+ suite.addTestSuite(BinaryFooterOffsetsOffheapNonCompactSelfTest.class);
+
suite.addTestSuite(GridCacheBinaryObjectsLocalSelfTest.class);
suite.addTestSuite(GridCacheBinaryObjectsAtomicLocalSelfTest.class);
suite.addTestSuite(GridCacheBinaryObjectsReplicatedSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
index d273b11..b2551ec 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
@@ -70,7 +70,7 @@ void CheckPrimitive(T val)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
try
@@ -150,7 +150,7 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -183,7 +183,7 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -220,7 +220,7 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -260,7 +260,7 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -512,7 +512,7 @@ void CheckCollectionEmpty(CollectionType* colType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -602,7 +602,7 @@ void CheckCollection(CollectionType* colType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -679,7 +679,7 @@ void CheckCollectionIterators(CollectionType* colType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -755,7 +755,7 @@ void CheckMapEmpty(MapType* mapType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -848,7 +848,7 @@ void CheckMap(MapType* mapType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1030,7 +1030,7 @@ BOOST_AUTO_TEST_CASE(TestGuidNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1115,7 +1115,7 @@ BOOST_AUTO_TEST_CASE(TestString) {
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1193,7 +1193,7 @@ BOOST_AUTO_TEST_CASE(TestStringArrayNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1310,7 +1310,7 @@ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1437,7 +1437,7 @@ BOOST_AUTO_TEST_CASE(TestStringArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1551,7 +1551,7 @@ BOOST_AUTO_TEST_CASE(TestObject)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 3;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1595,7 +1595,7 @@ BOOST_AUTO_TEST_CASE(TestNestedObject)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 3;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1637,7 +1637,7 @@ BOOST_AUTO_TEST_CASE(TestArrayNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1713,7 +1713,7 @@ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1797,7 +1797,7 @@ BOOST_AUTO_TEST_CASE(TestArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1858,7 +1858,7 @@ BOOST_AUTO_TEST_CASE(TestCollectionNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1944,7 +1944,7 @@ BOOST_AUTO_TEST_CASE(TestMapNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -2035,7 +2035,7 @@ BOOST_AUTO_TEST_CASE(TestRawMode)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin, footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin, footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -2091,10 +2091,10 @@ BOOST_AUTO_TEST_CASE(TestFieldSeek)
int32_t rawOff;
int32_t footerBegin;
- if (flags & IGNITE_BINARY_FLAG_RAW_ONLY)
- footerBegin = len;
- else
+ if (flags & IGNITE_BINARY_FLAG_HAS_SCHEMA)
footerBegin = schemaOrRawOff;
+ else
+ footerBegin = len;
int32_t trailingBytes = (len - footerBegin) % 8;
@@ -2105,14 +2105,14 @@ BOOST_AUTO_TEST_CASE(TestFieldSeek)
else
rawOff = schemaOrRawOff;
- bool usrType = flags & IGNITE_BINARY_FLAG_USER_OBJECT;
+ bool usrType = flags & IGNITE_BINARY_FLAG_USER_TYPE;
footerBegin += pos;
footerEnd += pos;
BinaryReaderImpl readerImpl(&in, &idRslvr, pos, usrType,
typeId, hashCode, len, rawOff,
- footerBegin, footerEnd, OFFSET_TYPE_1_BYTE);
+ footerBegin, footerEnd, OFFSET_TYPE_ONE_BYTE);
BinaryReader reader(&readerImpl);
@@ -2243,7 +2243,7 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteFields)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 6 * fieldsNum;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_2_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_TWO_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -2288,7 +2288,7 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteFields)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 8 * fieldsNum;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_4_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_FOUR_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -2328,7 +2328,7 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 6 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_2_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_TWO_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -2362,7 +2362,7 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 8 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_4_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, OFFSET_TYPE_FOUR_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h
index d487941..979d2ed 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_common.h
@@ -21,7 +21,7 @@
#include <stdint.h>
namespace ignite
-{
+{
namespace impl
{
namespace binary
@@ -164,19 +164,25 @@ namespace ignite
/** Read/write map. */
const int32_t IGNITE_BINARY_MODE_MAP = 3;
- /** User object flag. */
- const int16_t IGNITE_BINARY_FLAG_USER_OBJECT = 0x0001;
+ /** User type flag. */
+ const int16_t IGNITE_BINARY_FLAG_USER_TYPE = 0x0001;
- /** Raw only flag. */
- const int16_t IGNITE_BINARY_FLAG_RAW_ONLY = 0x0002;
+ /** Flag: schema exists. */
+ const int16_t IGNITE_BINARY_FLAG_HAS_SCHEMA = 0x0002;
+
+ /** Flag indicating that object has raw data. */
+ const int16_t IGNITE_BINARY_FLAG_HAS_RAW = 0x0004;
/** Flag indicating that schema field offset is one byte long. */
- const int16_t IGNITE_BINARY_FLAG_OFFSET_1_BYTE = 0x0004;
+ const int16_t IGNITE_BINARY_FLAG_OFFSET_ONE_BYTE = 0x0008;
/** Flag indicating that schema field offset is two byte long. */
- const int16_t IGNITE_BINARY_FLAG_OFFSET_2_BYTE = 0x0008;
+ const int16_t IGNITE_BINARY_FLAG_OFFSET_TWO_BYTES = 0x0010;
+
+ /** Flag: compact footer, no field IDs. */
+ const int16_t IGNITE_BINARY_FLAG_COMPACT_FOOTER = 0x0020;
}
- }
+ }
}
#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h
index 923553d..0b2b592 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_reader_impl.h
@@ -771,6 +771,13 @@ namespace ignite
}
int16_t flags = stream->ReadInt16();
+
+ if (flags & IGNITE_BINARY_FLAG_COMPACT_FOOTER) {
+ IGNITE_ERROR_2(ignite::IgniteError::IGNITE_ERR_BINARY,
+ "Unsupported binary protocol flag: IGNITE_BINARY_FLAG_COMPACT_FOOTER: ",
+ IGNITE_BINARY_FLAG_COMPACT_FOOTER);
+ }
+
int32_t typeId = stream->ReadInt32();
int32_t hashCode = stream->ReadInt32();
int32_t len = stream->ReadInt32();
@@ -783,50 +790,43 @@ namespace ignite
int32_t rawOff;
int32_t footerBegin;
- if (flags & IGNITE_BINARY_FLAG_RAW_ONLY)
- footerBegin = len;
+ if (flags & IGNITE_BINARY_FLAG_HAS_SCHEMA)
+ footerBegin = pos + schemaOrRawOff;
else
- footerBegin = schemaOrRawOff;
+ footerBegin = pos + len;
BinaryOffsetType schemaType;
- int32_t trailingBytes;
- if (flags & IGNITE_BINARY_FLAG_OFFSET_1_BYTE)
- {
- schemaType = OFFSET_TYPE_1_BYTE;
+ if (flags & IGNITE_BINARY_FLAG_OFFSET_ONE_BYTE)
+ schemaType = OFFSET_TYPE_ONE_BYTE;
+ else if (flags & IGNITE_BINARY_FLAG_OFFSET_TWO_BYTES)
+ schemaType = OFFSET_TYPE_TWO_BYTES;
+ else
+ schemaType = OFFSET_TYPE_FOUR_BYTES;
- trailingBytes = (len - footerBegin) % 5;
- }
- else if (flags & IGNITE_BINARY_FLAG_OFFSET_2_BYTE)
+ int32_t footerEnd;
+
+ if (flags & IGNITE_BINARY_FLAG_HAS_RAW)
{
- schemaType = OFFSET_TYPE_2_BYTE;
+ // 4 is the size of RawOffset field at the end of the packet.
+ footerEnd = pos + len - 4;
- trailingBytes = (len - footerBegin) % 6;
+ rawOff = stream->ReadInt32(footerEnd);
}
else
{
- schemaType = OFFSET_TYPE_4_BYTE;
-
- trailingBytes = (len - footerBegin) % 8;
- }
-
- int32_t footerEnd = len - trailingBytes;
+ footerEnd = pos + len;
- if (trailingBytes)
- rawOff = stream->ReadInt32(pos + len - 4);
- else
rawOff = schemaOrRawOff;
+ }
- bool usrType = flags & IGNITE_BINARY_FLAG_USER_OBJECT;
-
- footerBegin += pos;
- footerEnd += pos;
+ bool usrType = flags & IGNITE_BINARY_FLAG_USER_TYPE;
ignite::binary::BinaryType<T> type;
TemplatedBinaryIdResolver<T> idRslvr(type);
BinaryReaderImpl readerImpl(stream, &idRslvr, pos, usrType,
- typeId, hashCode, len, rawOff,
- footerBegin, footerEnd, schemaType);
+ typeId, hashCode, len, rawOff,
+ footerBegin, footerEnd, schemaType);
ignite::binary::BinaryReader reader(&readerImpl);
T val = type.Read(reader);
@@ -1038,9 +1038,7 @@ namespace ignite
{
CheckRawMode(false);
CheckSingleMode(true);
-
- int32_t pos = stream->Position();
-
+
int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
int32_t fieldPos = FindField(fieldId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h
index d0a9f26..b100b8c 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_schema.h
@@ -39,13 +39,13 @@ namespace ignite
enum BinaryOffsetType
{
/** Means all field offsets can be fit in one byte. */
- OFFSET_TYPE_1_BYTE,
+ OFFSET_TYPE_ONE_BYTE,
/** Means all field offsets can be fit in two bytes. */
- OFFSET_TYPE_2_BYTE,
+ OFFSET_TYPE_TWO_BYTES,
/** Means field offsets should be stored in four bytes. */
- OFFSET_TYPE_4_BYTE
+ OFFSET_TYPE_FOUR_BYTES
};
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h
index fe31ece..1b47d9e 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/binary/binary_writer_impl.h
@@ -601,7 +601,7 @@ namespace ignite
stream->WriteInt8(IGNITE_HDR_FULL);
stream->WriteInt8(IGNITE_PROTO_VER);
- stream->WriteInt16(IGNITE_BINARY_FLAG_USER_OBJECT);
+ stream->WriteInt16(IGNITE_BINARY_FLAG_USER_TYPE);
stream->WriteInt32(idRslvr.GetTypeId());
stream->WriteInt32(type.GetHashCode(obj));
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp
index e189273..5fcbc75 100644
--- a/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_reader_impl.cpp
@@ -47,7 +47,7 @@ namespace ignite
BinaryReaderImpl::BinaryReaderImpl(InteropInputStream* stream) :
stream(stream), idRslvr(NULL), pos(0), usrType(false), typeId(0), hashCode(0), len(0),
rawOff(0), rawMode(true), elemIdGen(0), elemId(0), elemCnt(-1), elemRead(0), footerBegin(-1),
- footerEnd(-1), schemaType(OFFSET_TYPE_4_BYTE)
+ footerEnd(-1), schemaType(OFFSET_TYPE_FOUR_BYTES)
{
// No-op.
}
@@ -637,7 +637,7 @@ namespace ignite
switch (schemaType)
{
- case OFFSET_TYPE_1_BYTE:
+ case OFFSET_TYPE_ONE_BYTE:
{
for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 5)
{
@@ -649,7 +649,7 @@ namespace ignite
break;
}
- case OFFSET_TYPE_2_BYTE:
+ case OFFSET_TYPE_TWO_BYTES:
{
for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 6)
{
@@ -661,7 +661,7 @@ namespace ignite
break;
}
- case OFFSET_TYPE_4_BYTE:
+ case OFFSET_TYPE_FOUR_BYTES:
{
for (int32_t schemaPos = footerBegin; schemaPos < footerEnd; schemaPos += 8)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp
index 1596557..0b8025a 100644
--- a/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_schema.cpp
@@ -70,7 +70,7 @@ namespace ignite
{
switch (GetType())
{
- case OFFSET_TYPE_1_BYTE:
+ case OFFSET_TYPE_ONE_BYTE:
{
for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
{
@@ -80,7 +80,7 @@ namespace ignite
break;
}
- case OFFSET_TYPE_2_BYTE:
+ case OFFSET_TYPE_TWO_BYTES:
{
for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
{
@@ -90,7 +90,7 @@ namespace ignite
break;
}
- case OFFSET_TYPE_4_BYTE:
+ case OFFSET_TYPE_FOUR_BYTES:
{
for (FieldContainer::const_iterator i = fieldsInfo->begin(); i != fieldsInfo->end(); ++i)
{
@@ -124,11 +124,11 @@ namespace ignite
int32_t maxOffset = fieldsInfo->back().offset;
if (maxOffset < 0x100)
- return OFFSET_TYPE_1_BYTE;
+ return OFFSET_TYPE_ONE_BYTE;
else if (maxOffset < 0x10000)
- return OFFSET_TYPE_2_BYTE;
+ return OFFSET_TYPE_TWO_BYTES;
- return OFFSET_TYPE_4_BYTE;
+ return OFFSET_TYPE_FOUR_BYTES;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp b/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp
index 47df19d..d03d6ba 100644
--- a/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/binary/binary_writer_impl.cpp
@@ -563,11 +563,15 @@ namespace ignite
int32_t lenWithoutSchema = stream->Position() - start;
int32_t nonRawLen = rawPos == -1 ? lenWithoutSchema : rawPos - start;
-
- if (schema.Empty())
+
+ uint16_t flags = IGNITE_BINARY_FLAG_USER_TYPE;
+
+ if (rawPos > 0)
+ flags |= IGNITE_BINARY_FLAG_HAS_RAW;
+
+ if (!HasSchema())
{
- stream->WriteInt16(start + IGNITE_OFFSET_FLAGS, IGNITE_BINARY_FLAG_USER_OBJECT |
- IGNITE_BINARY_FLAG_RAW_ONLY);
+ stream->WriteInt16(start + IGNITE_OFFSET_FLAGS, flags);
stream->WriteInt32(start + IGNITE_OFFSET_LEN, lenWithoutSchema);
stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_ID, 0);
stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_OR_RAW_OFF, GetRawPosition() - start);
@@ -584,17 +588,14 @@ namespace ignite
int32_t length = stream->Position() - start;
- if (schemaType == OFFSET_TYPE_1_BYTE)
- {
- stream->WriteInt16(start + IGNITE_OFFSET_FLAGS,
- IGNITE_BINARY_FLAG_USER_OBJECT | IGNITE_BINARY_FLAG_OFFSET_1_BYTE);
- }
- else if (schemaType == OFFSET_TYPE_2_BYTE)
- {
- stream->WriteInt16(start + IGNITE_OFFSET_FLAGS,
- IGNITE_BINARY_FLAG_USER_OBJECT | IGNITE_BINARY_FLAG_OFFSET_2_BYTE);
- }
+ flags |= IGNITE_BINARY_FLAG_HAS_SCHEMA;
+
+ if (schemaType == OFFSET_TYPE_ONE_BYTE)
+ flags |= IGNITE_BINARY_FLAG_OFFSET_ONE_BYTE;
+ else if (schemaType == OFFSET_TYPE_TWO_BYTES)
+ flags |= IGNITE_BINARY_FLAG_OFFSET_TWO_BYTES;
+ stream->WriteInt16(start + IGNITE_OFFSET_FLAGS, flags);
stream->WriteInt32(start + IGNITE_OFFSET_LEN, length);
stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_ID, schemaId);
stream->WriteInt32(start + IGNITE_OFFSET_SCHEMA_OR_RAW_OFF, lenWithoutSchema);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
index e373b89..9755033 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
@@ -70,6 +70,7 @@
<!-- Binary marshaller configuration -->
<property name="marshaller">
<bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
+ <property name="compactFooter" value="false" />
<property name="typeConfigurations">
<list>
<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
index 11b87bd..74444a1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/marshaller-explicit.xml
@@ -26,7 +26,9 @@
<property name="connectorConfiguration"><null/></property>
<property name="marshaller">
- <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller" />
+ <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
+ <property name="compactFooter" value="false"/>
+ </bean>
</property>
<property name="discoverySpi">
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/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 1840ab9..97cc381 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -678,28 +678,37 @@ namespace Apache.Ignite.Core.Impl.Binary
WriteField(ctx, valEntry.Value);
}
+ var flags = inHeader.IsUserType
+ ? BinaryObjectHeader.Flag.UserType
+ : BinaryObjectHeader.Flag.None;
+
// Write raw data.
int outRawOff = outStream.Position - outStartPos;
- int inRawOff = inHeader.GetRawOffset(inStream, inStartPos);
- int inRawLen = inHeader.SchemaOffset - inRawOff;
+ if (inHeader.HasRaw)
+ {
+ var inRawOff = inHeader.GetRawOffset(inStream, inStartPos);
+ var inRawLen = inHeader.SchemaOffset - inRawOff;
+
+ flags |= BinaryObjectHeader.Flag.HasRaw;
- if (inRawLen > 0)
outStream.Write(inStream.InternalArray, inStartPos + inRawOff, inRawLen);
+ }
// Write schema
int outSchemaOff = outRawOff;
var schemaPos = outStream.Position;
int outSchemaId;
- short flags;
- var hasSchema = outSchema.WriteSchema(outStream, schemaIdx, out outSchemaId, out flags);
+ var hasSchema = outSchema.WriteSchema(outStream, schemaIdx, out outSchemaId, ref flags);
if (hasSchema)
{
outSchemaOff = schemaPos - outStartPos;
+
+ flags |= BinaryObjectHeader.Flag.HasSchema;
- if (inRawLen > 0)
+ if (inHeader.HasRaw)
outStream.WriteInt(outRawOff);
}
@@ -707,8 +716,8 @@ namespace Apache.Ignite.Core.Impl.Binary
var outHash = changeHash ? hash : inHeader.HashCode;
- var outHeader = new BinaryObjectHeader(inHeader.IsUserType, inHeader.TypeId, outHash,
- outLen, outSchemaId, outSchemaOff, !hasSchema, flags);
+ var outHeader = new BinaryObjectHeader(inHeader.TypeId, outHash, outLen,
+ outSchemaId, outSchemaOff, flags);
BinaryObjectHeader.Write(outHeader, outStream, outStartPos);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
index 59cb29c1..573e014 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
@@ -33,22 +33,38 @@ namespace Apache.Ignite.Core.Impl.Binary
/** Size, equals to sizeof(BinaryObjectHeader). */
public const int Size = 24;
- /** User type flag. */
- public const short FlagUserType = 0x1;
+ /// <summary>
+ /// Flags.
+ /// </summary>
+ [Flags]
+ public enum Flag : short
+ {
+ /** No flags. */
+ None = 0x00,
+
+ /** Flag: user type. */
+ UserType = 0x01,
+
+ /** Flag: schema exists. */
+ HasSchema = 0x02,
+
+ /** Flag indicating that object has raw data. */
+ HasRaw = 0x04,
- /** Raw only flag. */
- public const short FlagRawOnly = 0x2;
+ /** Flag: offsets take 1 byte. */
+ OffsetOneByte = 0x08,
- /** Byte-sized field offsets flag. */
- public const short FlagByteOffsets = 0x4;
+ /** Flag: offsets take 2 bytes. */
+ OffsetTwoBytes = 0x10,
- /** Short-sized field offsets flag. */
- public const short FlagShortOffsets = 0x8;
+ /** Flag: compact footer, no field IDs. */
+ CompactFooter = 0x20
+ }
/** Actual header layout */
public readonly byte Header; // Header code, always 103 (HdrFull)
public readonly byte Version; // Protocol version
- public readonly short Flags; // Flags
+ public readonly Flag Flags; // Flags
public readonly int TypeId; // Type ID
public readonly int HashCode; // Hash code
public readonly int Length; // Length, including header
@@ -58,16 +74,13 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <summary>
/// Initializes a new instance of the <see cref="BinaryObjectHeader" /> struct.
/// </summary>
- /// <param name="userType">User type flag.</param>
/// <param name="typeId">Type ID.</param>
/// <param name="hashCode">Hash code.</param>
/// <param name="length">Length.</param>
/// <param name="schemaId">Schema ID.</param>
/// <param name="schemaOffset">Schema offset.</param>
- /// <param name="rawOnly">Raw flag.</param>
/// <param name="flags">The flags.</param>
- public BinaryObjectHeader(bool userType, int typeId, int hashCode, int length, int schemaId, int schemaOffset,
- bool rawOnly, short flags)
+ public BinaryObjectHeader(int typeId, int hashCode, int length, int schemaId, int schemaOffset, Flag flags)
{
Header = BinaryUtils.HdrFull;
Version = BinaryUtils.ProtoVer;
@@ -75,12 +88,6 @@ namespace Apache.Ignite.Core.Impl.Binary
Debug.Assert(schemaOffset <= length);
Debug.Assert(schemaOffset >= Size);
- if (userType)
- flags |= FlagUserType;
-
- if (rawOnly)
- flags |= FlagRawOnly;
-
Flags = flags;
TypeId = typeId;
@@ -98,7 +105,7 @@ namespace Apache.Ignite.Core.Impl.Binary
{
Header = stream.ReadByte();
Version = stream.ReadByte();
- Flags = stream.ReadShort();
+ Flags = (Flag) stream.ReadShort();
Length = stream.ReadInt();
TypeId = stream.ReadInt();
HashCode = stream.ReadInt();
@@ -114,7 +121,7 @@ namespace Apache.Ignite.Core.Impl.Binary
{
stream.WriteByte(Header);
stream.WriteByte(Version);
- stream.WriteShort(Flags);
+ stream.WriteShort((short) Flags);
stream.WriteInt(Length);
stream.WriteInt(TypeId);
stream.WriteInt(HashCode);
@@ -123,31 +130,35 @@ namespace Apache.Ignite.Core.Impl.Binary
}
/// <summary>
- /// Gets a user type flag.
+ /// Gets the user type flag.
/// </summary>
public bool IsUserType
{
- get { return (Flags & FlagUserType) == FlagUserType; }
+ get { return (Flags & Flag.UserType) == Flag.UserType; }
}
/// <summary>
- /// Gets a raw-only flag.
+ /// Gets the schema flag.
/// </summary>
- public bool IsRawOnly
+ public bool HasSchema
{
- get { return (Flags & FlagRawOnly) == FlagRawOnly; }
+ get { return (Flags & Flag.HasSchema) == Flag.HasSchema; }
}
/// <summary>
- /// Gets a value indicating whether this instance has raw offset.
+ /// Gets the raw flag.
/// </summary>
- public bool HasRawOffset
+ public bool HasRaw
{
- get
- {
- // Remainder => raw offset is the very last 4 bytes in object.
- return !IsRawOnly && ((Length - SchemaOffset) % SchemaFieldSize) == 4;
- }
+ get { return (Flags & Flag.HasRaw) == Flag.HasRaw; }
+ }
+
+ /// <summary>
+ /// Gets the compact footer flag.
+ /// </summary>
+ public bool IsCompactFooter
+ {
+ get { return (Flags & Flag.CompactFooter) == Flag.CompactFooter; }
}
/// <summary>
@@ -157,10 +168,10 @@ namespace Apache.Ignite.Core.Impl.Binary
{
get
{
- if ((Flags & FlagByteOffsets) == FlagByteOffsets)
+ if ((Flags & Flag.OffsetOneByte) == Flag.OffsetOneByte)
return 1;
- if ((Flags & FlagShortOffsets) == FlagShortOffsets)
+ if ((Flags & Flag.OffsetTwoBytes) == Flag.OffsetTwoBytes)
return 2;
return 4;
@@ -182,7 +193,7 @@ namespace Apache.Ignite.Core.Impl.Binary
{
get
{
- if (IsRawOnly)
+ if (!HasSchema)
return 0;
var schemaSize = Length - SchemaOffset;
@@ -201,7 +212,7 @@ namespace Apache.Ignite.Core.Impl.Binary
{
Debug.Assert(stream != null);
- if (!HasRawOffset)
+ if (!HasRaw || !HasSchema)
return SchemaOffset;
stream.Seek(position + Length - 4, SeekOrigin.Begin);
@@ -219,6 +230,8 @@ namespace Apache.Ignite.Core.Impl.Binary
{
Debug.Assert(stream != null);
+ ThrowIfUnsupported();
+
var schemaSize = SchemaFieldCount;
if (schemaSize == 0)
@@ -259,6 +272,8 @@ namespace Apache.Ignite.Core.Impl.Binary
{
Debug.Assert(stream != null);
+ ThrowIfUnsupported();
+
var schemaSize = SchemaFieldCount;
if (schemaSize == 0)
@@ -297,10 +312,10 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <param name="offset">Offset in the array.</param>
/// <param name="count">Field count to write.</param>
/// <returns>
- /// Flags according to offset sizes: <see cref="BinaryObjectHeader.FlagByteOffsets" />,
- /// <see cref="BinaryObjectHeader.FlagShortOffsets" />, or 0.
+ /// Flags according to offset sizes: <see cref="Flag.OffsetOneByte" />,
+ /// <see cref="Flag.OffsetTwoBytes" />, or 0.
/// </returns>
- public static unsafe short WriteSchema(BinaryObjectSchemaField[] fields, IBinaryStream stream, int offset,
+ public static unsafe Flag WriteSchema(BinaryObjectSchemaField[] fields, IBinaryStream stream, int offset,
int count)
{
Debug.Assert(fields != null);
@@ -324,7 +339,7 @@ namespace Apache.Ignite.Core.Impl.Binary
stream.WriteByte((byte)field.Offset);
}
- return FlagByteOffsets;
+ return Flag.OffsetOneByte;
}
if (maxFieldOffset <= ushort.MaxValue)
@@ -338,7 +353,7 @@ namespace Apache.Ignite.Core.Impl.Binary
stream.WriteShort((short)field.Offset);
}
- return FlagShortOffsets;
+ return Flag.OffsetTwoBytes;
}
if (BitConverter.IsLittleEndian)
@@ -359,9 +374,8 @@ namespace Apache.Ignite.Core.Impl.Binary
}
}
- return 0;
+ return Flag.None;
}
-
}
/// <summary>
@@ -396,24 +410,27 @@ namespace Apache.Ignite.Core.Impl.Binary
stream.Seek(position, SeekOrigin.Begin);
+ BinaryObjectHeader hdr;
+
if (BitConverter.IsLittleEndian)
{
- var hdr = new BinaryObjectHeader();
-
stream.Read((byte*) &hdr, Size);
Debug.Assert(hdr.Version == BinaryUtils.ProtoVer);
Debug.Assert(hdr.SchemaOffset <= hdr.Length);
Debug.Assert(hdr.SchemaOffset >= Size);
- // Only one of the flags can be set
- var f = hdr.Flags;
- Debug.Assert((f & (FlagShortOffsets | FlagByteOffsets)) != (FlagShortOffsets | FlagByteOffsets));
-
- return hdr;
}
+ else
+ hdr = new BinaryObjectHeader(stream);
+
+ hdr.ThrowIfUnsupported();
- return new BinaryObjectHeader(stream);
+ // Only one of the flags can be set
+ var f = hdr.Flags;
+ Debug.Assert((f & (Flag.OffsetOneByte | Flag.OffsetTwoBytes)) !=
+ (Flag.OffsetOneByte | Flag.OffsetTwoBytes));
+ return hdr;
}
/** <inheritdoc> */
@@ -465,5 +482,15 @@ namespace Apache.Ignite.Core.Impl.Binary
{
return !left.Equals(right);
}
+
+ /// <summary>
+ /// Throws an exception if current header represents unsupported mode.
+ /// </summary>
+ private void ThrowIfUnsupported()
+ {
+ // Compact schema is not supported
+ if (IsCompactFooter)
+ throw new NotSupportedException("Compact binary object footer is not supported in Ignite.NET.");
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
index 75ff2c5..65b6fc0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
@@ -82,22 +82,21 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <param name="stream">The stream.</param>
/// <param name="schemaOffset">The schema offset.</param>
/// <param name="schemaId">The schema identifier.</param>
- /// <param name="flags">Flags according to offset sizes: <see cref="BinaryObjectHeader.FlagByteOffsets" />,
- /// <see cref="BinaryObjectHeader.FlagShortOffsets" />, or 0.</param>
+ /// <param name="flags">Flags according to offset sizes.</param>
/// <returns>
/// True if current schema was non empty; false otherwise.
/// </returns>
- public bool WriteSchema(IBinaryStream stream, int schemaOffset, out int schemaId, out short flags)
+ public bool WriteSchema(IBinaryStream stream, int schemaOffset, out int schemaId,
+ ref BinaryObjectHeader.Flag flags)
{
schemaId = Fnv1Hash.Basis;
- flags = 0;
var count = _idx - schemaOffset;
if (count == 0)
return false;
- flags = BinaryObjectHeader.WriteSchema(_fields, stream, schemaOffset, count);
+ flags |= BinaryObjectHeader.WriteSchema(_fields, stream, schemaOffset, count);
for (var i = schemaOffset; i < _idx; i++)
schemaId = Fnv1Hash.Update(schemaId, _fields[i].Id);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index 53f6f4a..9aeb908 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -898,7 +898,7 @@ namespace Apache.Ignite.Core.Impl.Binary
if (_curRaw)
throw new BinaryObjectException("Cannot read named fields after raw data is read.");
- if (_curHdr.IsRawOnly)
+ if (!_curHdr.HasSchema)
return false;
var actionId = _curStruct.CurStructAction;
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/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 58973f7..e09a7f4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1090,20 +1090,31 @@ namespace Apache.Ignite.Core.Impl.Binary
var schemaOffset = _stream.Position - pos;
int schemaId;
- short flags;
- var hasSchema = _schema.WriteSchema(_stream, schemaIdx, out schemaId, out flags);
+
+ var flags = desc.UserType
+ ? BinaryObjectHeader.Flag.UserType
+ : BinaryObjectHeader.Flag.None;
- if (!hasSchema)
+ var hasSchema = _schema.WriteSchema(_stream, schemaIdx, out schemaId, ref flags);
+
+ if (hasSchema)
+ {
+ flags |= BinaryObjectHeader.Flag.HasSchema;
+
+ // Calculate and write header.
+ if (_curRawPos > 0)
+ _stream.WriteInt(_curRawPos - pos); // raw offset is in the last 4 bytes
+ }
+ else
schemaOffset = BinaryObjectHeader.Size;
- // Calculate and write header.
- if (hasSchema && _curRawPos > 0)
- _stream.WriteInt(_curRawPos - pos); // raw offset is in the last 4 bytes
+ if (_curRawPos > 0)
+ flags |= BinaryObjectHeader.Flag.HasRaw;
var len = _stream.Position - pos;
- var header = new BinaryObjectHeader(desc.UserType, desc.TypeId, obj.GetHashCode(), len,
- schemaId, schemaOffset, !hasSchema, flags);
+ var header = new BinaryObjectHeader(desc.TypeId, obj.GetHashCode(), len,
+ schemaId, schemaOffset, flags);
BinaryObjectHeader.Write(header, _stream, pos);
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b4a8f83/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
index 927ebaf..ecc6807 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
@@ -166,7 +166,8 @@ namespace Apache.Ignite.Core.Impl.Binary
{
var len = BinaryObjectHeader.Size;
- var hdr = new BinaryObjectHeader(desc.UserType, desc.TypeId, 0, len, 0, len, true, 0);
+ var hdr = new BinaryObjectHeader(desc.TypeId, 0, len, 0, len,
+ desc.UserType ? BinaryObjectHeader.Flag.UserType : BinaryObjectHeader.Flag.None);
var stream = new BinaryHeapStream(len);
[03/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
deleted file mode 100644
index 9529503..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ /dev/null
@@ -1,1777 +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.
- */
-
-// ReSharper disable UnassignedField.Global
-// ReSharper disable CollectionNeverUpdated.Global
-namespace Apache.Ignite.Core.Tests.Portable
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using Apache.Ignite.Core.Binary;
- using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Binary;
- using NUnit.Framework;
-
- /// <summary>
- /// Portable builder self test.
- /// </summary>
- public class PortableApiSelfTest
- {
- /** Undefined type: Empty. */
- private const string TypeEmpty = "EmptyUndefined";
-
- /** Grid. */
- private Ignite _grid;
-
- /** Marshaller. */
- private Marshaller _marsh;
-
- /// <summary>
- /// Set up routine.
- /// </summary>
- [TestFixtureSetUp]
- public void SetUp()
- {
- TestUtils.KillProcesses();
-
- var cfg = new IgniteConfiguration
- {
- BinaryConfiguration = new BinaryConfiguration
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>
- {
- new BinaryTypeConfiguration(typeof (Empty)),
- new BinaryTypeConfiguration(typeof (Primitives)),
- new BinaryTypeConfiguration(typeof (PrimitiveArrays)),
- new BinaryTypeConfiguration(typeof (StringDateGuidEnum)),
- new BinaryTypeConfiguration(typeof (WithRaw)),
- new BinaryTypeConfiguration(typeof (MetaOverwrite)),
- new BinaryTypeConfiguration(typeof (NestedOuter)),
- new BinaryTypeConfiguration(typeof (NestedInner)),
- new BinaryTypeConfiguration(typeof (MigrationOuter)),
- new BinaryTypeConfiguration(typeof (MigrationInner)),
- new BinaryTypeConfiguration(typeof (InversionOuter)),
- new BinaryTypeConfiguration(typeof (InversionInner)),
- new BinaryTypeConfiguration(typeof (CompositeOuter)),
- new BinaryTypeConfiguration(typeof (CompositeInner)),
- new BinaryTypeConfiguration(typeof (CompositeArray)),
- new BinaryTypeConfiguration(typeof (CompositeContainer)),
- new BinaryTypeConfiguration(typeof (ToPortable)),
- new BinaryTypeConfiguration(typeof (Remove)),
- new BinaryTypeConfiguration(typeof (RemoveInner)),
- new BinaryTypeConfiguration(typeof (BuilderInBuilderOuter)),
- new BinaryTypeConfiguration(typeof (BuilderInBuilderInner)),
- new BinaryTypeConfiguration(typeof (BuilderCollection)),
- new BinaryTypeConfiguration(typeof (BuilderCollectionItem)),
- new BinaryTypeConfiguration(typeof (DecimalHolder)),
- new BinaryTypeConfiguration(TypeEmpty),
- TypeConfigurationNoMeta(typeof (EmptyNoMeta)),
- TypeConfigurationNoMeta(typeof (ToPortableNoMeta))
- },
- DefaultIdMapper = new IdMapper()
- },
- JvmClasspath = TestUtils.CreateTestClasspath(),
- JvmOptions = new List<string>
- {
- "-ea",
- "-Xcheck:jni",
- "-Xms4g",
- "-Xmx4g",
- "-DIGNITE_QUIET=false",
- "-Xnoagent",
- "-Djava.compiler=NONE",
- "-Xdebug",
- "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005",
- "-XX:+HeapDumpOnOutOfMemoryError"
- },
- SpringConfigUrl = "config\\portable.xml"
- };
-
- _grid = (Ignite) Ignition.Start(cfg);
-
- _marsh = _grid.Marshaller;
- }
-
- /// <summary>
- /// Tear down routine.
- /// </summary>
- [TestFixtureTearDown]
- public virtual void TearDown()
- {
- if (_grid != null)
- Ignition.Stop(_grid.Name, true);
-
- _grid = null;
- }
-
- /// <summary>
- /// Ensure that portable engine is able to work with type names, which are not configured.
- /// </summary>
- [Test]
- public void TestNonConfigured()
- {
- string typeName1 = "Type1";
- string typeName2 = "Type2";
- string field1 = "field1";
- string field2 = "field2";
-
- // 1. Ensure that builder works fine.
- IBinaryObject portObj1 = _grid.GetBinary().GetBuilder(typeName1).SetField(field1, 1).Build();
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 2. Ensure that object can be unmarshalled without deserialization.
- byte[] data = ((BinaryObject) portObj1).Data;
-
- portObj1 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 3. Ensure that we can nest one anonymous object inside another
- IBinaryObject portObj2 =
- _grid.GetBinary().GetBuilder(typeName2).SetField(field2, portObj1).Build();
-
- Assert.AreEqual(typeName2, portObj2.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj2.GetBinaryType().Fields.Count);
- Assert.AreEqual(field2, portObj2.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, portObj2.GetBinaryType().GetFieldTypeName(field2));
-
- portObj1 = portObj2.GetField<IBinaryObject>(field2);
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
-
- // 4. Ensure that we can unmarshal object with other nested object.
- data = ((BinaryObject) portObj2).Data;
-
- portObj2 = _grid.Marshaller.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
-
- Assert.AreEqual(typeName2, portObj2.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj2.GetBinaryType().Fields.Count);
- Assert.AreEqual(field2, portObj2.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, portObj2.GetBinaryType().GetFieldTypeName(field2));
-
- portObj1 = portObj2.GetField<IBinaryObject>(field2);
-
- Assert.AreEqual(typeName1, portObj1.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj1.GetBinaryType().Fields.Count);
- Assert.AreEqual(field1, portObj1.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj1.GetBinaryType().GetFieldTypeName(field1));
-
- Assert.AreEqual(1, portObj1.GetField<int>(field1));
- }
-
- /// <summary>
- /// Test "ToPortable()" method.
- /// </summary>
- [Test]
- public void TestToPortable()
- {
- DateTime date = DateTime.Now.ToUniversalTime();
- Guid guid = Guid.NewGuid();
-
- IIgniteBinary api = _grid.GetBinary();
-
- // 1. Primitives.
- Assert.AreEqual(1, api.ToBinary<byte>((byte)1));
- Assert.AreEqual(1, api.ToBinary<short>((short)1));
- Assert.AreEqual(1, api.ToBinary<int>(1));
- Assert.AreEqual(1, api.ToBinary<long>((long)1));
-
- Assert.AreEqual((float)1, api.ToBinary<float>((float)1));
- Assert.AreEqual((double)1, api.ToBinary<double>((double)1));
-
- Assert.AreEqual(true, api.ToBinary<bool>(true));
- Assert.AreEqual('a', api.ToBinary<char>('a'));
-
- // 2. Special types.
- Assert.AreEqual("a", api.ToBinary<string>("a"));
- Assert.AreEqual(date, api.ToBinary<DateTime>(date));
- Assert.AreEqual(guid, api.ToBinary<Guid>(guid));
- Assert.AreEqual(TestEnum.One, api.ToBinary<TestEnum>(TestEnum.One));
-
- // 3. Arrays.
- Assert.AreEqual(new byte[] { 1 }, api.ToBinary<byte[]>(new byte[] { 1 }));
- Assert.AreEqual(new short[] { 1 }, api.ToBinary<short[]>(new short[] { 1 }));
- Assert.AreEqual(new[] { 1 }, api.ToBinary<int[]>(new[] { 1 }));
- Assert.AreEqual(new long[] { 1 }, api.ToBinary<long[]>(new long[] { 1 }));
-
- Assert.AreEqual(new float[] { 1 }, api.ToBinary<float[]>(new float[] { 1 }));
- Assert.AreEqual(new double[] { 1 }, api.ToBinary<double[]>(new double[] { 1 }));
-
- Assert.AreEqual(new[] { true }, api.ToBinary<bool[]>(new[] { true }));
- Assert.AreEqual(new[] { 'a' }, api.ToBinary<char[]>(new[] { 'a' }));
-
- Assert.AreEqual(new[] { "a" }, api.ToBinary<string[]>(new[] { "a" }));
- Assert.AreEqual(new[] { date }, api.ToBinary<DateTime[]>(new[] { date }));
- Assert.AreEqual(new[] { guid }, api.ToBinary<Guid[]>(new[] { guid }));
- Assert.AreEqual(new[] { TestEnum.One }, api.ToBinary<TestEnum[]>(new[] { TestEnum.One }));
-
- // 4. Objects.
- IBinaryObject portObj = api.ToBinary<IBinaryObject>(new ToPortable(1));
-
- Assert.AreEqual(typeof(ToPortable).Name, portObj.GetBinaryType().TypeName);
- Assert.AreEqual(1, portObj.GetBinaryType().Fields.Count);
- Assert.AreEqual("Val", portObj.GetBinaryType().Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, portObj.GetBinaryType().GetFieldTypeName("Val"));
-
- Assert.AreEqual(1, portObj.GetField<int>("val"));
- Assert.AreEqual(1, portObj.Deserialize<ToPortable>().Val);
-
- portObj = api.ToBinary<IBinaryObject>(new ToPortableNoMeta(1));
-
- Assert.AreEqual(1, portObj.GetBinaryType().Fields.Count);
-
- Assert.AreEqual(1, portObj.GetField<int>("Val"));
- Assert.AreEqual(1, portObj.Deserialize<ToPortableNoMeta>().Val);
-
- // 5. Object array.
- var portObjArr = api.ToBinary<object[]>(new object[] {new ToPortable(1)})
- .OfType<IBinaryObject>().ToArray();
-
- Assert.AreEqual(1, portObjArr.Length);
- Assert.AreEqual(1, portObjArr[0].GetField<int>("Val"));
- Assert.AreEqual(1, portObjArr[0].Deserialize<ToPortable>().Val);
- }
-
- /// <summary>
- /// Test builder field remove logic.
- /// </summary>
- [Test]
- public void TestRemove()
- {
- // Create empty object.
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Remove)).Build();
-
- Assert.IsNull(portObj.GetField<object>("val"));
- Assert.IsNull(portObj.Deserialize<Remove>().Val);
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
-
- // Populate it with field.
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(portObj);
-
- Assert.IsNull(builder.GetField<object>("val"));
-
- object val = 1;
-
- builder.SetField("val", val);
-
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- portObj = builder.Build();
-
- Assert.AreEqual(val, portObj.GetField<object>("val"));
- Assert.AreEqual(val, portObj.Deserialize<Remove>().Val);
-
- meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(Remove).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("val", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("val"));
-
- // Perform field remove.
- builder = _grid.GetBinary().GetBuilder(portObj);
-
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- builder.RemoveField("val");
- Assert.IsNull(builder.GetField<object>("val"));
-
- builder.SetField("val", val);
- Assert.AreEqual(val, builder.GetField<object>("val"));
-
- builder.RemoveField("val");
- Assert.IsNull(builder.GetField<object>("val"));
-
- portObj = builder.Build();
-
- Assert.IsNull(portObj.GetField<object>("val"));
- Assert.IsNull(portObj.Deserialize<Remove>().Val);
-
- // Test correct removal of field being referenced by handle somewhere else.
- RemoveInner inner = new RemoveInner(2);
-
- portObj = _grid.GetBinary().GetBuilder(typeof(Remove))
- .SetField("val", inner)
- .SetField("val2", inner)
- .Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).RemoveField("val").Build();
-
- Remove obj = portObj.Deserialize<Remove>();
-
- Assert.IsNull(obj.Val);
- Assert.AreEqual(2, obj.Val2.Val);
- }
-
- /// <summary>
- /// Test builder-in-builder scenario.
- /// </summary>
- [Test]
- public void TestBuilderInBuilder()
- {
- // Test different builders assembly.
- IBinaryObjectBuilder builderOuter = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter));
- IBinaryObjectBuilder builderInner = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner));
-
- builderOuter.SetField<object>("inner", builderInner);
- builderInner.SetField<object>("outer", builderOuter);
-
- IBinaryObject outerPortObj = builderOuter.Build();
-
- IBinaryType meta = outerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("inner", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
-
- IBinaryObject innerPortObj = outerPortObj.GetField<IBinaryObject>("inner");
-
- meta = innerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderInBuilderInner).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("outer", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("outer"));
-
- BuilderInBuilderOuter outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer, outer.Inner.Outer);
-
- // Test same builders assembly.
- innerPortObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderInner)).Build();
-
- outerPortObj = _grid.GetBinary().GetBuilder(typeof(BuilderInBuilderOuter))
- .SetField("inner", innerPortObj)
- .SetField("inner2", innerPortObj)
- .Build();
-
- meta = outerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderInBuilderOuter).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.IsTrue(meta.Fields.Contains("inner"));
- Assert.IsTrue(meta.Fields.Contains("inner2"));
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner"));
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner2"));
-
- outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer.Inner, outer.Inner2);
-
- builderOuter = _grid.GetBinary().GetBuilder(outerPortObj);
- IBinaryObjectBuilder builderInner2 = builderOuter.GetField<IBinaryObjectBuilder>("inner2");
-
- builderInner2.SetField("outer", builderOuter);
-
- outerPortObj = builderOuter.Build();
-
- outer = outerPortObj.Deserialize<BuilderInBuilderOuter>();
-
- Assert.AreSame(outer, outer.Inner.Outer);
- Assert.AreSame(outer.Inner, outer.Inner2);
- }
-
- /// <summary>
- /// Test for decimals building.
- /// </summary>
- [Test]
- public void TestDecimals()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(DecimalHolder))
- .SetField("val", decimal.One)
- .SetField("valArr", new decimal?[] { decimal.MinusOne })
- .Build();
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(DecimalHolder).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.IsTrue(meta.Fields.Contains("val"));
- Assert.IsTrue(meta.Fields.Contains("valArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameDecimal, meta.GetFieldTypeName("val"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayDecimal, meta.GetFieldTypeName("valArr"));
-
- Assert.AreEqual(decimal.One, portObj.GetField<decimal>("val"));
- Assert.AreEqual(new decimal?[] { decimal.MinusOne }, portObj.GetField<decimal?[]>("valArr"));
-
- DecimalHolder obj = portObj.Deserialize<DecimalHolder>();
-
- Assert.AreEqual(decimal.One, obj.Val);
- Assert.AreEqual(new decimal?[] { decimal.MinusOne }, obj.ValArr);
- }
-
- /// <summary>
- /// Test for an object returning collection of builders.
- /// </summary>
- [Test]
- public void TestBuilderCollection()
- {
- // Test collection with single element.
- IBinaryObjectBuilder builderCol = _grid.GetBinary().GetBuilder(typeof(BuilderCollection));
- IBinaryObjectBuilder builderItem =
- _grid.GetBinary().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
-
- builderCol.SetCollectionField("col", new ArrayList { builderItem });
-
- IBinaryObject portCol = builderCol.Build();
-
- IBinaryType meta = portCol.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderCollection).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("col", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
-
- var portColItems = portCol.GetField<ArrayList>("col");
-
- Assert.AreEqual(1, portColItems.Count);
-
- var portItem = (IBinaryObject) portColItems[0];
-
- meta = portItem.GetBinaryType();
-
- Assert.AreEqual(typeof(BuilderCollectionItem).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual("val", meta.Fields.First());
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("val"));
-
- BuilderCollection col = portCol.Deserialize<BuilderCollection>();
-
- Assert.IsNotNull(col.Col);
- Assert.AreEqual(1, col.Col.Count);
- Assert.AreEqual(1, ((BuilderCollectionItem) col.Col[0]).Val);
-
- // Add more portable objects to collection.
- builderCol = _grid.GetBinary().GetBuilder(portCol);
-
- IList builderColItems = builderCol.GetField<IList>("col");
-
- Assert.AreEqual(1, builderColItems.Count);
-
- BinaryObjectBuilder builderColItem = (BinaryObjectBuilder) builderColItems[0];
-
- builderColItem.SetField("val", 2); // Change nested value.
-
- builderColItems.Add(builderColItem); // Add the same object to check handles.
- builderColItems.Add(builderItem); // Add item from another builder.
- builderColItems.Add(portItem); // Add item in portable form.
-
- portCol = builderCol.Build();
-
- col = portCol.Deserialize<BuilderCollection>();
-
- Assert.AreEqual(4, col.Col.Count);
-
- var item0 = (BuilderCollectionItem) col.Col[0];
- var item1 = (BuilderCollectionItem) col.Col[1];
- var item2 = (BuilderCollectionItem) col.Col[2];
- var item3 = (BuilderCollectionItem) col.Col[3];
-
- Assert.AreEqual(2, item0.Val);
-
- Assert.AreSame(item0, item1);
- Assert.AreNotSame(item0, item2);
- Assert.AreNotSame(item0, item3);
-
- Assert.AreEqual(1, item2.Val);
- Assert.AreEqual(1, item3.Val);
-
- Assert.AreNotSame(item2, item3);
-
- // Test handle update inside collection.
- builderCol = _grid.GetBinary().GetBuilder(portCol);
-
- builderColItems = builderCol.GetField<IList>("col");
-
- ((BinaryObjectBuilder) builderColItems[1]).SetField("val", 3);
-
- portCol = builderCol.Build();
-
- col = portCol.Deserialize<BuilderCollection>();
-
- item0 = (BuilderCollectionItem) col.Col[0];
- item1 = (BuilderCollectionItem) col.Col[1];
-
- Assert.AreEqual(3, item0.Val);
- Assert.AreSame(item0, item1);
- }
-
- /// <summary>
- /// Test build of an empty object.
- /// </summary>
- [Test]
- public void TestEmptyDefined()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Empty)).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.IsNotNull(meta);
- Assert.AreEqual(typeof(Empty).Name, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
-
- Empty obj = portObj.Deserialize<Empty>();
-
- Assert.IsNotNull(obj);
- }
-
- /// <summary>
- /// Test build of an empty object with disabled metadata.
- /// </summary>
- [Test]
- public void TestEmptyNoMeta()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- EmptyNoMeta obj = portObj.Deserialize<EmptyNoMeta>();
-
- Assert.IsNotNull(obj);
- }
-
- /// <summary>
- /// Test build of an empty undefined object.
- /// </summary>
- [Test]
- public void TestEmptyUndefined()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(TypeEmpty).Build();
-
- Assert.IsNotNull(portObj);
- Assert.AreEqual(0, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.IsNotNull(meta);
- Assert.AreEqual(TypeEmpty, meta.TypeName);
- Assert.AreEqual(0, meta.Fields.Count);
- }
-
- /// <summary>
- /// Test object rebuild with no changes.
- /// </summary>
- [Test]
- public void TestEmptyRebuild()
- {
- var portObj = (BinaryObject) _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).Build();
-
- BinaryObject newPortObj = (BinaryObject) _grid.GetBinary().GetBuilder(portObj).Build();
-
- Assert.AreEqual(portObj.Data, newPortObj.Data);
- }
-
- /// <summary>
- /// Test hash code alteration.
- /// </summary>
- [Test]
- public void TestHashCodeChange()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(EmptyNoMeta)).SetHashCode(100).Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
- }
-
- /// <summary>
- /// Test primitive fields setting.
- /// </summary>
- [Test]
- public void TestPrimitiveFields()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(Primitives))
- .SetField<byte>("fByte", 1)
- .SetField("fBool", true)
- .SetField<short>("fShort", 2)
- .SetField("fChar", 'a')
- .SetField("fInt", 3)
- .SetField<long>("fLong", 4)
- .SetField<float>("fFloat", 5)
- .SetField<double>("fDouble", 6)
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(Primitives).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(BinaryTypeNames.TypeNameByte, meta.GetFieldTypeName("fByte"));
- Assert.AreEqual(BinaryTypeNames.TypeNameBool, meta.GetFieldTypeName("fBool"));
- Assert.AreEqual(BinaryTypeNames.TypeNameShort, meta.GetFieldTypeName("fShort"));
- Assert.AreEqual(BinaryTypeNames.TypeNameChar, meta.GetFieldTypeName("fChar"));
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, meta.GetFieldTypeName("fInt"));
- Assert.AreEqual(BinaryTypeNames.TypeNameLong, meta.GetFieldTypeName("fLong"));
- Assert.AreEqual(BinaryTypeNames.TypeNameFloat, meta.GetFieldTypeName("fFloat"));
- Assert.AreEqual(BinaryTypeNames.TypeNameDouble, meta.GetFieldTypeName("fDouble"));
-
- Assert.AreEqual(1, portObj.GetField<byte>("fByte"));
- Assert.AreEqual(true, portObj.GetField<bool>("fBool"));
- Assert.AreEqual(2, portObj.GetField<short>("fShort"));
- Assert.AreEqual('a', portObj.GetField<char>("fChar"));
- Assert.AreEqual(3, portObj.GetField<int>("fInt"));
- Assert.AreEqual(4, portObj.GetField<long>("fLong"));
- Assert.AreEqual(5, portObj.GetField<float>("fFloat"));
- Assert.AreEqual(6, portObj.GetField<double>("fDouble"));
-
- Primitives obj = portObj.Deserialize<Primitives>();
-
- Assert.AreEqual(1, obj.FByte);
- Assert.AreEqual(true, obj.FBool);
- Assert.AreEqual(2, obj.FShort);
- Assert.AreEqual('a', obj.FChar);
- Assert.AreEqual(3, obj.FInt);
- Assert.AreEqual(4, obj.FLong);
- Assert.AreEqual(5, obj.FFloat);
- Assert.AreEqual(6, obj.FDouble);
-
- // Overwrite.
- portObj = _grid.GetBinary().GetBuilder(portObj)
- .SetField<byte>("fByte", 7)
- .SetField("fBool", false)
- .SetField<short>("fShort", 8)
- .SetField("fChar", 'b')
- .SetField("fInt", 9)
- .SetField<long>("fLong", 10)
- .SetField<float>("fFloat", 11)
- .SetField<double>("fDouble", 12)
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual(7, portObj.GetField<byte>("fByte"));
- Assert.AreEqual(false, portObj.GetField<bool>("fBool"));
- Assert.AreEqual(8, portObj.GetField<short>("fShort"));
- Assert.AreEqual('b', portObj.GetField<char>("fChar"));
- Assert.AreEqual(9, portObj.GetField<int>("fInt"));
- Assert.AreEqual(10, portObj.GetField<long>("fLong"));
- Assert.AreEqual(11, portObj.GetField<float>("fFloat"));
- Assert.AreEqual(12, portObj.GetField<double>("fDouble"));
-
- obj = portObj.Deserialize<Primitives>();
-
- Assert.AreEqual(7, obj.FByte);
- Assert.AreEqual(false, obj.FBool);
- Assert.AreEqual(8, obj.FShort);
- Assert.AreEqual('b', obj.FChar);
- Assert.AreEqual(9, obj.FInt);
- Assert.AreEqual(10, obj.FLong);
- Assert.AreEqual(11, obj.FFloat);
- Assert.AreEqual(12, obj.FDouble);
- }
-
- /// <summary>
- /// Test primitive array fields setting.
- /// </summary>
- [Test]
- public void TestPrimitiveArrayFields()
- {
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(PrimitiveArrays))
- .SetField("fByte", new byte[] { 1 })
- .SetField("fBool", new[] { true })
- .SetField("fShort", new short[] { 2 })
- .SetField("fChar", new[] { 'a' })
- .SetField("fInt", new[] { 3 })
- .SetField("fLong", new long[] { 4 })
- .SetField("fFloat", new float[] { 5 })
- .SetField("fDouble", new double[] { 6 })
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(PrimitiveArrays).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayByte, meta.GetFieldTypeName("fByte"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayBool, meta.GetFieldTypeName("fBool"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayShort, meta.GetFieldTypeName("fShort"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayChar, meta.GetFieldTypeName("fChar"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayInt, meta.GetFieldTypeName("fInt"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayLong, meta.GetFieldTypeName("fLong"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayFloat, meta.GetFieldTypeName("fFloat"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayDouble, meta.GetFieldTypeName("fDouble"));
-
- Assert.AreEqual(new byte[] { 1 }, portObj.GetField<byte[]>("fByte"));
- Assert.AreEqual(new[] { true }, portObj.GetField<bool[]>("fBool"));
- Assert.AreEqual(new short[] { 2 }, portObj.GetField<short[]>("fShort"));
- Assert.AreEqual(new[] { 'a' }, portObj.GetField<char[]>("fChar"));
- Assert.AreEqual(new[] { 3 }, portObj.GetField<int[]>("fInt"));
- Assert.AreEqual(new long[] { 4 }, portObj.GetField<long[]>("fLong"));
- Assert.AreEqual(new float[] { 5 }, portObj.GetField<float[]>("fFloat"));
- Assert.AreEqual(new double[] { 6 }, portObj.GetField<double[]>("fDouble"));
-
- PrimitiveArrays obj = portObj.Deserialize<PrimitiveArrays>();
-
- Assert.AreEqual(new byte[] { 1 }, obj.FByte);
- Assert.AreEqual(new[] { true }, obj.FBool);
- Assert.AreEqual(new short[] { 2 }, obj.FShort);
- Assert.AreEqual(new[] { 'a' }, obj.FChar);
- Assert.AreEqual(new[] { 3 }, obj.FInt);
- Assert.AreEqual(new long[] { 4 }, obj.FLong);
- Assert.AreEqual(new float[] { 5 }, obj.FFloat);
- Assert.AreEqual(new double[] { 6 }, obj.FDouble);
-
- // Overwrite.
- portObj = _grid.GetBinary().GetBuilder(portObj)
- .SetField("fByte", new byte[] { 7 })
- .SetField("fBool", new[] { false })
- .SetField("fShort", new short[] { 8 })
- .SetField("fChar", new[] { 'b' })
- .SetField("fInt", new[] { 9 })
- .SetField("fLong", new long[] { 10 })
- .SetField("fFloat", new float[] { 11 })
- .SetField("fDouble", new double[] { 12 })
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual(new byte[] { 7 }, portObj.GetField<byte[]>("fByte"));
- Assert.AreEqual(new[] { false }, portObj.GetField<bool[]>("fBool"));
- Assert.AreEqual(new short[] { 8 }, portObj.GetField<short[]>("fShort"));
- Assert.AreEqual(new[] { 'b' }, portObj.GetField<char[]>("fChar"));
- Assert.AreEqual(new[] { 9 }, portObj.GetField<int[]>("fInt"));
- Assert.AreEqual(new long[] { 10 }, portObj.GetField<long[]>("fLong"));
- Assert.AreEqual(new float[] { 11 }, portObj.GetField<float[]>("fFloat"));
- Assert.AreEqual(new double[] { 12 }, portObj.GetField<double[]>("fDouble"));
-
- obj = portObj.Deserialize<PrimitiveArrays>();
-
- Assert.AreEqual(new byte[] { 7 }, obj.FByte);
- Assert.AreEqual(new[] { false }, obj.FBool);
- Assert.AreEqual(new short[] { 8 }, obj.FShort);
- Assert.AreEqual(new[] { 'b' }, obj.FChar);
- Assert.AreEqual(new[] { 9 }, obj.FInt);
- Assert.AreEqual(new long[] { 10 }, obj.FLong);
- Assert.AreEqual(new float[] { 11 }, obj.FFloat);
- Assert.AreEqual(new double[] { 12 }, obj.FDouble);
- }
-
- /// <summary>
- /// Test non-primitive fields and their array counterparts.
- /// </summary>
- [Test]
- public void TestStringDateGuidEnum()
- {
- DateTime? nDate = DateTime.Now;
-
- Guid? nGuid = Guid.NewGuid();
-
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(StringDateGuidEnum))
- .SetField("fStr", "str")
- .SetField("fNDate", nDate)
- .SetGuidField("fNGuid", nGuid)
- .SetField("fEnum", TestEnum.One)
- .SetField("fStrArr", new[] { "str" })
- .SetArrayField("fDateArr", new[] { nDate })
- .SetGuidArrayField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.One })
- .SetHashCode(100)
- .Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
-
- Assert.AreEqual(8, meta.Fields.Count);
-
- Assert.AreEqual(BinaryTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
- Assert.AreEqual(BinaryTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
- Assert.AreEqual(BinaryTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
-
- Assert.AreEqual("str", portObj.GetField<string>("fStr"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.One }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- StringDateGuidEnum obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str", obj.FStr);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.One, obj.FEnum);
- Assert.AreEqual(new[] { "str" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
-
- // Check builder field caching.
- var builder = _grid.GetBinary().GetBuilder(portObj);
-
- Assert.AreEqual("str", builder.GetField<string>("fStr"));
- Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, builder.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.One, builder.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, builder.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, builder.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, builder.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.One }, builder.GetField<TestEnum[]>("fEnumArr"));
-
- // Check reassemble.
- portObj = builder.Build();
-
- Assert.AreEqual("str", portObj.GetField<string>("fStr"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.One }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str", obj.FStr);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.One, obj.FEnum);
- Assert.AreEqual(new[] { "str" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
-
- // Overwrite.
- nDate = DateTime.Now.ToUniversalTime();
- nGuid = Guid.NewGuid();
-
- portObj = builder
- .SetField("fStr", "str2")
- .SetTimestampField("fNDate", nDate)
- .SetField("fNGuid", nGuid)
- .SetField("fEnum", TestEnum.Two)
- .SetField("fStrArr", new[] { "str2" })
- .SetArrayField("fDateArr", new[] { nDate })
- .SetField("fGuidArr", new[] { nGuid })
- .SetField("fEnumArr", new[] { TestEnum.Two })
- .SetHashCode(200)
- .Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- Assert.AreEqual("str2", portObj.GetField<string>("fStr"));
- Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
- Assert.AreEqual(TestEnum.Two, portObj.GetField<TestEnum>("fEnum"));
- Assert.AreEqual(new[] { "str2" }, portObj.GetField<string[]>("fStrArr"));
- Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
- Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
- Assert.AreEqual(new[] { TestEnum.Two }, portObj.GetField<TestEnum[]>("fEnumArr"));
-
- obj = portObj.Deserialize<StringDateGuidEnum>();
-
- Assert.AreEqual("str2", obj.FStr);
- Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(nGuid, obj.FnGuid);
- Assert.AreEqual(TestEnum.Two, obj.FEnum);
- Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
- Assert.AreEqual(new[] { nDate }, obj.FDateArr);
- Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
- Assert.AreEqual(new[] { TestEnum.Two }, obj.FEnumArr);
- }
-
- /// <summary>
- /// Test arrays.
- /// </summary>
- [Test]
- public void TestCompositeArray()
- {
- // 1. Test simple array.
- object[] inArr = { new CompositeInner(1) };
-
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("inArr", inArr).Build();
-
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- IBinaryObject[] portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(1, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
-
- CompositeArray arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(1, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
-
- // 2. Test addition to array.
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", new object[] { portInArr[0], null }).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.IsNull(portInArr[1]);
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
- Assert.IsNull(arr.InArr[1]);
-
- portInArr[1] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(300)
- .SetField("inArr", portInArr.OfType<object>().ToArray()).Build();
-
- Assert.AreEqual(300, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(2, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
- Assert.AreEqual(2, ((CompositeInner)arr.InArr[1]).Val);
-
- // 3. Test top-level handle inversion.
- CompositeInner inner = new CompositeInner(1);
-
- inArr = new object[] { inner, inner };
-
- portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("inArr", inArr).Build();
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
-
- portInArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", portInArr.ToArray<object>()).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("inArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(2, portInArr[0].GetField<int>("val"));
- Assert.AreEqual(1, portInArr[1].GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.OutArr);
- Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(2, ((CompositeInner)arr.InArr[0]).Val);
- Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
-
- // 4. Test nested object handle inversion.
- CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
-
- portObj = _grid.GetBinary().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("outArr", outArr.ToArray<object>()).Build();
-
- meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(CompositeArray).Name, meta.TypeName);
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("inArr"));
- Assert.AreEqual(BinaryTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("outArr"));
-
- Assert.AreEqual(100, portObj.GetHashCode());
-
- var portOutArr = portObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portOutArr.Length);
- Assert.AreEqual(1, portOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
- Assert.AreEqual(1, portOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.InArr);
- Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
- Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
-
- portOutArr[0] = _grid.GetBinary().GetBuilder(typeof(CompositeOuter))
- .SetField("inner", new CompositeInner(2)).Build();
-
- portObj = _grid.GetBinary().GetBuilder(portObj).SetHashCode(200)
- .SetField("outArr", portOutArr.ToArray<object>()).Build();
-
- Assert.AreEqual(200, portObj.GetHashCode());
-
- portInArr = portObj.GetField<object[]>("outArr").Cast<IBinaryObject>().ToArray();
-
- Assert.AreEqual(2, portInArr.Length);
- Assert.AreEqual(2, portOutArr[0].GetField<IBinaryObject>("inner").GetField<int>("val"));
- Assert.AreEqual(1, portOutArr[1].GetField<IBinaryObject>("inner").GetField<int>("val"));
-
- arr = portObj.Deserialize<CompositeArray>();
-
- Assert.IsNull(arr.InArr);
- Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(2, ((CompositeOuter)arr.OutArr[0]).Inner.Val);
- Assert.AreEqual(1, ((CompositeOuter)arr.OutArr[1]).Inner.Val);
- }
-
- /// <summary>
- /// Test container types other than array.
- /// </summary>
- [Test]
- public void TestCompositeContainer()
- {
- ArrayList col = new ArrayList();
- IDictionary dict = new Hashtable();
-
- col.Add(new CompositeInner(1));
- dict[3] = new CompositeInner(3);
-
- IBinaryObject portObj = _grid.GetBinary().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
- .SetCollectionField("col", col)
- .SetDictionaryField("dict", dict).Build();
-
- // 1. Check meta.
- IBinaryType meta = portObj.GetBinaryType();
-
- Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
-
- Assert.AreEqual(2, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
- Assert.AreEqual(BinaryTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
-
- // 2. Check in portable form.
- Assert.AreEqual(1, portObj.GetField<ICollection>("col").Count);
- Assert.AreEqual(1, portObj.GetField<ICollection>("col").OfType<IBinaryObject>().First()
- .GetField<int>("val"));
-
- Assert.AreEqual(1, portObj.GetField<IDictionary>("dict").Count);
- Assert.AreEqual(3, ((IBinaryObject) portObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
-
- // 3. Check in deserialized form.
- CompositeContainer obj = portObj.Deserialize<CompositeContainer>();
-
- Assert.AreEqual(1, obj.Col.Count);
- Assert.AreEqual(1, obj.Col.OfType<CompositeInner>().First().Val);
-
- Assert.AreEqual(1, obj.Dict.Count);
- Assert.AreEqual(3, ((CompositeInner) obj.Dict[3]).Val);
- }
-
- /// <summary>
- /// Ensure that raw data is not lost during build.
- /// </summary>
- [Test]
- public void TestRawData()
- {
- var raw = new WithRaw
- {
- A = 1,
- B = 2
- };
-
- var portObj = _marsh.Unmarshal<IBinaryObject>(_marsh.Marshal(raw), BinaryMode.ForceBinary);
-
- raw = portObj.Deserialize<WithRaw>();
-
- Assert.AreEqual(1, raw.A);
- Assert.AreEqual(2, raw.B);
-
- IBinaryObject newPortObj = _grid.GetBinary().GetBuilder(portObj).SetField("a", 3).Build();
-
- raw = newPortObj.Deserialize<WithRaw>();
-
- Assert.AreEqual(3, raw.A);
- Assert.AreEqual(2, raw.B);
- }
-
- /// <summary>
- /// Test nested objects.
- /// </summary>
- [Test]
- public void TestNested()
- {
- // 1. Create from scratch.
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(NestedOuter));
-
- NestedInner inner1 = new NestedInner {Val = 1};
- builder.SetField("inner1", inner1);
-
- IBinaryObject outerPortObj = builder.Build();
-
- IBinaryType meta = outerPortObj.GetBinaryType();
-
- Assert.AreEqual(typeof(NestedOuter).Name, meta.TypeName);
- Assert.AreEqual(1, meta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameObject, meta.GetFieldTypeName("inner1"));
-
- IBinaryObject innerPortObj1 = outerPortObj.GetField<IBinaryObject>("inner1");
-
- IBinaryType innerMeta = innerPortObj1.GetBinaryType();
-
- Assert.AreEqual(typeof(NestedInner).Name, innerMeta.TypeName);
- Assert.AreEqual(1, innerMeta.Fields.Count);
- Assert.AreEqual(BinaryTypeNames.TypeNameInt, innerMeta.GetFieldTypeName("Val"));
-
- inner1 = innerPortObj1.Deserialize<NestedInner>();
-
- Assert.AreEqual(1, inner1.Val);
-
- NestedOuter outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(outer.Inner1.Val, 1);
- Assert.IsNull(outer.Inner2);
-
- // 2. Add another field over existing portable object.
- builder = _grid.GetBinary().GetBuilder(outerPortObj);
-
- NestedInner inner2 = new NestedInner {Val = 2};
- builder.SetField("inner2", inner2);
-
- outerPortObj = builder.Build();
-
- outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(1, outer.Inner1.Val);
- Assert.AreEqual(2, outer.Inner2.Val);
-
- // 3. Try setting inner object in portable form.
- innerPortObj1 = _grid.GetBinary().GetBuilder(innerPortObj1).SetField("val", 3).Build();
-
- inner1 = innerPortObj1.Deserialize<NestedInner>();
-
- Assert.AreEqual(3, inner1.Val);
-
- outerPortObj = _grid.GetBinary().GetBuilder(outerPortObj).SetField<object>("inner1", innerPortObj1).Build();
-
- outer = outerPortObj.Deserialize<NestedOuter>();
- Assert.AreEqual(3, outer.Inner1.Val);
- Assert.AreEqual(2, outer.Inner2.Val);
- }
-
- /// <summary>
- /// Test handle migration.
- /// </summary>
- [Test]
- public void TestHandleMigration()
- {
- // 1. Simple comparison of results.
- MigrationInner inner = new MigrationInner {Val = 1};
-
- MigrationOuter outer = new MigrationOuter
- {
- Inner1 = inner,
- Inner2 = inner
- };
-
- byte[] outerBytes = _marsh.Marshal(outer);
-
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(MigrationOuter));
-
- builder.SetHashCode(outer.GetHashCode());
-
- builder.SetField<object>("inner1", inner);
- builder.SetField<object>("inner2", inner);
-
- BinaryObject portOuter = (BinaryObject) builder.Build();
-
- byte[] portOuterBytes = new byte[outerBytes.Length];
-
- Buffer.BlockCopy(portOuter.Data, 0, portOuterBytes, 0, portOuterBytes.Length);
-
- Assert.AreEqual(outerBytes, portOuterBytes);
-
- // 2. Change the first inner object so that the handle must migrate.
- MigrationInner inner1 = new MigrationInner {Val = 2};
-
- IBinaryObject portOuterMigrated =
- _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1).Build();
-
- MigrationOuter outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
-
- Assert.AreEqual(2, outerMigrated.Inner1.Val);
- Assert.AreEqual(1, outerMigrated.Inner2.Val);
-
- // 3. Change the first value using serialized form.
- IBinaryObject inner1Port =
- _grid.GetBinary().GetBuilder(typeof(MigrationInner)).SetField("val", 2).Build();
-
- portOuterMigrated =
- _grid.GetBinary().GetBuilder(portOuter).SetField<object>("inner1", inner1Port).Build();
-
- outerMigrated = portOuterMigrated.Deserialize<MigrationOuter>();
-
- Assert.AreEqual(2, outerMigrated.Inner1.Val);
- Assert.AreEqual(1, outerMigrated.Inner2.Val);
- }
-
- /// <summary>
- /// Test handle inversion.
- /// </summary>
- [Test]
- public void TestHandleInversion()
- {
- InversionInner inner = new InversionInner();
- InversionOuter outer = new InversionOuter();
-
- inner.Outer = outer;
- outer.Inner = inner;
-
- byte[] rawOuter = _marsh.Marshal(outer);
-
- IBinaryObject portOuter = _marsh.Unmarshal<IBinaryObject>(rawOuter, BinaryMode.ForceBinary);
- IBinaryObject portInner = portOuter.GetField<IBinaryObject>("inner");
-
- // 1. Ensure that inner object can be deserialized after build.
- IBinaryObject portInnerNew = _grid.GetBinary().GetBuilder(portInner).Build();
-
- InversionInner innerNew = portInnerNew.Deserialize<InversionInner>();
-
- Assert.AreSame(innerNew, innerNew.Outer.Inner);
-
- // 2. Ensure that portable object with external dependencies could be added to builder.
- IBinaryObject portOuterNew =
- _grid.GetBinary().GetBuilder(typeof(InversionOuter)).SetField<object>("inner", portInner).Build();
-
- InversionOuter outerNew = portOuterNew.Deserialize<InversionOuter>();
-
- Assert.AreNotSame(outerNew, outerNew.Inner.Outer);
- Assert.AreSame(outerNew.Inner, outerNew.Inner.Outer.Inner);
- }
-
- /// <summary>
- /// Test build multiple objects.
- /// </summary>
- [Test]
- public void TestBuildMultiple()
- {
- IBinaryObjectBuilder builder = _grid.GetBinary().GetBuilder(typeof(Primitives));
-
- builder.SetField<byte>("fByte", 1).SetField("fBool", true);
-
- IBinaryObject po1 = builder.Build();
- IBinaryObject po2 = builder.Build();
-
- Assert.AreEqual(1, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(1, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- builder.SetField<byte>("fByte", 2);
-
- IBinaryObject po3 = builder.Build();
-
- Assert.AreEqual(1, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(1, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- Assert.AreEqual(2, po3.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- builder = _grid.GetBinary().GetBuilder(po1);
-
- builder.SetField<byte>("fByte", 10);
-
- po1 = builder.Build();
- po2 = builder.Build();
-
- builder.SetField<byte>("fByte", 20);
-
- po3 = builder.Build();
-
- Assert.AreEqual(10, po1.GetField<byte>("fByte"));
- Assert.AreEqual(true, po1.GetField<bool>("fBool"));
-
- Assert.AreEqual(10, po2.GetField<byte>("fByte"));
- Assert.AreEqual(true, po2.GetField<bool>("fBool"));
-
- Assert.AreEqual(20, po3.GetField<byte>("fByte"));
- Assert.AreEqual(true, po3.GetField<bool>("fBool"));
- }
-
- /// <summary>
- /// Tests type id method.
- /// </summary>
- [Test]
- public void TestTypeId()
- {
- Assert.Throws<ArgumentException>(() => _grid.GetBinary().GetTypeId(null));
-
- Assert.AreEqual(IdMapper.TestTypeId, _grid.GetBinary().GetTypeId(IdMapper.TestTypeName));
-
- Assert.AreEqual(BinaryUtils.GetStringHashCode("someTypeName"), _grid.GetBinary().GetTypeId("someTypeName"));
- }
-
- /// <summary>
- /// Tests metadata methods.
- /// </summary>
- [Test]
- public void TestMetadata()
- {
- // Populate metadata
- var portables = _grid.GetBinary();
-
- portables.ToBinary<IBinaryObject>(new DecimalHolder());
-
- // All meta
- var allMetas = portables.GetBinaryTypes();
-
- var decimalMeta = allMetas.Single(x => x.TypeName == "DecimalHolder");
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type
- decimalMeta = portables.GetBinaryType(typeof (DecimalHolder));
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type id
- decimalMeta = portables.GetBinaryType(portables.GetTypeId("DecimalHolder"));
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
-
- // By type name
- decimalMeta = portables.GetBinaryType("DecimalHolder");
-
- Assert.AreEqual(new[] {"val", "valArr"}, decimalMeta.Fields);
- }
-
- /// <summary>
- /// Create portable type configuration with disabled metadata.
- /// </summary>
- /// <param name="typ">Type.</param>
- /// <returns>Configuration.</returns>
- private static BinaryTypeConfiguration TypeConfigurationNoMeta(Type typ)
- {
- return new BinaryTypeConfiguration(typ);
- }
- }
-
- /// <summary>
- /// Empty portable class.
- /// </summary>
- public class Empty
- {
- // No-op.
- }
-
- /// <summary>
- /// Empty portable class with no metadata.
- /// </summary>
- public class EmptyNoMeta
- {
- // No-op.
- }
-
- /// <summary>
- /// Portable with primitive fields.
- /// </summary>
- public class Primitives
- {
- public byte FByte;
- public bool FBool;
- public short FShort;
- public char FChar;
- public int FInt;
- public long FLong;
- public float FFloat;
- public double FDouble;
- }
-
- /// <summary>
- /// Portable with primitive array fields.
- /// </summary>
- public class PrimitiveArrays
- {
- public byte[] FByte;
- public bool[] FBool;
- public short[] FShort;
- public char[] FChar;
- public int[] FInt;
- public long[] FLong;
- public float[] FFloat;
- public double[] FDouble;
- }
-
- /// <summary>
- /// Portable having strings, dates, Guids and enums.
- /// </summary>
- public class StringDateGuidEnum
- {
- public string FStr;
- public DateTime? FnDate;
- public Guid? FnGuid;
- public TestEnum FEnum;
-
- public string[] FStrArr;
- public DateTime?[] FDateArr;
- public Guid?[] FGuidArr;
- public TestEnum[] FEnumArr;
- }
-
- /// <summary>
- /// Enumeration.
- /// </summary>
- public enum TestEnum
- {
- One, Two
- }
-
- /// <summary>
- /// Portable with raw data.
- /// </summary>
- public class WithRaw : IBinarizable
- {
- public int A;
- public int B;
-
- /** <inheritDoc /> */
- public void WriteBinary(IBinaryWriter writer)
- {
- writer.WriteInt("a", A);
- writer.GetRawWriter().WriteInt(B);
- }
-
- /** <inheritDoc /> */
- public void ReadBinary(IBinaryReader reader)
- {
- A = reader.ReadInt("a");
- B = reader.GetRawReader().ReadInt();
- }
- }
-
- /// <summary>
- /// Empty class for metadata overwrite test.
- /// </summary>
- public class MetaOverwrite
- {
- // No-op.
- }
-
- /// <summary>
- /// Nested outer object.
- /// </summary>
- public class NestedOuter
- {
- public NestedInner Inner1;
- public NestedInner Inner2;
- }
-
- /// <summary>
- /// Nested inner object.
- /// </summary>
- public class NestedInner
- {
- public int Val;
- }
-
- /// <summary>
- /// Outer object for handle migration test.
- /// </summary>
- public class MigrationOuter
- {
- public MigrationInner Inner1;
- public MigrationInner Inner2;
- }
-
- /// <summary>
- /// Inner object for handle migration test.
- /// </summary>
- public class MigrationInner
- {
- public int Val;
- }
-
- /// <summary>
- /// Outer object for handle inversion test.
- /// </summary>
- public class InversionOuter
- {
- public InversionInner Inner;
- }
-
- /// <summary>
- /// Inner object for handle inversion test.
- /// </summary>
- public class InversionInner
- {
- public InversionOuter Outer;
- }
-
- /// <summary>
- /// Object for composite array tests.
- /// </summary>
- public class CompositeArray
- {
- public object[] InArr;
- public object[] OutArr;
- }
-
- /// <summary>
- /// Object for composite collection/dictionary tests.
- /// </summary>
- public class CompositeContainer
- {
- public ICollection Col;
- public IDictionary Dict;
- }
-
- /// <summary>
- /// OUter object for composite structures test.
- /// </summary>
- public class CompositeOuter
- {
- public CompositeInner Inner;
-
- public CompositeOuter()
- {
- // No-op.
- }
-
- public CompositeOuter(CompositeInner inner)
- {
- Inner = inner;
- }
- }
-
- /// <summary>
- /// Inner object for composite structures test.
- /// </summary>
- public class CompositeInner
- {
- public int Val;
-
- public CompositeInner()
- {
- // No-op.
- }
-
- public CompositeInner(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test "ToPortable()" logic.
- /// </summary>
- public class ToPortable
- {
- public int Val;
-
- public ToPortable(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test "ToPortable()" logic with metadata disabled.
- /// </summary>
- public class ToPortableNoMeta
- {
- public int Val;
-
- public ToPortableNoMeta(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- /// Type to test removal.
- /// </summary>
- public class Remove
- {
- public object Val;
- public RemoveInner Val2;
- }
-
- /// <summary>
- /// Inner type to test removal.
- /// </summary>
- public class RemoveInner
- {
- /** */
- public int Val;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="val"></param>
- public RemoveInner(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderInBuilderOuter
- {
- /** */
- public BuilderInBuilderInner Inner;
-
- /** */
- public BuilderInBuilderInner Inner2;
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderInBuilderInner
- {
- /** */
- public BuilderInBuilderOuter Outer;
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderCollection
- {
- /** */
- public readonly ArrayList Col;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="col"></param>
- public BuilderCollection(ArrayList col)
- {
- Col = col;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class BuilderCollectionItem
- {
- /** */
- public int Val;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="val"></param>
- public BuilderCollectionItem(int val)
- {
- Val = val;
- }
- }
-
- /// <summary>
- ///
- /// </summary>
- public class DecimalHolder
- {
- /** */
- public decimal Val;
-
- /** */
- public decimal?[] ValArr;
- }
-
- /// <summary>
- /// Test id mapper.
- /// </summary>
- public class IdMapper : IBinaryIdMapper
- {
- /** */
- public const string TestTypeName = "IdMapperTestType";
-
- /** */
- public const int TestTypeId = -65537;
-
- /** <inheritdoc /> */
- public int GetTypeId(string typeName)
- {
- return typeName == TestTypeName ? TestTypeId : 0;
- }
-
- /** <inheritdoc /> */
- public int GetFieldId(int typeId, string fieldName)
- {
- return 0;
- }
- }
-}
[06/55] [abbrv] ignite git commit: IGNITE-1881: Internal portable ->
binary renamings.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
new file mode 100644
index 0000000..102afd1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -0,0 +1,2157 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable NonReadonlyMemberInGetHashCode
+// ReSharper disable CompareOfFloatsByEqualityOperator
+// ReSharper disable PossibleInvalidOperationException
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Tests.Binary
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ 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;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixture]
+ public class BinarySelfTest {
+ /** */
+ private Marshaller _marsh;
+
+ /// <summary>
+ ///
+ /// </summary>
+ [TestFixtureSetUp]
+ public void BeforeTest()
+ {
+ _marsh = new Marshaller(null);
+ }
+
+ /**
+ * <summary>Check write of primitive boolean.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveBool()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(false)), false);
+ Assert.AreEqual(_marsh.Unmarshal<bool>(_marsh.Marshal(true)), true);
+
+ Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)false)), false);
+ Assert.AreEqual(_marsh.Unmarshal<bool?>(_marsh.Marshal((bool?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive boolean array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveBoolArray()
+ {
+ bool[] vals = { true, false };
+
+ Assert.AreEqual(_marsh.Unmarshal<bool[]>(_marsh.Marshal(vals)), vals);
+
+ bool?[] vals2 = { true, false };
+
+ Assert.AreEqual(_marsh.Unmarshal<bool?[]>(_marsh.Marshal(vals2)), vals2);
+ }
+
+ /**
+ * <summary>Check write of primitive sbyte.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveSbyte()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal((sbyte)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MinValue)), sbyte.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte>(_marsh.Marshal(sbyte.MaxValue)), sbyte.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)1)), (sbyte?)1);
+ Assert.AreEqual(_marsh.Unmarshal<sbyte?>(_marsh.Marshal((sbyte?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive sbyte array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveSbyteArray()
+ {
+ sbyte[] vals = { sbyte.MinValue, 0, 1, sbyte.MaxValue };
+ sbyte[] newVals = _marsh.Unmarshal<sbyte[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive byte.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveByte()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal((byte)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MinValue)), byte.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<byte>(_marsh.Marshal(byte.MaxValue)), byte.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)1)), (byte?)1);
+ Assert.AreEqual(_marsh.Unmarshal<byte?>(_marsh.Marshal((byte?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive byte array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveByteArray()
+ {
+ byte[] vals = { byte.MinValue, 0, 1, byte.MaxValue };
+ byte[] newVals = _marsh.Unmarshal<byte[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive short.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveShort()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal((short)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MinValue)), short.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<short>(_marsh.Marshal(short.MaxValue)), short.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)1)), (short?)1);
+ Assert.AreEqual(_marsh.Unmarshal<short?>(_marsh.Marshal((short?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive short array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveShortArray()
+ {
+ short[] vals = { short.MinValue, 0, 1, short.MaxValue };
+ short[] newVals = _marsh.Unmarshal<short[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive ushort.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUshort()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal((ushort)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MinValue)), ushort.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<ushort>(_marsh.Marshal(ushort.MaxValue)), ushort.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)1)), (ushort?)1);
+ Assert.AreEqual(_marsh.Unmarshal<ushort?>(_marsh.Marshal((ushort?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive short array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUshortArray()
+ {
+ ushort[] vals = { ushort.MinValue, 0, 1, ushort.MaxValue };
+ ushort[] newVals = _marsh.Unmarshal<ushort[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive char.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveChar()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal((char)1)), (char)1);
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MinValue)), char.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<char>(_marsh.Marshal(char.MaxValue)), char.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)1)), (char?)1);
+ Assert.AreEqual(_marsh.Unmarshal<char?>(_marsh.Marshal((char?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveCharArray()
+ {
+ char[] vals = { char.MinValue, (char)0, (char)1, char.MaxValue };
+ char[] newVals = _marsh.Unmarshal<char[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive int.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveInt()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MinValue)), int.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<int>(_marsh.Marshal(int.MaxValue)), int.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)1)), (int?)1);
+ Assert.AreEqual(_marsh.Unmarshal<int?>(_marsh.Marshal((int?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveIntArray()
+ {
+ int[] vals = { int.MinValue, 0, 1, int.MaxValue };
+ int[] newVals = _marsh.Unmarshal<int[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive uint.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUint()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal((uint)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MinValue)), uint.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<uint>(_marsh.Marshal(uint.MaxValue)), uint.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)1)), (int?)1);
+ Assert.AreEqual(_marsh.Unmarshal<uint?>(_marsh.Marshal((uint?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive uint array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUintArray()
+ {
+ uint[] vals = { uint.MinValue, 0, 1, uint.MaxValue };
+ uint[] newVals = _marsh.Unmarshal<uint[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive long.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveLong()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal((long)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MinValue)), long.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<long>(_marsh.Marshal(long.MaxValue)), long.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)1)), (long?)1);
+ Assert.AreEqual(_marsh.Unmarshal<long?>(_marsh.Marshal((long?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive long array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveLongArray()
+ {
+ long[] vals = { long.MinValue, 0, 1, long.MaxValue };
+ long[] newVals = _marsh.Unmarshal<long[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive ulong.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUlong()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal((ulong)1)), 1);
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MinValue)), ulong.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<ulong>(_marsh.Marshal(ulong.MaxValue)), ulong.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)1)), (ulong?)1);
+ Assert.AreEqual(_marsh.Unmarshal<ulong?>(_marsh.Marshal((ulong?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive ulong array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveUlongArray()
+ {
+ ulong[] vals = { ulong.MinValue, 0, 1, ulong.MaxValue };
+ ulong[] newVals = _marsh.Unmarshal<ulong[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive float.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveFloat()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal((float)1)), (float)1);
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MinValue)), float.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<float>(_marsh.Marshal(float.MaxValue)), float.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)1)), (float?)1);
+ Assert.AreEqual(_marsh.Unmarshal<float?>(_marsh.Marshal((float?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive float array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveFloatArray()
+ {
+ float[] vals = { float.MinValue, 0, 1, float.MaxValue };
+ float[] newVals = _marsh.Unmarshal<float[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of primitive double.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDouble()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal((double)1)), (double)1);
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MinValue)), double.MinValue);
+ Assert.AreEqual(_marsh.Unmarshal<double>(_marsh.Marshal(double.MaxValue)), double.MaxValue);
+
+ Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)1)), (double?)1);
+ Assert.AreEqual(_marsh.Unmarshal<double?>(_marsh.Marshal((double?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of primitive double array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDoubleArray()
+ {
+ double[] vals = { double.MinValue, 0, 1, double.MaxValue };
+ double[] newVals = _marsh.Unmarshal<double[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of decimal.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDecimal()
+ {
+ decimal val;
+
+ // Test positibe and negative.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Zero)), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 0, 0, true, 0))), val);
+
+ // Test 32, 64 and 96 bits + mixed.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 1, 0, true, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(0, 0, 1, true, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, false, 0))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = new decimal(1, 1, 1, true, 0))), val);
+
+ // Test extremes.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("65536"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-65536"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("4294967296"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-4294967296"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("281474976710656"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-281474976710656"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("18446744073709551616"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-18446744073709551616"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("1208925819614629174706176"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-1208925819614629174706176"))), val);
+
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MaxValue)), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.MinValue)), val);
+
+ // Test scale.
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("11,12"))), val);
+ Assert.AreEqual(_marsh.Unmarshal<decimal>(_marsh.Marshal(val = decimal.Parse("-11,12"))), val);
+
+ // Test null.
+ Assert.AreEqual(_marsh.Unmarshal<decimal?>(_marsh.Marshal((decimal?)null)), null);
+ }
+
+ /**
+ * <summary>Check write of decimal array.</summary>
+ */
+ [Test]
+ public void TestWritePrimitiveDecimalArray()
+ {
+ decimal?[] vals = { decimal.One, decimal.Parse("11,12") };
+ var newVals = _marsh.Unmarshal<decimal?[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of string.</summary>
+ */
+ [Test]
+ public void TestWriteString()
+ {
+ Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal("str")), "str");
+ Assert.AreEqual(_marsh.Unmarshal<string>(_marsh.Marshal((string) null)), null);
+ }
+
+ /**
+ * <summary>Check write of string array.</summary>
+ */
+ [Test]
+ public void TestWriteStringArray()
+ {
+ string[] vals = { "str1", null, "", "str2", null};
+ string[] newVals = _marsh.Unmarshal<string[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of Guid.</summary>
+ */
+ [Test]
+ public void TestWriteGuid()
+ {
+ Guid guid = Guid.NewGuid();
+ Guid? nGuid = guid;
+
+ Assert.AreEqual(_marsh.Unmarshal<Guid>(_marsh.Marshal(guid)), guid);
+ Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), nGuid);
+
+ nGuid = null;
+
+ // ReSharper disable once ExpressionIsAlwaysNull
+ Assert.AreEqual(_marsh.Unmarshal<Guid?>(_marsh.Marshal(nGuid)), null);
+ }
+
+ /**
+ * <summary>Check write of string array.</summary>
+ */
+ [Test]
+ public void TestWriteGuidArray()
+ {
+ Guid?[] vals = { Guid.NewGuid(), null, Guid.Empty, Guid.NewGuid(), null };
+ Guid?[] newVals = _marsh.Unmarshal<Guid?[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /**
+ * <summary>Check write of enum.</summary>
+ */
+ [Test]
+ public void TestWriteEnum()
+ {
+ TestEnum val = TestEnum.Val1;
+
+ Assert.AreEqual(_marsh.Unmarshal<TestEnum>(_marsh.Marshal(val)), val);
+ }
+
+ /**
+ * <summary>Check write of enum.</summary>
+ */
+ [Test]
+ public void TestWriteEnumArray()
+ {
+ TestEnum[] vals = { TestEnum.Val2, TestEnum.Val3 };
+ TestEnum[] newVals = _marsh.Unmarshal<TestEnum[]>(_marsh.Marshal(vals));
+
+ Assert.AreEqual(vals, newVals);
+ }
+
+ /// <summary>
+ /// Test object with dates.
+ /// </summary>
+ [Test]
+ public void TestDateObject()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(DateTimeType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ DateTime now = DateTime.Now;
+
+ DateTimeType obj = new DateTimeType(now);
+
+ DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
+
+ Assert.AreEqual(obj.Utc, otherObj.Utc);
+ Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
+ Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
+
+ Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
+ Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
+ Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
+ }
+
+ /// <summary>
+ /// Tests the DateTime marshalling.
+ /// </summary>
+ [Test]
+ public void TestDateTime()
+ {
+ var time = DateTime.Now;
+ Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
+
+ var timeUtc = DateTime.UtcNow;
+ Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), timeUtc);
+
+ // Check exception with non-UTC date
+ var stream = new BinaryHeapStream(128);
+ var writer = _marsh.StartMarshal(stream);
+ Assert.Throws<InvalidOperationException>(() => writer.WriteTimestamp(DateTime.Now));
+ }
+
+ /**
+ * <summary>Check generic collections.</summary>
+ */
+ [Test]
+ public void TestGenericCollections()
+ {
+ var list = new List<string> {"1"};
+
+ var data = _marsh.Marshal(list);
+
+ var newObjList = _marsh.Unmarshal<IList<string>>(data);
+
+ CollectionAssert.AreEquivalent(list, newObjList);
+ }
+
+ /// <summary>
+ /// Tests marshal aware type with generic collections.
+ /// </summary>
+ [Test]
+ public void TestGenericCollectionsType()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (PrimitiveFieldType)),
+ new BinaryTypeConfiguration(typeof (GenericCollectionsType<PrimitiveFieldType, SerializableObject>))
+ }
+ });
+
+ var obj = new GenericCollectionsType<PrimitiveFieldType, SerializableObject>
+ {
+ Keys = new[] {new PrimitiveFieldType(), new PrimitiveFieldType()},
+ Values =
+ new List<SerializableObject>
+ {
+ new SerializableObject {Foo = 1},
+ new SerializableObject {Foo = 5}
+ },
+ Pairs = new Dictionary<PrimitiveFieldType, SerializableObject>
+ {
+ {new PrimitiveFieldType(), new SerializableObject {Foo = 10}},
+ {new PrimitiveFieldType {PByte = 10}, new SerializableObject {Foo = 20}}
+ },
+ Objects = new object[] {1, 2, "3", 4.4}
+ };
+
+ var data = marsh.Marshal(obj);
+
+ var result = marsh.Unmarshal<GenericCollectionsType<PrimitiveFieldType, SerializableObject>>(data);
+
+ CollectionAssert.AreEquivalent(obj.Keys, result.Keys);
+ CollectionAssert.AreEquivalent(obj.Values, result.Values);
+ CollectionAssert.AreEquivalent(obj.Pairs, result.Pairs);
+ CollectionAssert.AreEquivalent(obj.Objects, result.Objects);
+ }
+
+ /**
+ * <summary>Check property read.</summary>
+ */
+ [Test]
+ public void TestProperty()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PropertyType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PropertyType obj = new PropertyType
+ {
+ Field1 = 1,
+ Field2 = 2
+ };
+
+ byte[] data = marsh.Marshal(obj);
+
+ PropertyType newObj = marsh.Unmarshal<PropertyType>(data);
+
+ Assert.AreEqual(obj.Field1, newObj.Field1);
+ Assert.AreEqual(obj.Field2, newObj.Field2);
+
+ IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.Field1, portNewObj.GetField<int>("field1"));
+ Assert.AreEqual(obj.Field2, portNewObj.GetField<int>("Field2"));
+ }
+
+ /**
+ * <summary>Check write of primitive fields through reflection.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsReflective()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through binary interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsBinary()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldBinaryType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldBinaryType obj = new PrimitiveFieldBinaryType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through binary interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsRawBinary()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(PrimitiveFieldRawBinaryType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldRawBinaryType obj = new PrimitiveFieldRawBinaryType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through binary interface.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsSerializer()
+ {
+ var typeCfgs = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (PrimitiveFieldType))
+ {
+ Serializer = new PrimitiveFieldsSerializer()
+ }
+ };
+
+ BinaryConfiguration cfg = new BinaryConfiguration {TypeConfigurations = typeCfgs};
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ /**
+ * <summary>Check decimals.</summary>
+ */
+ [Test]
+ public void TestDecimalFields()
+ {
+ BinaryConfiguration cfg = new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (DecimalReflective)),
+ new BinaryTypeConfiguration(typeof (DecimalMarshalAware))
+ }
+ };
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ // 1. Test reflective stuff.
+ DecimalReflective obj1 = new DecimalReflective
+ {
+ Val = decimal.Zero,
+ ValArr = new decimal?[] {decimal.One, decimal.MinusOne}
+ };
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj1), BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj1.Val, portObj.GetField<decimal>("val"));
+ Assert.AreEqual(obj1.ValArr, portObj.GetField<decimal?[]>("valArr"));
+
+ Assert.AreEqual(obj1.Val, portObj.Deserialize<DecimalReflective>().Val);
+ Assert.AreEqual(obj1.ValArr, portObj.Deserialize<DecimalReflective>().ValArr);
+
+ // 2. Test marshal aware stuff.
+ DecimalMarshalAware obj2 = new DecimalMarshalAware();
+
+ obj2.Val = decimal.Zero;
+ obj2.ValArr = new decimal?[] { decimal.One, decimal.MinusOne };
+ obj2.RawVal = decimal.MaxValue;
+ obj2.RawValArr = new decimal?[] { decimal.MinusOne, decimal.One} ;
+
+ portObj = marsh.Unmarshal<IBinaryObject>(marsh.Marshal(obj2), BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj2.Val, portObj.GetField<decimal>("val"));
+ Assert.AreEqual(obj2.ValArr, portObj.GetField<decimal?[]>("valArr"));
+
+ Assert.AreEqual(obj2.Val, portObj.Deserialize<DecimalMarshalAware>().Val);
+ Assert.AreEqual(obj2.ValArr, portObj.Deserialize<DecimalMarshalAware>().ValArr);
+ Assert.AreEqual(obj2.RawVal, portObj.Deserialize<DecimalMarshalAware>().RawVal);
+ Assert.AreEqual(obj2.RawValArr, portObj.Deserialize<DecimalMarshalAware>().RawValArr);
+ }
+
+ /**
+ * <summary>Check write of primitive fields through raw serializer.</summary>
+ */
+ [Test]
+ public void TestPrimitiveFieldsRawSerializer()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ BinaryTypeConfiguration typeCfg =
+ new BinaryTypeConfiguration(typeof(PrimitiveFieldType));
+
+ typeCfg.Serializer = new PrimitiveFieldsRawSerializer();
+
+ typeCfgs.Add(typeCfg);
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ PrimitiveFieldType obj = new PrimitiveFieldType();
+
+ CheckPrimitiveFields(marsh, obj);
+ }
+
+ private void CheckPrimitiveFields(Marshaller marsh, PrimitiveFieldType obj)
+ {
+ obj.PBool = true;
+ obj.PByte = 2;
+ obj.PSbyte = 3;
+ obj.PShort = 4;
+ obj.PUshort = 5;
+ obj.PInt = 6;
+ obj.PUint = 7;
+ obj.PLong = 8;
+ obj.PUlong = 9;
+ obj.PChar = 'a';
+ obj.PFloat = 10;
+ obj.PDouble = 11;
+ obj.PString = "abc";
+ obj.PGuid = Guid.NewGuid();
+ obj.PnGuid = Guid.NewGuid();
+ obj.IgniteGuid = new IgniteGuid(Guid.NewGuid(), 123);
+
+ CheckPrimitiveFieldsSerialization(marsh, obj);
+ }
+
+ private void CheckPrimitiveFieldsSerialization(Marshaller marsh, PrimitiveFieldType obj)
+ {
+ byte[] bytes = marsh.Marshal(obj);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ PrimitiveFieldType newObj = portObj.Deserialize<PrimitiveFieldType>();
+
+ Assert.AreEqual(obj, newObj);
+ }
+
+ /**
+ * <summary>Check write of object with enums.</summary>
+ */
+ [Test]
+ public void TestEnumsReflective()
+ {
+ Marshaller marsh =
+ new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations =
+ new List<BinaryTypeConfiguration> {new BinaryTypeConfiguration(typeof (EnumType))}
+ });
+
+ EnumType obj = new EnumType
+ {
+ PEnum = TestEnum.Val1,
+ PEnumArray = new[] {TestEnum.Val2, TestEnum.Val3}
+ };
+
+ byte[] bytes = marsh.Marshal(obj);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ EnumType newObj = portObj.Deserialize<EnumType>();
+
+ Assert.AreEqual(obj.PEnum, newObj.PEnum);
+ Assert.AreEqual(obj.PEnumArray, newObj.PEnumArray);
+ }
+
+ /**
+ * <summary>Check write of object with collections.</summary>
+ */
+ [Test]
+ public void TestCollectionsReflective()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (CollectionsType)),
+ new BinaryTypeConfiguration(typeof (InnerObjectType))
+ }
+ });
+
+ var obj = new CollectionsType
+ {
+ Hashtable = new Hashtable {{1, 2}, {3, 4}},
+ LinkedList = new LinkedList<int>(new[] {1, 2, 3}),
+ SortedDict = new SortedDictionary<string, int> {{"1", 2}},
+ Dict = new Dictionary<int, string> {{1, "2"}},
+ Arr = new[] {new InnerObjectType()}
+ };
+
+ var list = new ArrayList
+ {
+ true,
+ (byte) 1,
+ (short) 2,
+ 'a',
+ 3,
+ (long) 4,
+ (float) 5,
+ (double) 6,
+ "string",
+ Guid.NewGuid(),
+ new InnerObjectType
+ {
+ PInt1 = 1,
+ PInt2 = 2
+ }
+ };
+
+ obj.Col1 = list;
+
+ byte[] bytes = marsh.Marshal(obj);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(obj.GetHashCode(), portObj.GetHashCode());
+
+ CollectionsType newObj = portObj.Deserialize<CollectionsType>();
+
+ Assert.AreEqual(obj, newObj);
+
+ obj.Col1 = null;
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+
+ obj.Col1 = list;
+ obj.Col2 = list;
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+
+ obj.Col2 = new TestList();
+
+ Assert.AreEqual(obj, marsh.Unmarshal<CollectionsType>(marsh.Marshal(obj)));
+ }
+
+ /**
+ * <summary>Check write of object fields through reflective serializer.</summary>
+ */
+ [Test]
+ public void TestObjectReflective()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(OuterObjectType)));
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(InnerObjectType)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ CheckObject(marsh, new OuterObjectType(), new InnerObjectType());
+ }
+
+ /**
+ * <summary>Test handles.</summary>
+ */
+ [Test]
+ public void TestHandles()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleInner)));
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(HandleOuter)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ HandleOuter outer = new HandleOuter();
+
+ outer.Before = "outBefore";
+ outer.After = "outAfter";
+ outer.RawBefore = "outRawBefore";
+ outer.RawAfter = "outRawAfter";
+
+ HandleInner inner = new HandleInner();
+
+ inner.Before = "inBefore";
+ inner.After = "inAfter";
+ inner.RawBefore = "inRawBefore";
+ inner.RawAfter = "inRawAfter";
+
+ outer.Inner = inner;
+ outer.RawInner = inner;
+
+ inner.Outer = outer;
+ inner.RawOuter = outer;
+
+ byte[] bytes = marsh.Marshal(outer);
+
+ IBinaryObject outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
+ HandleInner newInner = newOuter.Inner;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+
+ // Get inner object by field.
+ IBinaryObject innerObj = outerObj.GetField<IBinaryObject>("inner");
+
+ newInner = innerObj.Deserialize<HandleInner>();
+ newOuter = newInner.Outer;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+
+ // Get outer object from inner object by handle.
+ outerObj = innerObj.GetField<IBinaryObject>("outer");
+
+ newOuter = outerObj.Deserialize<HandleOuter>();
+ newInner = newOuter.Inner;
+
+ CheckHandlesConsistency(outer, inner, newOuter, newInner);
+ }
+
+ /**
+ * <summary>Test handles with exclusive writes.</summary>
+ */
+ [Test]
+ public void TestHandlesExclusive([Values(true, false)] bool detached, [Values(true, false)] bool asbinary)
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (HandleInner)),
+ new BinaryTypeConfiguration(typeof (HandleOuterExclusive))
+ }
+ });
+
+ var inner = new HandleInner
+ {
+ Before = "inBefore",
+ After = "inAfter",
+ RawBefore = "inRawBefore",
+ RawAfter = "inRawAfter"
+ };
+
+ var outer = new HandleOuterExclusive
+ {
+ Before = "outBefore",
+ After = "outAfter",
+ RawBefore = "outRawBefore",
+ RawAfter = "outRawAfter",
+ Inner = inner,
+ RawInner = inner
+ };
+
+ inner.Outer = outer;
+ inner.RawOuter = outer;
+
+ var bytes = asbinary
+ ? marsh.Marshal(new IgniteBinary(marsh).ToBinary<IBinaryObject>(outer))
+ : marsh.Marshal(outer);
+
+ IBinaryObject outerObj;
+
+ if (detached)
+ {
+ var reader = new BinaryReader(marsh, new Dictionary<long, IBinaryTypeDescriptor>(),
+ new BinaryHeapStream(bytes), BinaryMode.ForceBinary, null);
+
+ reader.DetachNext();
+
+ outerObj = reader.Deserialize<IBinaryObject>();
+ }
+ else
+ outerObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ HandleOuter newOuter = outerObj.Deserialize<HandleOuter>();
+
+ Assert.IsFalse(newOuter == newOuter.Inner.Outer);
+ Assert.IsFalse(newOuter == newOuter.Inner.RawOuter);
+ Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
+ Assert.IsFalse(newOuter == newOuter.RawInner.RawOuter);
+
+ Assert.IsFalse(newOuter.Inner == newOuter.RawInner);
+
+ Assert.IsTrue(newOuter.Inner.Outer == newOuter.Inner.RawOuter);
+ Assert.IsTrue(newOuter.RawInner.Outer == newOuter.RawInner.RawOuter);
+
+ Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.Inner);
+ Assert.IsTrue(newOuter.Inner == newOuter.Inner.Outer.RawInner);
+ Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.Inner);
+ Assert.IsTrue(newOuter.RawInner == newOuter.RawInner.Outer.RawInner);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedDefault()
+ {
+ CheckKeepSerialized(new BinaryConfiguration(), true);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedDefaultFalse()
+ {
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.DefaultKeepDeserialized = false;
+
+ CheckKeepSerialized(cfg, false);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedTypeCfgFalse()
+ {
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
+
+ typeCfg.KeepDeserialized = false;
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
+
+ CheckKeepSerialized(cfg, false);
+ }
+
+ ///
+ /// <summary>Test KeepSerialized property</summary>
+ ///
+ [Test]
+ public void TestKeepSerializedTypeCfgTrue()
+ {
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(PropertyType));
+ typeCfg.KeepDeserialized = true;
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+ cfg.DefaultKeepDeserialized = false;
+
+ cfg.TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg };
+
+ CheckKeepSerialized(cfg, true);
+ }
+
+ /// <summary>
+ /// Test correct serialization/deserialization of arrays of special types.
+ /// </summary>
+ [Test]
+ public void TestSpecialArrays()
+ {
+ ICollection<BinaryTypeConfiguration> typeCfgs =
+ new List<BinaryTypeConfiguration>();
+
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArray)));
+ typeCfgs.Add(new BinaryTypeConfiguration(typeof(SpecialArrayMarshalAware)));
+
+ BinaryConfiguration cfg = new BinaryConfiguration();
+
+ cfg.TypeConfigurations = typeCfgs;
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ Guid[] guidArr = { Guid.NewGuid() };
+ Guid?[] nGuidArr = { Guid.NewGuid() };
+ DateTime[] dateArr = { DateTime.Now.ToUniversalTime() };
+ DateTime?[] nDateArr = { DateTime.Now.ToUniversalTime() };
+
+ // Use special object.
+ SpecialArray obj1 = new SpecialArray
+ {
+ GuidArr = guidArr,
+ NGuidArr = nGuidArr,
+ DateArr = dateArr,
+ NDateArr = nDateArr
+ };
+
+ byte[] bytes = marsh.Marshal(obj1);
+
+ IBinaryObject portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.IsNotNull(portObj.Deserialize<SpecialArray>());
+
+ Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("guidArr"));
+ Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("nGuidArr"));
+ Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("dateArr"));
+ Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("nDateArr"));
+
+ obj1 = portObj.Deserialize<SpecialArray>();
+
+ Assert.AreEqual(guidArr, obj1.GuidArr);
+ Assert.AreEqual(nGuidArr, obj1.NGuidArr);
+ Assert.AreEqual(dateArr, obj1.DateArr);
+ Assert.AreEqual(nDateArr, obj1.NDateArr);
+
+ // Use special with IGridbinaryMarshalAware.
+ SpecialArrayMarshalAware obj2 = new SpecialArrayMarshalAware();
+
+ obj2.GuidArr = guidArr;
+ obj2.NGuidArr = nGuidArr;
+ obj2.DateArr = dateArr;
+ obj2.NDateArr = nDateArr;
+
+ bytes = marsh.Marshal(obj2);
+
+ portObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("a"));
+ Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("b"));
+ Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("c"));
+ Assert.AreEqual(nDateArr, portObj.GetField<DateTime?[]>("d"));
+
+ obj2 = portObj.Deserialize<SpecialArrayMarshalAware>();
+
+ Assert.AreEqual(guidArr, obj2.GuidArr);
+ Assert.AreEqual(nGuidArr, obj2.NGuidArr);
+ Assert.AreEqual(dateArr, obj2.DateArr);
+ Assert.AreEqual(nDateArr, obj2.NDateArr);
+ }
+
+ /// <summary>
+ /// Writes objects of various sizes to test schema compaction
+ /// (where field offsets can be stored as 1, 2 or 4 bytes).
+ /// </summary>
+ [Test]
+ public void TestCompactSchema()
+ {
+ var marsh = new Marshaller(new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof (SpecialArray)),
+ new BinaryTypeConfiguration(typeof (SpecialArrayMarshalAware))
+ }
+ });
+
+ var dt = new SpecialArrayMarshalAware();
+
+ foreach (var i in new[] {1, 5, 10, 13, 14, 15, 100, 200, 1000, 5000, 15000, 30000})
+ {
+ dt.NGuidArr = Enumerable.Range(1, i).Select(x => (Guid?) Guid.NewGuid()).ToArray();
+ dt.NDateArr = Enumerable.Range(1, i).Select(x => (DateTime?) DateTime.Now.AddDays(x)).ToArray();
+
+ var bytes = marsh.Marshal(dt);
+
+ var res = marsh.Unmarshal<SpecialArrayMarshalAware>(bytes);
+
+ CollectionAssert.AreEquivalent(dt.NGuidArr, res.NGuidArr);
+ CollectionAssert.AreEquivalent(dt.NDateArr, res.NDateArr);
+ }
+ }
+
+ private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
+ {
+ if (cfg.TypeConfigurations == null)
+ {
+ cfg.TypeConfigurations = new List<BinaryTypeConfiguration>
+ {
+ new BinaryTypeConfiguration(typeof(PropertyType))
+ };
+ }
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ byte[] data = marsh.Marshal(new PropertyType());
+
+ IBinaryObject portNewObj = marsh.Unmarshal<IBinaryObject>(data, BinaryMode.ForceBinary);
+
+ PropertyType deserialized1 = portNewObj.Deserialize<PropertyType>();
+ PropertyType deserialized2 = portNewObj.Deserialize<PropertyType>();
+
+ Assert.NotNull(deserialized1);
+
+ Assert.AreEqual(expKeep, deserialized1 == deserialized2);
+ }
+
+ private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter,
+ HandleInner newInner)
+ {
+ Assert.True(newOuter != null);
+ Assert.AreEqual(outer.Before, newOuter.Before);
+ Assert.True(newOuter.Inner == newInner);
+ Assert.AreEqual(outer.After, newOuter.After);
+ Assert.AreEqual(outer.RawBefore, newOuter.RawBefore);
+ Assert.True(newOuter.RawInner == newInner);
+ Assert.AreEqual(outer.RawAfter, newOuter.RawAfter);
+
+ Assert.True(newInner != null);
+ Assert.AreEqual(inner.Before, newInner.Before);
+ Assert.True(newInner.Outer == newOuter);
+ Assert.AreEqual(inner.After, newInner.After);
+ Assert.AreEqual(inner.RawBefore, newInner.RawBefore);
+ Assert.True(newInner.RawOuter == newOuter);
+ Assert.AreEqual(inner.RawAfter, newInner.RawAfter);
+ }
+
+ private static void CheckObject(Marshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
+ {
+ inObj.PInt1 = 1;
+ inObj.PInt2 = 2;
+
+ outObj.InObj = inObj;
+
+ byte[] bytes = marsh.Marshal(outObj);
+
+ IBinaryObject portOutObj = marsh.Unmarshal<IBinaryObject>(bytes, BinaryMode.ForceBinary);
+
+ Assert.AreEqual(outObj.GetHashCode(), portOutObj.GetHashCode());
+
+ OuterObjectType newOutObj = portOutObj.Deserialize<OuterObjectType>();
+
+ Assert.AreEqual(outObj, newOutObj);
+ }
+
+ public class OuterObjectType
+ {
+ public InnerObjectType InObj { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var type = obj as OuterObjectType;
+
+ return type != null && Equals(InObj, type.InObj);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return InObj != null ? InObj.GetHashCode() : 0;
+ }
+ }
+
+ [Serializable]
+ public class InnerObjectType
+ {
+ public int PInt1 { get; set; }
+
+ public int PInt2 { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var that = obj as InnerObjectType;
+
+ return that != null && (PInt1 == that.PInt1 && PInt2 == that.PInt2);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return 31 * PInt1 + PInt2;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return "InnerObjectType[pInt1=" + PInt1 + ", pInt2=" + PInt2 + ']';
+ }
+ }
+
+ public class CollectionsType
+ {
+ public ICollection Col1 { get; set; }
+
+ public ArrayList Col2 { get; set; }
+
+ public Hashtable Hashtable { get; set; }
+
+ public Dictionary<int, string> Dict { get; set; }
+
+ public InnerObjectType[] Arr { get; set; }
+
+ public SortedDictionary<string, int> SortedDict { get; set; }
+
+ public LinkedList<int> LinkedList { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var that = obj as CollectionsType;
+
+ return that != null
+ && CompareCollections(Col1, that.Col1)
+ && CompareCollections(Col2, that.Col2)
+ && CompareCollections(Hashtable, that.Hashtable)
+ && CompareCollections(Dict, that.Dict)
+ && CompareCollections(Arr, that.Arr)
+ && CompareCollections(SortedDict, that.SortedDict)
+ && CompareCollections(LinkedList, that.LinkedList);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ int res = 0;
+
+ foreach (var col in new object[] {Col1, Col2, Hashtable, Dict, Arr, SortedDict, LinkedList})
+ res = 31*res + (col != null ? col.GetHashCode() : 0);
+
+ return res;
+ }
+ }
+
+ public class GenericCollectionsType<TKey, TValue> : IBinarizable
+ {
+ public ICollection<TKey> Keys { get; set; }
+
+ public ICollection<TValue> Values { get; set; }
+
+ public IDictionary<TKey, TValue> Pairs { get; set; }
+
+ public ICollection<object> Objects { get; set; }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteObject("Keys", Keys);
+ writer.WriteObject("Values", Values);
+ writer.WriteObject("Pairs", Pairs);
+ writer.WriteObject("Objects", Objects);
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Keys = (ICollection<TKey>) reader.ReadObject<object>("Keys");
+ Values = (ICollection<TValue>) reader.ReadObject<object>("Values");
+ Pairs = (IDictionary<TKey, TValue>) reader.ReadObject<object>("Pairs");
+ Objects = (ICollection<object>) reader.ReadObject<object>("Objects");
+ }
+ }
+
+ public class TestList : ArrayList
+ {
+
+ }
+
+ private static bool CompareCollections(ICollection col1, ICollection col2)
+ {
+ if (col1 == null && col2 == null)
+ return true;
+ if (col1 == null || col2 == null)
+ return false;
+
+ return col1.OfType<object>().SequenceEqual(col2.OfType<object>());
+ }
+
+ public class PrimitiveArrayFieldType
+ {
+ public bool[] PBool { get; set; }
+
+ public sbyte[] PSbyte { get; set; }
+
+ public byte[] PByte { get; set; }
+
+ public short[] PShort { get; set; }
+
+ public ushort[] PUshort { get; set; }
+
+ public char[] PChar { get; set; }
+
+ public int[] PInt { get; set; }
+
+ public uint[] PUint { get; set; }
+
+ public long[] PLong { get; set; }
+
+ public ulong[] PUlong { get; set; }
+
+ public float[] PFloat { get; set; }
+
+ public double[] PDouble { get; set; }
+
+ public string[] PString { get; set; }
+
+ public Guid?[] PGuid { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ var other = obj as PrimitiveArrayFieldType;
+
+ return other != null && (PBool == other.PBool &&
+ PByte == other.PByte &&
+ PSbyte == other.PSbyte &&
+ PShort == other.PShort &&
+ PUshort == other.PUshort &&
+ PInt == other.PInt &&
+ PUint == other.PUint &&
+ PLong == other.PLong &&
+ PUlong == other.PUlong &&
+ PChar == other.PChar &&
+ PFloat == other.PFloat &&
+ PDouble == other.PDouble &&
+ PString == other.PString &&
+ PGuid == other.PGuid);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return PInt != null && PInt.Length > 0 ? PInt[0].GetHashCode() : 0;
+ }
+ }
+
+ public class SpecialArray
+ {
+ public Guid[] GuidArr;
+ public Guid?[] NGuidArr;
+ public DateTime[] DateArr;
+ public DateTime?[] NDateArr;
+ }
+
+ public class SpecialArrayMarshalAware : SpecialArray, IBinarizable
+ {
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteObject("a", GuidArr);
+ writer.WriteObject("b", NGuidArr);
+ writer.WriteObject("c", DateArr);
+ writer.WriteObject("d", NDateArr);
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ GuidArr = reader.ReadObject<Guid[]>("a");
+ NGuidArr = reader.ReadObject<Guid?[]>("b");
+ DateArr = reader.ReadObject<DateTime[]>("c");
+ NDateArr = reader.ReadObject<DateTime?[]>("d");
+ }
+ }
+
+ public class EnumType
+ {
+ public TestEnum PEnum { get; set; }
+
+ public TestEnum[] PEnumArray { get; set; }
+ }
+
+ [Serializable]
+ public class PrimitiveFieldType
+ {
+ public bool PBool { get; set; }
+
+ public sbyte PSbyte { get; set; }
+
+ public byte PByte { get; set; }
+
+ public short PShort { get; set; }
+
+ public ushort PUshort { get; set; }
+
+ public char PChar { get; set; }
+
+ public int PInt { get; set; }
+
+ public uint PUint { get; set; }
+
+ public long PLong { get; set; }
+
+ public ulong PUlong { get; set; }
+
+ public float PFloat { get; set; }
+
+ public double PDouble { get; set; }
+
+ public string PString { get; set; }
+
+ public Guid PGuid { get; set; }
+
+ public Guid? PnGuid { get; set; }
+
+ public IgniteGuid IgniteGuid { get; set; }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj != null && obj is PrimitiveFieldType)
+ {
+ PrimitiveFieldType that = (PrimitiveFieldType)obj;
+
+ return PBool == that.PBool &&
+ PByte == that.PByte &&
+ PSbyte == that.PSbyte &&
+ PShort == that.PShort &&
+ PUshort == that.PUshort &&
+ PInt == that.PInt &&
+ PUint == that.PUint &&
+ PLong == that.PLong &&
+ PUlong == that.PUlong &&
+ PChar == that.PChar &&
+ PFloat == that.PFloat &&
+ PDouble == that.PDouble &&
+ (string.Equals(PString, that.PString)) &&
+ PGuid.Equals(that.PGuid) &&
+ IgniteGuid.Equals(that.IgniteGuid) &&
+ (PnGuid == null && that.PnGuid == null || PnGuid != null && PnGuid.Equals(that.PnGuid));
+ }
+ return false;
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ return PInt;
+ }
+ }
+
+ public class PrimitiveFieldBinaryType : PrimitiveFieldType, IBinarizable
+ {
+ public unsafe void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteBoolean("bool", PBool);
+ writer.WriteByte("byte", PByte);
+ writer.WriteShort("short", PShort);
+ writer.WriteInt("int", PInt);
+ writer.WriteLong("long", PLong);
+ writer.WriteChar("char", PChar);
+ writer.WriteFloat("float", PFloat);
+ writer.WriteDouble("double", PDouble);
+
+ sbyte sByte = PSbyte;
+ ushort uShort = PUshort;
+ uint uInt = PUint;
+ ulong uLong = PUlong;
+
+ writer.WriteByte("sbyte", *(byte*)&sByte);
+ writer.WriteShort("ushort", *(short*)&uShort);
+ writer.WriteInt("uint", *(int*)&uInt);
+ writer.WriteLong("ulong", *(long*)&uLong);
+
+ writer.WriteString("string", PString);
+ writer.WriteGuid("guid", PGuid);
+ writer.WriteGuid("nguid", PnGuid);
+
+ writer.WriteObject("iguid", IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(IBinaryReader reader)
+ {
+ PBool = reader.ReadBoolean("bool");
+ PByte = reader.ReadByte("byte");
+ PShort = reader.ReadShort("short");
+ PInt = reader.ReadInt("int");
+
+ PLong = reader.ReadLong("long");
+ PChar = reader.ReadChar("char");
+ PFloat = reader.ReadFloat("float");
+ PDouble = reader.ReadDouble("double");
+
+ byte sByte = reader.ReadByte("sbyte");
+ short uShort = reader.ReadShort("ushort");
+ int uInt = reader.ReadInt("uint");
+ long uLong = reader.ReadLong("ulong");
+
+ PSbyte = *(sbyte*)&sByte;
+ PUshort = *(ushort*)&uShort;
+ PUint = *(uint*)&uInt;
+ PUlong = *(ulong*)&uLong;
+
+ PString = reader.ReadString("string");
+ PGuid = reader.ReadObject<Guid>("guid");
+ PnGuid = reader.ReadGuid("nguid");
+
+ IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
+ }
+ }
+
+ public class PrimitiveFieldRawBinaryType : PrimitiveFieldType, IBinarizable
+ {
+ public unsafe void WriteBinary(IBinaryWriter writer)
+ {
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteBoolean(PBool);
+ rawWriter.WriteByte(PByte);
+ rawWriter.WriteShort(PShort);
+ rawWriter.WriteInt(PInt);
+ rawWriter.WriteLong(PLong);
+ rawWriter.WriteChar(PChar);
+ rawWriter.WriteFloat(PFloat);
+ rawWriter.WriteDouble(PDouble);
+
+ sbyte sByte = PSbyte;
+ ushort uShort = PUshort;
+ uint uInt = PUint;
+ ulong uLong = PUlong;
+
+ rawWriter.WriteByte(*(byte*)&sByte);
+ rawWriter.WriteShort(*(short*)&uShort);
+ rawWriter.WriteInt(*(int*)&uInt);
+ rawWriter.WriteLong(*(long*)&uLong);
+
+ rawWriter.WriteString(PString);
+ rawWriter.WriteGuid(PGuid);
+ rawWriter.WriteGuid(PnGuid);
+
+ rawWriter.WriteObject(IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(IBinaryReader reader)
+ {
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ PBool = rawReader.ReadBoolean();
+ PByte = rawReader.ReadByte();
+ PShort = rawReader.ReadShort();
+ PInt = rawReader.ReadInt();
+
+ PLong = rawReader.ReadLong();
+ PChar = rawReader.ReadChar();
+ PFloat = rawReader.ReadFloat();
+ PDouble = rawReader.ReadDouble();
+
+ byte sByte = rawReader.ReadByte();
+ short uShort = rawReader.ReadShort();
+ int uInt = rawReader.ReadInt();
+ long uLong = rawReader.ReadLong();
+
+ PSbyte = *(sbyte*)&sByte;
+ PUshort = *(ushort*)&uShort;
+ PUint = *(uint*)&uInt;
+ PUlong = *(ulong*)&uLong;
+
+ PString = rawReader.ReadString();
+ PGuid = rawReader.ReadGuid().Value;
+ PnGuid = rawReader.ReadGuid();
+
+ IgniteGuid = rawReader.ReadObject<IgniteGuid>();
+ }
+ }
+
+ public class PrimitiveFieldsSerializer : IBinarySerializer
+ {
+ public unsafe void WriteBinary(object obj, IBinaryWriter writer)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ writer.WriteBoolean("bool", obj0.PBool);
+ writer.WriteByte("byte", obj0.PByte);
+ writer.WriteShort("short", obj0.PShort);
+ writer.WriteInt("int", obj0.PInt);
+ writer.WriteLong("long", obj0.PLong);
+ writer.WriteChar("char", obj0.PChar);
+ writer.WriteFloat("float", obj0.PFloat);
+ writer.WriteDouble("double", obj0.PDouble);
+
+ sbyte sByte = obj0.PSbyte;
+ ushort uShort = obj0.PUshort;
+ uint uInt = obj0.PUint;
+ ulong uLong = obj0.PUlong;
+
+ writer.WriteByte("sbyte", *(byte*)&sByte);
+ writer.WriteShort("ushort", *(short*)&uShort);
+ writer.WriteInt("uint", *(int*)&uInt);
+ writer.WriteLong("ulong", *(long*)&uLong);
+
+ writer.WriteString("string", obj0.PString);
+ writer.WriteGuid("guid", obj0.PGuid);
+ writer.WriteGuid("nguid", obj0.PnGuid);
+
+ writer.WriteObject("iguid", obj0.IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(object obj, IBinaryReader reader)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ obj0.PBool = reader.ReadBoolean("bool");
+ obj0.PByte = reader.ReadByte("byte");
+ obj0.PShort = reader.ReadShort("short");
+ obj0.PInt = reader.ReadInt("int");
+
+ obj0.PLong = reader.ReadLong("long");
+ obj0.PChar = reader.ReadChar("char");
+ obj0.PFloat = reader.ReadFloat("float");
+ obj0.PDouble = reader.ReadDouble("double");
+
+ byte sByte = reader.ReadByte("sbyte");
+ short uShort = reader.ReadShort("ushort");
+ int uInt = reader.ReadInt("uint");
+ long uLong = reader.ReadLong("ulong");
+
+ obj0.PSbyte = *(sbyte*)&sByte;
+ obj0.PUshort = *(ushort*)&uShort;
+ obj0.PUint = *(uint*)&uInt;
+ obj0.PUlong = *(ulong*)&uLong;
+
+ obj0.PString = reader.ReadString("string");
+ obj0.PGuid = reader.ReadObject<Guid>("guid");
+ obj0.PnGuid = reader.ReadGuid("nguid");
+
+ obj0.IgniteGuid = reader.ReadObject<IgniteGuid>("iguid");
+ }
+ }
+
+ public class PrimitiveFieldsRawSerializer : IBinarySerializer
+ {
+ public unsafe void WriteBinary(object obj, IBinaryWriter writer)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteBoolean(obj0.PBool);
+ rawWriter.WriteByte(obj0.PByte);
+ rawWriter.WriteShort( obj0.PShort);
+ rawWriter.WriteInt( obj0.PInt);
+ rawWriter.WriteLong( obj0.PLong);
+ rawWriter.WriteChar(obj0.PChar);
+ rawWriter.WriteFloat(obj0.PFloat);
+ rawWriter.WriteDouble( obj0.PDouble);
+
+ sbyte sByte = obj0.PSbyte;
+ ushort uShort = obj0.PUshort;
+ uint uInt = obj0.PUint;
+ ulong uLong = obj0.PUlong;
+
+ rawWriter.WriteByte(*(byte*)&sByte);
+ rawWriter.WriteShort(*(short*)&uShort);
+ rawWriter.WriteInt(*(int*)&uInt);
+ rawWriter.WriteLong(*(long*)&uLong);
+
+ rawWriter.WriteString(obj0.PString);
+ rawWriter.WriteGuid(obj0.PGuid);
+ rawWriter.WriteGuid(obj0.PnGuid);
+
+ rawWriter.WriteObject(obj0.IgniteGuid);
+ }
+
+ public unsafe void ReadBinary(object obj, IBinaryReader reader)
+ {
+ PrimitiveFieldType obj0 = (PrimitiveFieldType)obj;
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ obj0.PBool = rawReader.ReadBoolean();
+ obj0.PByte = rawReader.ReadByte();
+ obj0.PShort = rawReader.ReadShort();
+ obj0.PInt = rawReader.ReadInt();
+ obj0.PLong = rawReader.ReadLong();
+ obj0.PChar = rawReader.ReadChar();
+ obj0.PFloat = rawReader.ReadFloat();
+ obj0.PDouble = rawReader.ReadDouble();
+
+ byte sByte = rawReader.ReadByte();
+ short uShort = rawReader.ReadShort();
+ int uInt = rawReader.ReadInt();
+ long uLong = rawReader.ReadLong();
+
+ obj0.PSbyte = *(sbyte*)&sByte;
+ obj0.PUshort = *(ushort*)&uShort;
+ obj0.PUint = *(uint*)&uInt;
+ obj0.PUlong = *(ulong*)&uLong;
+
+ obj0.PString = rawReader.ReadString();
+ obj0.PGuid = rawReader.ReadGuid().Value;
+ obj0.PnGuid = rawReader.ReadGuid();
+
+ obj0.IgniteGuid = rawReader.ReadObject<IgniteGuid>();
+ }
+ }
+
+ public class HandleOuter : IBinarizable
+ {
+ public string Before;
+ public HandleInner Inner;
+ public string After;
+
+ public string RawBefore;
+ public HandleInner RawInner;
+ public string RawAfter;
+
+ /** <inheritdoc /> */
+ virtual public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteString("before", Before);
+ writer.WriteObject("inner", Inner);
+ writer.WriteString("after", After);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteString(RawBefore);
+ rawWriter.WriteObject(RawInner);
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ virtual public void ReadBinary(IBinaryReader reader)
+ {
+ Before = reader.ReadString("before");
+ Inner = reader.ReadObject<HandleInner>("inner");
+ After = reader.ReadString("after");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ RawBefore = rawReader.ReadString();
+ RawInner = rawReader.ReadObject<HandleInner>();
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+ public class HandleInner : IBinarizable
+ {
+ public string Before;
+ public HandleOuter Outer;
+ public string After;
+
+ public string RawBefore;
+ public HandleOuter RawOuter;
+ public string RawAfter;
+
+ /** <inheritdoc /> */
+ virtual public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteString("before", Before);
+ writer.WriteObject("outer", Outer);
+ writer.WriteString("after", After);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteString(RawBefore);
+ rawWriter.WriteObject(RawOuter);
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ virtual public void ReadBinary(IBinaryReader reader)
+ {
+ Before = reader.ReadString("before");
+ Outer = reader.ReadObject<HandleOuter>("outer");
+ After = reader.ReadString("after");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ RawBefore = rawReader.ReadString();
+ RawOuter = rawReader.ReadObject<HandleOuter>();
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+
+ public class HandleOuterExclusive : HandleOuter
+ {
+ /** <inheritdoc /> */
+ override public void WriteBinary(IBinaryWriter writer)
+ {
+ BinaryWriter writer0 = (BinaryWriter)writer;
+
+ writer.WriteString("before", Before);
+
+ writer0.WithDetach(w => w.WriteObject("inner", Inner));
+
+ writer.WriteString("after", After);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteString(RawBefore);
+
+ writer0.WithDetach(w => w.WriteObject(RawInner));
+
+ rawWriter.WriteString(RawAfter);
+ }
+
+ /** <inheritdoc /> */
+ override public void ReadBinary(IBinaryReader reader)
+ {
+ var reader0 = (BinaryReader) reader;
+
+ Before = reader0.ReadString("before");
+
+ reader0.DetachNext();
+ Inner = reader0.ReadObject<HandleInner>("inner");
+
+ After = reader0.ReadString("after");
+
+ var rawReader = (BinaryReader) reader.GetRawReader();
+
+ RawBefore = rawReader.ReadString();
+
+ reader0.DetachNext();
+ RawInner = rawReader.ReadObject<HandleInner>();
+
+ RawAfter = rawReader.ReadString();
+ }
+ }
+
+ public class PropertyType
+ {
+ public int Field1;
+
+ public int Field2
+ {
+ get;
+ set;
+ }
+ }
+
+ public enum TestEnum
+ {
+ Val1, Val2, Val3 = 10
+ }
+
+ public class DecimalReflective
+ {
+ /** */
+ public decimal? Val;
+
+ /** */
+ public decimal?[] ValArr;
+ }
+
+ public class DecimalMarshalAware : DecimalReflective, IBinarizable
+ {
+ /** */
+ public decimal? RawVal;
+
+ /** */
+ public decimal?[] RawValArr;
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteDecimal("val", Val);
+ writer.WriteDecimalArray("valArr", ValArr);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteDecimal(RawVal);
+ rawWriter.WriteDecimalArray(RawValArr);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Val = reader.ReadDecimal("val");
+ ValArr = reader.ReadDecimalArray("valArr");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ RawVal = rawReader.ReadDecimal();
+ RawValArr = rawReader.ReadDecimalArray();
+ }
+ }
+
+ /// <summary>
+ /// Date time type.
+ /// </summary>
+ public class DateTimeType : IBinarizable
+ {
+ public DateTime Utc;
+
+ public DateTime? UtcNull;
+
+ public DateTime?[] UtcArr;
+
+ public DateTime UtcRaw;
+
+ public DateTime? UtcNullRaw;
+
+ public DateTime?[] UtcArrRaw;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="now">Current local time.</param>
+ public DateTimeType(DateTime now)
+ {
+ Utc = now.ToUniversalTime();
+
+ UtcNull = Utc;
+
+ UtcArr = new DateTime?[] { Utc };
+
+ UtcRaw = Utc;
+
+ UtcNullRaw = UtcNull;
+
+ UtcArrRaw = new[] { UtcArr[0] };
+ }
+
+ /** <inheritDoc /> */
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteTimestamp("utc", Utc);
+ writer.WriteTimestamp("utcNull", UtcNull);
+ writer.WriteTimestampArray("utcArr", UtcArr);
+
+ IBinaryRawWriter rawWriter = writer.GetRawWriter();
+
+ rawWriter.WriteTimestamp(UtcRaw);
+ rawWriter.WriteTimestamp(UtcNullRaw);
+ rawWriter.WriteTimestampArray(UtcArrRaw);
+ }
+
+ /** <inheritDoc /> */
+ public void ReadBinary(IBinaryReader reader)
+ {
+ Utc = reader.ReadTimestamp("utc").Value;
+ UtcNull = reader.ReadTimestamp("utc").Value;
+ UtcArr = reader.ReadTimestampArray("utcArr");
+
+ IBinaryRawReader rawReader = reader.GetRawReader();
+
+ UtcRaw = rawReader.ReadTimestamp().Value;
+ UtcNullRaw = rawReader.ReadTimestamp().Value;
+ UtcArrRaw = rawReader.ReadTimestampArray();
+ }
+ }
+
+ [Serializable]
+ private class SerializableObject
+ {
+ public int Foo { get; set; }
+
+ private bool Equals(SerializableObject other)
+ {
+ return Foo == other.Foo;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+
+ return Equals((SerializableObject) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Foo;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d69362f8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
new file mode 100644
index 0000000..78ee8c0
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Contains tests for binary type structure.
+ /// </summary>
+ [TestFixture]
+ public class BinaryStructureTest
+ {
+ /** Repeat count. */
+ public static readonly int RepeatCnt = 10;
+
+ /** Objects per mode. */
+ public static readonly int ObjectsPerMode = 5;
+
+ /// <summary>
+ /// Test object write with different structures.
+ /// </summary>
+ [Test]
+ public void TestStructure()
+ {
+ for (int i = 1; i <= RepeatCnt; i++)
+ {
+ Console.WriteLine(">>> Iteration started: " + i);
+
+ // 1. Generate and shuffle objects.
+ IList<BranchedType> objs = new List<BranchedType>();
+
+ for (int j = 0; j < 6 * ObjectsPerMode; j++)
+ objs.Add(new BranchedType((j%6) + 1));
+
+ objs = IgniteUtils.Shuffle(objs);
+
+ // 2. Create new marshaller.
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(typeof(BranchedType));
+
+ BinaryConfiguration cfg = new BinaryConfiguration
+ {
+ TypeConfigurations = new List<BinaryTypeConfiguration> { typeCfg }
+ };
+
+ Marshaller marsh = new Marshaller(cfg);
+
+ // 3. Marshal all data and ensure deserialized object is fine.
+ foreach (BranchedType obj in objs)
+ {
+ Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');
+
+ byte[] data = marsh.Marshal(obj);
+
+ BranchedType other = marsh.Unmarshal<BranchedType>(data);
+
+ Assert.IsTrue(obj.Equals(other));
+ }
+
+ Console.WriteLine();
+
+ // 4. Ensure that all fields are recorded.
+ var desc = marsh.GetDescriptor(typeof (BranchedType));
+
+ CollectionAssert.AreEquivalent(new[] {"mode", "f2", "f3", "f4", "f5", "f6", "f7", "f8"},
+ desc.WriterTypeStructure.FieldTypes.Keys);
+ }
+ }
+ }
+
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ public class BranchedType : IBinarizable
+ {
+ public int mode;
+ public int f2;
+ public int f3;
+ public int f4;
+ public int f5;
+ public int f6;
+ public int f7;
+ public int f8;
+
+ public BranchedType(int mode)
+ {
+ this.mode = mode;
+
+ switch (mode)
+ {
+ case 1:
+ f2 = 2;
+
+ break;
+
+ case 2:
+ f2 = 2;
+ f3 = 3;
+ f4 = 4;
+
+ break;
+
+ case 3:
+ f2 = 2;
+ f3 = 3;
+ f5 = 5;
+
+ break;
+
+ case 4:
+ f2 = 2;
+ f3 = 3;
+ f5 = 5;
+ f6 = 6;
+
+ break;
+
+ case 5:
+ f2 = 2;
+ f3 = 3;
+ f7 = 7;
+
+ break;
+
+ case 6:
+ f8 = 8;
+
+ break;
+ }
+ }
+
+ public void WriteBinary(IBinaryWriter writer)
+ {
+ writer.WriteInt("mode", mode);
+
+ switch (mode)
+ {
+ case 1:
+ writer.WriteInt("f2", f2);
+
+ break;
+
+ case 2:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f4", f4);
+
+ break;
+
+ case 3:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f5", f5);
+
+ break;
+
+ case 4:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f5", f5);
+ writer.WriteInt("f6", f6);
+
+ break;
+
+ case 5:
+ writer.WriteInt("f2", f2);
+ writer.WriteInt("f3", f3);
+ writer.WriteInt("f7", f7);
+
+ break;
+
+ case 6:
+ writer.WriteInt("f8", f8);
+
+ break;
+ }
+ }
+
+ public void ReadBinary(IBinaryReader reader)
+ {
+ mode = reader.ReadInt("mode");
+
+ switch (mode)
+ {
+ case 1:
+ f2 = reader.ReadInt("f2");
+
+ break;
+
+ case 2:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f4 = reader.ReadInt("f4");
+
+ break;
+
+ case 3:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f5 = reader.ReadInt("f5");
+
+ break;
+
+ case 4:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f5 = reader.ReadInt("f5");
+ f6 = reader.ReadInt("f6");
+
+ break;
+
+ case 5:
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
+ f7 = reader.ReadInt("f7");
+
+ break;
+
+ case 6:
+ f8 = reader.ReadInt("f8");
+
+ break;
+ }
+ }
+
+ public bool Equals(BranchedType other)
+ {
+ return mode == other.mode && f2 == other.f2 && f3 == other.f3 && f4 == other.f4 && f5 == other.f5 &&
+ f6 == other.f6 && f7 == other.f7 && f8 == other.f8;
+ }
+ }
+}
[50/55] [abbrv] ignite git commit: IGNITE-1282 - Fixed queries.
Posted by ag...@apache.org.
IGNITE-1282 - Fixed queries.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/80abb061
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/80abb061
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/80abb061
Branch: refs/heads/ignite-1.5
Commit: 80abb061b8a19b14a3d6e16f3c15de017d7df09a
Parents: f17dfd0
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Nov 20 20:28:14 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Nov 20 20:28:14 2015 +0300
----------------------------------------------------------------------
.../processors/query/GridQueryProcessor.java | 37 ++++++++++++++++----
1 file changed, 31 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/80abb061/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 4d1145d..fbe54e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -45,6 +45,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.binary.BinaryField;
+import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.cache.CacheTypeMetadata;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.QueryIndex;
@@ -1808,6 +1809,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
/** Binary field to speed-up deserialization. */
private volatile BinaryField field;
+ /** Flag indicating that we already tried to take a field. */
+ private volatile boolean fieldTaken;
+
/**
* Constructor.
*
@@ -1861,7 +1865,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
BinaryObject obj0 = (BinaryObject)obj;
- return binaryField(obj0).value(obj0);
+ return fieldValue(obj0);
}
/**
@@ -1873,18 +1877,39 @@ public class GridQueryProcessor extends GridProcessorAdapter {
private BinaryField binaryField(BinaryObject obj) {
BinaryField field0 = field;
- if (field0 == null)
- {
- field0 = obj.type().field(propName);
+ if (field0 == null && !fieldTaken) {
+ BinaryType type = obj.type();
+
+ if (type != null) {
+ field0 = type.field(propName);
+
+ assert field0 != null;
- assert field0 != null;
+ field = field0;
+ }
- field = field0;
+ fieldTaken = true;
}
return field0;
}
+ /**
+ * Gets field value for the given binary object.
+ *
+ * @param obj Binary object.
+ * @return Field value.
+ */
+ @SuppressWarnings("IfMayBeConditional")
+ private Object fieldValue(BinaryObject obj) {
+ BinaryField field = binaryField(obj);
+
+ if (field != null)
+ return field.value(obj);
+ else
+ return obj.field(propName);
+ }
+
/** {@inheritDoc} */
@Override public String name() {
return alias;
[30/55] [abbrv] ignite git commit: IGNITE-1951: Safe default
type/field ID calculation: zeros are not allowed.
Posted by ag...@apache.org.
IGNITE-1951: Safe default type/field ID calculation: zeros are not allowed.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/60b805e6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/60b805e6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/60b805e6
Branch: refs/heads/ignite-1.5
Commit: 60b805e6829b7076490bd3727472cc96a216adb3
Parents: d69b177
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Nov 20 10:39:59 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Nov 20 10:39:59 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryInternalIdMapper.java | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/60b805e6/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java
index dd434ff..2b5a53a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryInternalIdMapper.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.portable;
import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryObjectException;
import org.jetbrains.annotations.Nullable;
/**
@@ -79,7 +80,7 @@ public class BinaryInternalIdMapper implements BinaryIdMapper {
public int typeId(String typeName) {
assert typeName != null;
- return lowerCaseHashCode(typeName);
+ return lowerCaseHashCode(typeName, true);
}
/**
@@ -92,16 +93,17 @@ public class BinaryInternalIdMapper implements BinaryIdMapper {
public int fieldId(int typeId, String fieldName) {
assert fieldName != null;
- return lowerCaseHashCode(fieldName);
+ return lowerCaseHashCode(fieldName, false);
}
/**
* Routine to calculate string hash code an
*
* @param str String.
+ * @param type {@code True} if this is type name, false otherwise.
* @return Hash code for given string converted to lower case.
*/
- private static int lowerCaseHashCode(String str) {
+ private static int lowerCaseHashCode(String str, boolean type) {
int len = str.length();
int h = 0;
@@ -114,7 +116,14 @@ public class BinaryInternalIdMapper implements BinaryIdMapper {
h = 31 * h + c;
}
- return h;
+ if (h != 0)
+ return h;
+ else {
+ String what = type ? "type" : "field";
+
+ throw new BinaryObjectException("Default binary ID mapper resolved " + what + " ID to zero " +
+ "(either change " + what + "'s name or use custom ID mapper) [name=" + str + ']');
+ }
}
/**