ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Tupitsyn <ptupit...@gridgain.com>
Subject Re: Enable Binary Reflective Serializer in the app.config
Date Fri, 24 Jun 2016 12:26:34 GMT
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 <ptupitsyn@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.
>>
>
>

Mime
View raw message