You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Igor Rudyak <ir...@gmail.com> on 2017/06/19 22:08:43 UTC

BinaryObjects and hashCode()

Hi,

I am using simple POJO objects as key/value pair for my Ignite cache. Also
I would like to store objects as BinaryObjects. Thus Ignite cache was
created using:

*mycache = ignite.getOrCreateCache("mycache").withKeepBinary()*

When I am trying to put objects in the cache I am receiving such an error:

*java.lang.IllegalArgumentException: Cache key must override hashCode() and
equals() methods: com.test.MyKey*

Isn't this contradicts to *BinaryObjects* concept? As far as there are no
*com.test.MyKey* class deployed on the server side all implemented class
methods (including *hashCode* and *equals*) are useless, cause they will
not be available on the server.

Igor

Re: BinaryObjects and hashCode()

Posted by Igor Rudyak <ir...@gmail.com>.
Vladimir,

Thanks for the clarification.

Igor

On Jun 20, 2017 2:37 AM, "Vladimir Ozerov" <vo...@gridgain.com> wrote:

> Igor,
>
> This exception is just a regression from recent work on binary
> serialization in the scope of 2.0 release. If BinaryMarshaller is set, we
> should not force users to have equals/hashCode methods on keys. There is a
> ticket [1], hopefully it will be merged to master soon.
>
> Vladimir.
>
> [1] https://issues.apache.org/jira/browse/IGNITE-5383
>
> On Tue, Jun 20, 2017 at 1:08 AM, Igor Rudyak <ir...@gmail.com> wrote:
>
> > Hi,
> >
> > I am using simple POJO objects as key/value pair for my Ignite cache.
> Also
> > I would like to store objects as BinaryObjects. Thus Ignite cache was
> > created using:
> >
> > *mycache = ignite.getOrCreateCache("mycache").withKeepBinary()*
> >
> > When I am trying to put objects in the cache I am receiving such an
> error:
> >
> > *java.lang.IllegalArgumentException: Cache key must override hashCode()
> > and
> > equals() methods: com.test.MyKey*
> >
> > Isn't this contradicts to *BinaryObjects* concept? As far as there are no
> > *com.test.MyKey* class deployed on the server side all implemented class
> > methods (including *hashCode* and *equals*) are useless, cause they will
> > not be available on the server.
> >
> > Igor
> >
>

Re: BinaryObjects and hashCode()

Posted by Vladimir Ozerov <vo...@gridgain.com>.
Igor,

This exception is just a regression from recent work on binary
serialization in the scope of 2.0 release. If BinaryMarshaller is set, we
should not force users to have equals/hashCode methods on keys. There is a
ticket [1], hopefully it will be merged to master soon.

Vladimir.

[1] https://issues.apache.org/jira/browse/IGNITE-5383

On Tue, Jun 20, 2017 at 1:08 AM, Igor Rudyak <ir...@gmail.com> wrote:

> Hi,
>
> I am using simple POJO objects as key/value pair for my Ignite cache. Also
> I would like to store objects as BinaryObjects. Thus Ignite cache was
> created using:
>
> *mycache = ignite.getOrCreateCache("mycache").withKeepBinary()*
>
> When I am trying to put objects in the cache I am receiving such an error:
>
> *java.lang.IllegalArgumentException: Cache key must override hashCode()
> and
> equals() methods: com.test.MyKey*
>
> Isn't this contradicts to *BinaryObjects* concept? As far as there are no
> *com.test.MyKey* class deployed on the server side all implemented class
> methods (including *hashCode* and *equals*) are useless, cause they will
> not be available on the server.
>
> Igor
>

Re: BinaryObjects and hashCode()

Posted by Igor Rudyak <ir...@gmail.com>.
If the server doesn't calculate hash code how it then should work for
objects which expired from cache and were pushed to persistent store?

As far as persistent store methods (loadCache, load, loadAll) will be
executed on server side it looks like server should have custom logic for
hashCode() and equals().


Igor

On Mon, Jun 19, 2017 at 3:45 PM, Dmitriy Setrakyan <ds...@apache.org>
wrote:

> Igor,
>
> As far as I know, the hash code would be calculated on the client side and
> sent over within the binary format. Server does not calculate the hash
> code.
>
> D.
>
> On Tue, Jun 20, 2017 at 12:08 AM, Igor Rudyak <ir...@gmail.com> wrote:
>
> > Hi,
> >
> > I am using simple POJO objects as key/value pair for my Ignite cache.
> Also
> > I would like to store objects as BinaryObjects. Thus Ignite cache was
> > created using:
> >
> > *mycache = ignite.getOrCreateCache("mycache").withKeepBinary()*
> >
> > When I am trying to put objects in the cache I am receiving such an
> error:
> >
> > *java.lang.IllegalArgumentException: Cache key must override hashCode()
> > and
> > equals() methods: com.test.MyKey*
> >
> > Isn't this contradicts to *BinaryObjects* concept? As far as there are no
> > *com.test.MyKey* class deployed on the server side all implemented class
> > methods (including *hashCode* and *equals*) are useless, cause they will
> > not be available on the server.
> >
> > Igor
> >
>

Re: BinaryObjects and hashCode()

Posted by Dmitriy Setrakyan <ds...@apache.org>.
Igor,

As far as I know, the hash code would be calculated on the client side and
sent over within the binary format. Server does not calculate the hash code.

D.

On Tue, Jun 20, 2017 at 12:08 AM, Igor Rudyak <ir...@gmail.com> wrote:

> Hi,
>
> I am using simple POJO objects as key/value pair for my Ignite cache. Also
> I would like to store objects as BinaryObjects. Thus Ignite cache was
> created using:
>
> *mycache = ignite.getOrCreateCache("mycache").withKeepBinary()*
>
> When I am trying to put objects in the cache I am receiving such an error:
>
> *java.lang.IllegalArgumentException: Cache key must override hashCode()
> and
> equals() methods: com.test.MyKey*
>
> Isn't this contradicts to *BinaryObjects* concept? As far as there are no
> *com.test.MyKey* class deployed on the server side all implemented class
> methods (including *hashCode* and *equals*) are useless, cause they will
> not be available on the server.
>
> Igor
>