You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by mrinalkamboj <mr...@gmail.com> on 2016/06/23 08:06:15 UTC
Enable Binary Reflective Serializer in the app.config
What is the App.Config replacement to enable the following c# code in the
documents or this can be only done in C# code
var binaryConfiguration = new BinaryConfiguration
{
TypeConfigurations = new[]
{
new BinaryTypeConfiguration(typeof(MyClass))
{
Serializer = new BinaryReflectiveSerializer {RawMode = true}
}
}
};
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Enable Binary Reflective Serializer in the app.config
Posted by Pavel Tupitsyn <pt...@gridgain.com>.
... and another fix would be to remove [QuerySqlField] attribute, since
queries won't work with raw mode anyway.
On Fri, Jun 24, 2016 at 3:26 PM, Pavel Tupitsyn <pt...@gridgain.com>
wrote:
> The workaround is to implement raw mode manually via IBinarizable
> interface.
> It will look like this for the OrderEntity class (field order should be
> the same in read and write methods):
>
> public void WriteBinary(IBinaryWriter writer)
> {
> var w = writer.GetRawWriter();
>
> w.WriteInt(OrderId);
> w.WriteString(OrderName);
> w.WriteObject(OrderDateTime);
> w.WriteDouble(OrderValue);
> w.WriteString(OrderAddress);
> }
> public void ReadBinary(IBinaryReader reader)
> {
> var r = reader.GetRawReader();
>
> OrderId = r.ReadInt();
> OrderName = r.ReadString();
> OrderDateTime = r.ReadObject<DateTime>();
> OrderValue = r.ReadDouble();
> OrderAddress = r.ReadString();
> }
>
>
> On Fri, Jun 24, 2016 at 3:22 PM, Pavel Tupitsyn <pt...@gridgain.com>
> wrote:
>
>> I've reproduced it.
>> There is a bug with DateTime in raw mode. It works when I remove
>> OrderEntity.OrderDateTime property.
>>
>> Bug is filed and will be fixed shortly:
>> https://issues.apache.org/jira/browse/IGNITE-3364
>>
>> On Fri, Jun 24, 2016 at 2:15 PM, mrinalkamboj <
>> mrinal.technology@gmail.com> wrote:
>>
>>> On enabling the rawMode="true", as suggested in the configuration file,
>>> following piece of code leads to the exception:
>>>
>>> using (var ldr = ignite.GetDataStreamer<int, OrderEntity>("OrderCache"))
>>> {
>>> ldr.PerNodeBufferSize = 1024;
>>>
>>> //ldr.AllowOverwrite = true;
>>>
>>> var parallelOptions = new ParallelOptions {
>>> MaxDegreeOfParallelism = Environment.ProcessorCount };
>>>
>>> // ReSharper disable once AccessToDisposedClosure
>>> Parallel.Invoke(parallelOptions, orders.Select(order =>
>>> (Action)(() => ldr.AddData(order.OrderId, order))).ToArray());
>>> }
>>>
>>> On the AddData call of the Data Streamer and the Exception is:
>>>
>>> {Apache.Ignite.Core.Binary.BinaryObjectException} - Cannot write named
>>> fields after raw data is written.
>>>
>>> Logically this looks correct, but what shall I do now, can't use Data
>>> Streamer with this setting, if I remove the rawMode setting then it works
>>> fine
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819p5872.html
>>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>>
>>
>>
>
Re: Enable Binary Reflective Serializer in the app.config
Posted by Pavel Tupitsyn <pt...@gridgain.com>.
The workaround is to implement raw mode manually via IBinarizable interface.
It will look like this for the OrderEntity class (field order should be the
same in read and write methods):
public void WriteBinary(IBinaryWriter writer)
{
var w = writer.GetRawWriter();
w.WriteInt(OrderId);
w.WriteString(OrderName);
w.WriteObject(OrderDateTime);
w.WriteDouble(OrderValue);
w.WriteString(OrderAddress);
}
public void ReadBinary(IBinaryReader reader)
{
var r = reader.GetRawReader();
OrderId = r.ReadInt();
OrderName = r.ReadString();
OrderDateTime = r.ReadObject<DateTime>();
OrderValue = r.ReadDouble();
OrderAddress = r.ReadString();
}
On Fri, Jun 24, 2016 at 3:22 PM, Pavel Tupitsyn <pt...@gridgain.com>
wrote:
> I've reproduced it.
> There is a bug with DateTime in raw mode. It works when I remove
> OrderEntity.OrderDateTime property.
>
> Bug is filed and will be fixed shortly:
> https://issues.apache.org/jira/browse/IGNITE-3364
>
> On Fri, Jun 24, 2016 at 2:15 PM, mrinalkamboj <mrinal.technology@gmail.com
> > wrote:
>
>> On enabling the rawMode="true", as suggested in the configuration file,
>> following piece of code leads to the exception:
>>
>> using (var ldr = ignite.GetDataStreamer<int, OrderEntity>("OrderCache"))
>> {
>> ldr.PerNodeBufferSize = 1024;
>>
>> //ldr.AllowOverwrite = true;
>>
>> var parallelOptions = new ParallelOptions {
>> MaxDegreeOfParallelism = Environment.ProcessorCount };
>>
>> // ReSharper disable once AccessToDisposedClosure
>> Parallel.Invoke(parallelOptions, orders.Select(order =>
>> (Action)(() => ldr.AddData(order.OrderId, order))).ToArray());
>> }
>>
>> On the AddData call of the Data Streamer and the Exception is:
>>
>> {Apache.Ignite.Core.Binary.BinaryObjectException} - Cannot write named
>> fields after raw data is written.
>>
>> Logically this looks correct, but what shall I do now, can't use Data
>> Streamer with this setting, if I remove the rawMode setting then it works
>> fine
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819p5872.html
>> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>>
>
>
Re: Enable Binary Reflective Serializer in the app.config
Posted by Pavel Tupitsyn <pt...@gridgain.com>.
I've reproduced it.
There is a bug with DateTime in raw mode. It works when I remove
OrderEntity.OrderDateTime property.
Bug is filed and will be fixed shortly:
https://issues.apache.org/jira/browse/IGNITE-3364
On Fri, Jun 24, 2016 at 2:15 PM, mrinalkamboj <mr...@gmail.com>
wrote:
> On enabling the rawMode="true", as suggested in the configuration file,
> following piece of code leads to the exception:
>
> using (var ldr = ignite.GetDataStreamer<int, OrderEntity>("OrderCache"))
> {
> ldr.PerNodeBufferSize = 1024;
>
> //ldr.AllowOverwrite = true;
>
> var parallelOptions = new ParallelOptions {
> MaxDegreeOfParallelism = Environment.ProcessorCount };
>
> // ReSharper disable once AccessToDisposedClosure
> Parallel.Invoke(parallelOptions, orders.Select(order =>
> (Action)(() => ldr.AddData(order.OrderId, order))).ToArray());
> }
>
> On the AddData call of the Data Streamer and the Exception is:
>
> {Apache.Ignite.Core.Binary.BinaryObjectException} - Cannot write named
> fields after raw data is written.
>
> Logically this looks correct, but what shall I do now, can't use Data
> Streamer with this setting, if I remove the rawMode setting then it works
> fine
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819p5872.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>
Re: Enable Binary Reflective Serializer in the app.config
Posted by mrinalkamboj <mr...@gmail.com>.
On enabling the rawMode="true", as suggested in the configuration file,
following piece of code leads to the exception:
using (var ldr = ignite.GetDataStreamer<int, OrderEntity>("OrderCache"))
{
ldr.PerNodeBufferSize = 1024;
//ldr.AllowOverwrite = true;
var parallelOptions = new ParallelOptions {
MaxDegreeOfParallelism = Environment.ProcessorCount };
// ReSharper disable once AccessToDisposedClosure
Parallel.Invoke(parallelOptions, orders.Select(order =>
(Action)(() => ldr.AddData(order.OrderId, order))).ToArray());
}
On the AddData call of the Data Streamer and the Exception is:
{Apache.Ignite.Core.Binary.BinaryObjectException} - Cannot write named
fields after raw data is written.
Logically this looks correct, but what shall I do now, can't use Data
Streamer with this setting, if I remove the rawMode setting then it works
fine
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819p5872.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Enable Binary Reflective Serializer in the app.config
Posted by Pavel Tupitsyn <pt...@gridgain.com>.
Please provide the exception details.
On Thu, Jun 23, 2016 at 4:24 PM, mrinalkamboj <mr...@gmail.com>
wrote:
> Thanks it works but it doesn't recognize the rawMode="true", this
> configuration is not available and leads to exception
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819p5838.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>
Re: Enable Binary Reflective Serializer in the app.config
Posted by mrinalkamboj <mr...@gmail.com>.
Thanks it works but it doesn't recognize the rawMode="true", this
configuration is not available and leads to exception
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819p5838.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Enable Binary Reflective Serializer in the app.config
Posted by Pavel Tupitsyn <pt...@gridgain.com>.
Hi, you can do it like this:
<igniteConfiguration xmlns="
http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection">
<binaryConfiguration>
<typeConfigurations>
<binaryTypeConfiguration typeName="MyClass">
<serializer type="Apache.Ignite.Core.Binary.BinaryReflectiveSerializer,
Apache.Ignite.Core" rawMode="true" />
</binaryTypeConfiguration>
</typeConfigurations>
</binaryConfiguration>
</igniteConfiguration>
On Thu, Jun 23, 2016 at 11:06 AM, mrinalkamboj <mr...@gmail.com>
wrote:
> What is the App.Config replacement to enable the following c# code in the
> documents or this can be only done in C# code
>
> var binaryConfiguration = new BinaryConfiguration
> {
> TypeConfigurations = new[]
> {
> new BinaryTypeConfiguration(typeof(MyClass))
> {
> Serializer = new BinaryReflectiveSerializer {RawMode = true}
> }
> }
> };
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Enable-Binary-Reflective-Serializer-in-the-app-config-tp5819.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>