Re: Default hash code generation strategy for new binary objects

2016-10-14 Thread Alexander Paschenko
Current design is documented here: https://issues.apache.org/jira/browse/IGNITE-4011, it incorps both equals and hashCode. - Alex 2016-10-03 15:24 GMT+03:00 Dmitriy Setrakyan : > On Mon, Oct 3, 2016 at 5:03 AM, Alexey Goncharuk > wrote: > >> Dima, >> >> Why do you think somebody will need to over

Re: Default hash code generation strategy for new binary objects

2016-10-03 Thread Dmitriy Setrakyan
On Mon, Oct 3, 2016 at 5:03 AM, Alexey Goncharuk wrote: > Dima, > > Why do you think somebody will need to override equals? Currently we do not > have such an ability and AFAIK we did not have a single question regarding > this. Other products, such as Hazelcast, rely solely on binary > represent

Re: Default hash code generation strategy for new binary objects

2016-10-03 Thread Alexey Goncharuk
Dima, Why do you think somebody will need to override equals? Currently we do not have such an ability and AFAIK we did not have a single question regarding this. Other products, such as Hazelcast, rely solely on binary representation of a key. If this is never used, why do we need to increase the

Re: Default hash code generation strategy for new binary objects

2016-09-30 Thread Dmitriy Setrakyan
Alex, I can't post in the ticket, because my Jira login stopped working, so I will post here. I only have 1 question - do we purposely not support custom equals implementation? Seems we could simply add 2 methods to the BinaryObjectHashCodeResolver: isUseEquals() and computeEquals(). Having said

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Alexander Paschenko
I've posted proposed example of hash code resolver interface and XML configuration for classless key on issue page https://issues.apache.org/jira/browse/IGNITE-2294. 2016-09-29 20:16 GMT+03:00 Dmitriy Setrakyan : > On Thu, Sep 29, 2016 at 9:57 AM, Denis Magda wrote: > >> Alex, >> >> A minor note

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Dmitriy Setrakyan
On Thu, Sep 29, 2016 at 9:57 AM, Denis Magda wrote: > Alex, > > A minor note regarding this > > > On Sep 29, 2016, at 8:39 AM, Alexey Goncharuk < > alexey.goncha...@gmail.com> wrote: > > > > A set of fields participating in hashCode and equals is impossible to > > change without cluster restart.

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Denis Magda
Alex, A minor note regarding this > On Sep 29, 2016, at 8:39 AM, Alexey Goncharuk > wrote: > > A set of fields participating in hashCode and equals is impossible to > change without cluster restart. It’s unlikely that someone will change a key or at least it should be a rare or accidental

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Dmitriy Setrakyan
On Thu, Sep 29, 2016 at 9:19 AM, Alexey Goncharuk < alexey.goncha...@gmail.com> wrote: > I want to step back a little bit. Why do we need to choose fields for > hashCode at all? If all fields participate in equals, all of them should > participate in hashCode as well. We already serialize a user k

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Alexander Paschenko
Dmitry, Just list them in XML config, in the section about indexed types. Will do proposal for that on issue page later today. Regarding validation of the field list - currently there's no (and hardly can be) protection against miscalculation of hash codes passed to the BinaryObjectBuilder. It's

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Alexey Goncharuk
I want to step back a little bit. Why do we need to choose fields for hashCode at all? If all fields participate in equals, all of them should participate in hashCode as well. We already serialize a user key in order to get a value from cache, so we can use a hashCode based on binary object represe

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Alexey Goncharuk
In the assumption that we do not have 'non-equals' fields, binary array comparison generally should be faster, because even if we did a field-by-field comparison, we would read the same amount of data anyway, but also would need to do some byte jiggling for type conversion. 2016-09-29 19:07 GMT+0

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Dmitriy Setrakyan
Alexander, How do you plan to annotate fields that participate in the hashcode calculation? Can you add all the changes you plan to make to the configuration in the ticket and post the link here? Also, we must make sure that hashcode fields do not change. I believe you should have validation in t

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Alexander Paschenko
Thanks everyone! Denis, yes, that's what I meant, now we're on the same page :) However, I'm worried about the same things Alexey is, that is, I'm not sure how we can handle presence of key fields that don't participate in 'equals' evaluation. Hence I'm all up for keeping mechanism of comparison f

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Dmitriy Setrakyan
Alexey, in your opinion, what will be faster, the binary array comparison or field-by-field comparison? On Thu, Sep 29, 2016 at 8:39 AM, Alexey Goncharuk < alexey.goncha...@gmail.com> wrote: > Folks, let me point out a few obvious (or not) things > > A set of fields participating in hashCode and

Re: Default hash code generation strategy for new binary objects

2016-09-29 Thread Alexey Goncharuk
Folks, let me point out a few obvious (or not) things A set of fields participating in hashCode and equals is impossible to change without cluster restart. Imagine a new client adding a field F to key structure (A, B) so that new key is (A, B, F). In this case key (1, 2, 0) will be treated as a di

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Dmitriy Setrakyan
Guys, We need to look at 3 cases: a) key is just one field b) key is multiple fields c) key is one or multiple fields, with possibility of an alternate affinity key For (a) and (b), whenever a type is defined in XML, and further in DML, a user will specify which fields are part of the key. In th

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Denis Magda
Let me show the picture I have in my mind: Primary key is a must for all INSERT and MERGE operations. If it’s not set then an INSERT/MERGE fails. If a primary key is a boxed/unboxed primitive (int, Integer, String, Date, etc.) then the key value is used for hashCode calculation. At the same time

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Alexander Paschenko
Also MERGE. 2016-09-29 2:10 GMT+03:00 Denis Magda : > You need a hash code only for INSERT operation, right? > > — > Denis > >> On Sep 28, 2016, at 3:47 PM, Alexander Paschenko >> wrote: >> >> But what if the user works from some kind of console and just types >> the queries as text in full and

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Denis Magda
You need a hash code only for INSERT operation, right? — Denis > On Sep 28, 2016, at 3:47 PM, Alexander Paschenko > wrote: > > But what if the user works from some kind of console and just types > the queries as text in full and does not bind params via JDBC or > something alike? What if there

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Alexander Paschenko
But what if the user works from some kind of console and just types the queries as text in full and does not bind params via JDBC or something alike? What if there's no binary object? I don't see why we should keep the user from usual cache gets in this case. I really like the idea of supplying the

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Denis Magda
Hmm, this is a good question. If a user doesn’t provide a _key when an INSERT is executed for me it means that he is not going to use the key later for cache.get/put, DELETE, UPDATE and other possible operation simply because he doesn’t know how to reconstruct the key back in his code. If he wa

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Alexander Paschenko
Denis, That's not what I was asking about. Currently DML implementation allows for dymanic instantiation of keys, in other words, user does not have to provide value for object-typed _key column - instead, he may supply just field values based on which _key will be dynamically instantiated/binary

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Denis Magda
Alexander, As I guess if we have a key without a class then it will be constructed using a BinaryBuilder instance and it’s user responsibility to set the has code at the end with BinaryBuilder.hasCode method. Sure, all this cases must be well-documented in both Java Doc API and Apache Ignite do

Re: Default hash code generation strategy for new binary objects

2016-09-28 Thread Alexander Paschenko
Dmitry, Denis, OK, but I think it's necessary to address also the cases when there's no actual class for the key, and its fields are simply declared in XML. In this case, there are no fields to be marked transient. What do we do then? List transient fields in XML separately? - Alex 2016-09-28 4:

Re: Default hash code generation strategy for new binary objects

2016-09-27 Thread Dmitriy Setrakyan
Agree with Denis. - by default, all non-transient key fields should participate in the hashcode generation - when working on DDL, then the primary key fields should participate in the hashcode - we should add a resolver to override the default behavior (please propose the interfa

Re: Default hash code generation strategy for new binary objects

2016-09-27 Thread Denis Magda
Hi Alexander, Vladimir’s proposal sounds reasonable to me. However we must keep in mind one important thing. Binary objects were designed to address the following disadvantages a regular serializer, like optimized marshaller, has: necessity to deserialize an object on a server side every time it

Default hash code generation strategy for new binary objects

2016-09-26 Thread Alexander Paschenko
Hello Igniters, As DML support is near, it's critical that we agree on how we generate hash codes for new keys in presence of binary marshaller. Actually, this discussion isn't new - please see its beginning here: http://apache-ignite-developers.2346864.n4.nabble.com/All-BinaryObjects-created-by-