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 <voze...@gridgain.com> wrote: > 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 user > about potential problems if order is violated. > > On Thu, Apr 13, 2017 at 2:16 PM, Alexey Goncharuk < > alexey.goncha...@gmail.com> wrote: > > > That is cool, completely forgot about it :) > > > > 2017-04-13 14:07 GMT+03:00 Pavel Tupitsyn <ptupit...@apache.org>: > > > > > 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 case must be written first. > > > > > > > > 2017-04-13 0:29 GMT+03:00 Dmitriy Setrakyan <dsetrak...@apache.org>: > > > > > > > > > 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 < > > voze...@gridgain.com > > > > > > > > > wrote: > > > > > > > > > > > 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 < > > > > > dsetrak...@apache.org> > > > > > > wrote: > > > > > > > > > > > > > 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 < > > > > ptupit...@apache.org > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > 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. > > > > > > > > > > > > > > > > So I guess we can agree on sorting fields alphabetically. > > > > > > > > > > > > > > > > Let's get to the initial question: > > > > > > > > * Should we do the sorting for the user (performance hit)? > > > > > > > > * Should we at least validate user-defined order? > > > > > > > > > > > > > > > > On Wed, Apr 12, 2017 at 2:12 AM, Dmitriy Setrakyan < > > > > > > > dsetrak...@apache.org> > > > > > > > > wrote: > > > > > > > > > > > > > > > > > On Tue, Apr 11, 2017 at 1:28 PM, Sergi Vladykin < > > > > > > > > sergi.vlady...@gmail.com> > > > > > > > > > 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 DML builds keys this way and require from > > user > > > to > > > > > do > > > > > > > the > > > > > > > > > same > > > > > > > > > > to be able to use cache API. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I think it is important from the usability stand point. A > > user > > > > can > > > > > > > always > > > > > > > > > sort fields alphabetically in his or her mind. However, > > trying > > > to > > > > > > > > remember > > > > > > > > > the field order from some QueryEntity is a lot harder. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >