Re: Sorting fields of Binarilyzable objects on write

2017-04-13 Thread Dmitriy Setrakyan
Vova, can you give an example of when writing out of order would be the only option? On Thu, Apr 13, 2017 at 4:20 AM, Vladimir Ozerov wrote: > Folks, > > If you restrict writes in certain order and conditions, Binarylizable > interfaces turns into an unusable bullshit :-) Remember that not all b

Re: Sorting fields of Binarilyzable objects on write

2017-04-13 Thread Vladimir Ozerov
Folks, If you restrict writes in certain order and conditions, Binarylizable interfaces turns into an unusable bullshit :-) Remember that not all binary objects participate in DML, and even if so, not all binary objects are cache keys. I think we should simply print a warning to log, informing use

Re: Sorting fields of Binarilyzable objects on write

2017-04-13 Thread Alexey Goncharuk
That is cool, completely forgot about it :) 2017-04-13 14:07 GMT+03:00 Pavel Tupitsyn : > Alexey, we can read fields in any order in non-raw mode. > Dmitriy's suggestion would work. > > On Thu, Apr 13, 2017 at 1:56 PM, Alexey Goncharuk < > alexey.goncha...@gmail.com> wrote: > > > Dmitriy, > > > >

Re: Sorting fields of Binarilyzable objects on write

2017-04-13 Thread Pavel Tupitsyn
Alexey, we can read fields in any order in non-raw mode. Dmitriy's suggestion would work. On Thu, Apr 13, 2017 at 1:56 PM, Alexey Goncharuk < alexey.goncha...@gmail.com> wrote: > Dmitriy, > > How would then reader determine which field to read (a and b could the of > different size)? c in this ca

Re: Sorting fields of Binarilyzable objects on write

2017-04-13 Thread Alexey Goncharuk
Dmitriy, How would then reader determine which field to read (a and b could the of different size)? c in this case must be written first. 2017-04-13 0:29 GMT+03:00 Dmitriy Setrakyan : > Vladimir, > > Would this be valid? > > *void writeBinary(BinaryWriter w) {* > > *if (c)* > *w.writ

Re: Sorting fields of Binarilyzable objects on write

2017-04-12 Thread Dmitriy Setrakyan
Vladimir, Would this be valid? *void writeBinary(BinaryWriter w) {* *if (c)* *w.writeInt("A", a)* *else* *w.writeInt("B", b)* *w.writeBoolean("C", c);* *}* D. On Wed, Apr 12, 2017 at 1:07 AM, Vladimir Ozerov wrote: > Consider the following code: > > void writeBin

Re: Sorting fields of Binarilyzable objects on write

2017-04-12 Thread Sergi Vladykin
Vladimir, I think we have to disallow conditional writes here, because DML should write all the fields, no? Sergi 2017-04-12 11:07 GMT+03:00 Vladimir Ozerov : > Consider the following code: > > void writeBinary(BinaryWriter w) { > w.writeBoolean("C", c); > > if (c) > w.writeInt(

Re: Sorting fields of Binarilyzable objects on write

2017-04-12 Thread Vladimir Ozerov
Consider the following code: void writeBinary(BinaryWriter w) { w.writeBoolean("C", c); if (c) w.writeInt("A", a) else w.writeInt("B", b) } How are we going to force user to follow the contract in this case? On Wed, Apr 12, 2017 at 9:16 AM, Dmitriy Setrakyan wrote:

Re: Sorting fields of Binarilyzable objects on write

2017-04-11 Thread Dmitriy Setrakyan
I think it is OK for users to do their own sorting, but we should definitely validate the correct order and throw an exception if it is not. D. On Tue, Apr 11, 2017 at 11:02 PM, Pavel Tupitsyn wrote: > QueryEntity order is not only harder for the users, it will be nightmare to > implement. > Wh

Re: Sorting fields of Binarilyzable objects on write

2017-04-11 Thread Pavel Tupitsyn
QueryEntity order is not only harder for the users, it will be nightmare to implement. What if there is no QueryEntity defined? What if the same class is used in multiple QueryEntity? I don't think serialization code has to be tied to QueryEntity in any way, this violates separation of concerns. S

Re: Sorting fields of Binarilyzable objects on write

2017-04-11 Thread Dmitriy Setrakyan
On Tue, Apr 11, 2017 at 1:28 PM, Sergi Vladykin wrote: > I'm just trying to understand the current state of things and risks. May be > we need to do some adjustments here before 2.0 to be on the safe side. > > Actually looks like this not really important, we just have to clearly > document that

Re: Sorting fields of Binarilyzable objects on write

2017-04-11 Thread Sergi Vladykin
I'm just trying to understand the current state of things and risks. May be we need to do some adjustments here before 2.0 to be on the safe side. Actually looks like this not really important, we just have to clearly document that DML builds keys this way and require from user to do the same to b

Re: Sorting fields of Binarilyzable objects on write

2017-04-11 Thread Dmitriy Setrakyan
Sergi, why do you not like the alphabetical order? Seems like it would be a much easier to understand requirement from the user standpoint. Do you see some issues here? On Mon, Apr 10, 2017 at 10:43 AM, Sergi Vladykin wrote: > I'm sorry, looks like I do not really well understand this stuff, but

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Sergi Vladykin
I'm sorry, looks like I do not really well understand this stuff, but it is still not clear to me why wouldn't we just take the order of key fields given in QueryEntity and use it for both cases irrespectively to the order of fields in regular Class or in Binarylizable? I mean lets say we have a C

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Vladimir Ozerov
Guys, The problem is that order of fields serialization is unknown for regular objects, where "regular" stands for non-Binarilyzable class. Reflection returns fields in unpredictable order. For this reason you cannot match fields order between class and QueryEntity. This is why we introduced sorti

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Sergi Vladykin
Why "regular" are different here? Sergi 2017-04-10 18:59 GMT+03:00 Pavel Tupitsyn : > QueryEntity sorting is not an option for "regular" classes with reflective > serialization. > We have to use alphabetical. > Also, same class can participate in multiple query entities. > > 10 апр. 2017 г. 18:5

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Pavel Tupitsyn
QueryEntity sorting is not an option for "regular" classes with reflective serialization. We have to use alphabetical. Also, same class can participate in multiple query entities. 10 апр. 2017 г. 18:52 пользователь "Dmitriy Setrakyan" < dsetrak...@apache.org> написал: On Mon, Apr 10, 2017 at 8:28

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Dmitriy Setrakyan
On Mon, Apr 10, 2017 at 8:28 AM, Sergi Vladykin wrote: > The decision to use alphabetic order looks strange here. Using order > provided in QueryEntity and require from user to have the same order > in Binarylizable > looks more reasonable. > I think this would be much harder to verify. Alphabet

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Sergi Vladykin
I even think that in DML we have to just calculate hashCode in order of QueryEntity regardless of order in Binarylizable. Sergi 2017-04-10 18:29 GMT+03:00 Dmitriy Setrakyan : > Does anyone disagree about having users sort the fields themselves, as > Sergi and I suggested above? > > On Mon, Apr 1

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Dmitriy Setrakyan
Does anyone disagree about having users sort the fields themselves, as Sergi and I suggested above? On Mon, Apr 10, 2017 at 8:21 AM, Pavel Tupitsyn wrote: > Sergi, DML writes fields in alphabetic order and computes hash code > accordingly. > If user-defined Binarylizable impl uses different orde

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Sergi Vladykin
The decision to use alphabetic order looks strange here. Using order provided in QueryEntity and require from user to have the same order in Binarylizable looks more reasonable. Sergi 2017-04-10 18:21 GMT+03:00 Pavel Tupitsyn : > Sergi, DML writes fields in alphabetic order and computes hash cod

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Pavel Tupitsyn
Sergi, DML writes fields in alphabetic order and computes hash code accordingly. If user-defined Binarylizable impl uses different order, hash codes will be inconsistent. On Mon, Apr 10, 2017 at 6:18 PM, Sergi Vladykin wrote: > What is correct or incorrect ordering for DML? > > Sergi > > 2017-04

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Sergi Vladykin
What is correct or incorrect ordering for DML? Sergi 2017-04-10 18:14 GMT+03:00 Dmitriy Setrakyan : > I would agree that it should be on a user to always sort the fields, if we > make it a part of the contract. However, in this case, we should always > throw exception if user somehow provides fi

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Dmitriy Setrakyan
I would agree that it should be on a user to always sort the fields, if we make it a part of the contract. However, in this case, we should always throw exception if user somehow provides fields in the wrong order. D. On Mon, Apr 10, 2017 at 8:07 AM, Sergi Vladykin wrote: > Could you please ela

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Pavel Tupitsyn
I agree with performance concerns. BinarYLizable (why don't we rename it to Binarizable already, btw?) used to be the fastest approach to serialization (and it makes sense that manual approach is the best). With sorting it won't be so anymore. On the other hand, incorrect ordering will break DML i

Re: Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Sergi Vladykin
Could you please elaborate why would we want to sort fields in Binarilyzable classes? If you are taking from stable binary representation perspective, then I think it is a problem of user, but not ours. Sergi 2017-04-10 17:53 GMT+03:00 Vladimir Ozerov : > Zapalniki, > > Inspired by IGNITE-4669

Sorting fields of Binarilyzable objects on write

2017-04-10 Thread Vladimir Ozerov
Zapalniki, Inspired by IGNITE-4669 (.NET: Sort binary object fields) [1]. Currently we sort binary object fields before when writing them to the output stream in case of standard (Serializable) objects and BinaryObjectBuilder. This makes sense as we have stable binary object representation irresp