Sql Query using Map as value for cache

classic Classic list List threaded Threaded
5 messages Options
Andrey Nestrogaev Andrey Nestrogaev
Reply | Threaded
Open this post in threaded view
|

Sql Query using Map as value for cache

Hi!

Testing Ignite 1.5.0.

Can we use Query, QueryIndexes over caches where values is a Map.class subclasses?
Or its possible only for POJO as a value?

Thanks!
Denis Magda Denis Magda
Reply | Threaded
Open this post in threaded view
|

Re: Sql Query using Map as value for cache

Hi,

I'll highly discourage you doing this.

I didn't check but probably you won't get any runtime exception if to
mark such a value as an index but no magic will happen. Maps should be
compared using equals() method implementation and sorted (maps
instances) according to compareTo() method.

So my suggestion is to redesign your data model to avoid such use cases.

--
Denis

On 1/22/2016 11:10 AM, Andrey Nestrogaev wrote:

> Hi!
>
> Testing Ignite 1.5.0.
>
> Can we use Query, QueryIndexes over caches where values is a Map.class
> subclasses?
> Or its possible only for POJO as a value?
>
> Thanks!
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Sql-Query-using-Map-as-value-for-cache-tp2668.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Andrey Nestrogaev Andrey Nestrogaev
Reply | Threaded
Open this post in threaded view
|

Re: Sql Query using Map as value for cache

Hi, thanks for response!

"Maps should be
compared using equals() method implementation and sorted (maps
instances) according to compareTo() method
"

I do not quite understand what the problem is, is POJO do not need to do the same?

My usecase is to create new queryable caches (queryable by sql query) at runtime.
What is your recommendation for such usecases?


Thanks!
vkulichenko vkulichenko
Reply | Threaded
Open this post in threaded view
|

Re: Sql Query using Map as value for cache

Hi Andrey,

Sounds like binary objects [1] could be useful for your use case. You can create cache objects on the fly using BinaryBuilder and they will support field lookups directly from byte array. It's like saving a POJO, but without having a POJO :)

Cache itself can be easily created dynamically as well [2].

Hope this helps.

[1] https://apacheignite.readme.io/docs/binary-marshaller
[2] https://apacheignite.readme.io/v1.5/docs/jcache#section-dynamic-cache

-Val
Andrey Nestrogaev Andrey Nestrogaev
Reply | Threaded
Open this post in threaded view
|

Re: Sql Query using Map as value for cache

Hi Val,

BinaryObject is what I was looking for. I've tested it and it suits for my task.

Thank you very mach!