Re: Fwd: Re: Ignite cache query

2018-04-25 Thread Вячеслав Коптилин
Hello Shaleen,

It looks like that you want that SQL engine would create table columns
based on the hashmap which has a dynamic structure (obviously you can add
and remove keys from the map simultaneously).
So, every time when you add/remove a key from the map for a particular
entry, SQL engine should automatically add/remove the corresponding column.
I don't think it is possible.

I see only the one way, that can be used here. This is a user-defined
function [1]
public class Pojo {
@QuerySqlField
private Map map;

@QuerySqlFunction
public static String get(Map field, String id) {
return map.get(id);
}

...
}

In that case, you can use this custom function as follows: select * from
Pojo where get(map,?)=?
Though you will not be able to use indexes this way.

[1] https://apacheignite-sql.readme.io/docs/custom-sql-functions

Thanks.

2018-04-24 9:00 GMT+03:00 Shaleen Sharma :

> Hi All
>
> Is there anything anyone has to say about the below issue?
>
> Thanks
> Shaleen
>
> *From:* Shaleen Sharma 
> *Sent:* Monday, April 23, 2018 4:04:13 PM
> *To:* user@ignite.apache.org; user@ignite.apache.org
> *Subject:* Re: Ignite cache query
>
> Thanks for your reply.
>
> Forgot to mention earlier that I am already using @QuerySqlField on each
> field of my Pojo class so all the fields are appearing as table columns but
> the hashmap doesn't. So how do i use @QuerySqlField on a hashmap so that
> each key of hashmap also behaves as a table column which I can use to do an
> "order by" in my sql.
>
> Thanks
> Shaleen
>
>
>
> From: begineer
> Sent: Monday, 23 April, 3:53 pm
> Subject: Re: Ignite cache query
> To: user@ignite.apache.org
>
>
> e.g. public class Student { @QuerySqlField(index=true) int id;
> @QuerySqlField String name ; @QuerySqlField LocalDateTime dob;
> @QuerySqlField LocalDate dos; @QuerySqlField Map> map = new HashMap config
> = new CacheConfiguration cache = ignite.getOrCreateCache(config);
> DateTimeFormatter formatter = DateTimeFormatter.ofPattern("-MM-dd
> H:mm"); LocalDateTime time1= LocalDateTime.now(); String s =
> time1.format(formatter); LocalDateTime time = LocalDateTime.parse(s,
> formatter); Map> map = new HashMap query = new SqlQuery list =
> cache.query(query).getAll().stream().map(Cache.Entry::
> getValue).collect(Collectors.toList()); -- Sent from:
> http://apache-ignite-users.70518.x6.nabble.com/
>
>
>
>


Re: Fwd: Re: Ignite cache query

2018-04-23 Thread Shaleen Sharma
Hi All

Is there anything anyone has to say about the below issue?

Thanks
Shaleen

From: Shaleen Sharma 
Sent: Monday, April 23, 2018 4:04:13 PM
To: user@ignite.apache.org; user@ignite.apache.org
Subject: Re: Ignite cache query

Thanks for your reply.

Forgot to mention earlier that I am already using @QuerySqlField on each field 
of my Pojo class so all the fields are appearing as table columns but the 
hashmap doesn't. So how do i use @QuerySqlField on a hashmap so that each key 
of hashmap also behaves as a table column which I can use to do an "order by" 
in my sql.

Thanks
Shaleen



From: begineer
Sent: Monday, 23 April, 3:53 pm
Subject: Re: Ignite cache query
To: user@ignite.apache.org


e.g. public class Student { @QuerySqlField(index=true) int id; @QuerySqlField 
String name ; @QuerySqlField LocalDateTime dob; @QuerySqlField LocalDate dos; 
@QuerySqlField Map> map = new HashMap config = new CacheConfiguration cache = 
ignite.getOrCreateCache(config); DateTimeFormatter formatter = 
DateTimeFormatter.ofPattern("-MM-dd H:mm"); LocalDateTime time1= 
LocalDateTime.now(); String s = time1.format(formatter); LocalDateTime time = 
LocalDateTime.parse(s, formatter); Map> map = new HashMap query = new SqlQuery 
list = 
cache.query(query).getAll().stream().map(Cache.Entry::getValue).collect(Collectors.toList());
 -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/