You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by iostream <si...@gmail.com> on 2017/09/28 07:26:03 UTC
Cache Indexes not getting created Ignite v2.1
*Hi,
I have a setup with 20 ignite cache servers (v2.1). I create my cache using
a client, steps are as follows -
1. Client connects to the ignite cluster during startup.
2. During startup, client checks if my cache is already created (cache name
- "Person")
3. If cache is already created, client does nothing. If cache is not already
created, the client creates the cache.*
*My Cache value object looks like this -*
public class Person implements Serializable {
@QuerySqlField(index = true, orderedGroups = {
@QuerySqlField.Group(name = "personGroup", order = 3, descending = true)
})
@QueryTextField
private String name;
@QuerySqlField(index = true, orderedGroups = {
@QuerySqlField.Group(name = "personGroup", order = 4, descending = true)
})
private String id;
@QuerySqlField(index = true, orderedGroups = {
@QuerySqlField.Group(name = "personGroup", order = 0, descending = false)
})
private String country;
@QuerySqlField(index = true, orderedGroups = {
@QuerySqlField.Group(name = "personGroup", order = 2, descending = false)
})
private String department;
@QuerySqlField(index = true, orderedGroups = {
@QuerySqlField.Group(name = "personGroup", order = 1, descending = false)
})
private Integer stateCode;
@QuerySqlField
private Integer activityStatus;
}
*As can be seen, I have created a group index - personGroup.
The cache creation code in the client looks as follows -*
if (cacheManager.getCache("PersonCache") == null) {
CacheConfiguration<person_key, Person> cacheConfig = new
CacheConfiguration<>();
cacheConfig.setAtomicityMode(TRANSACTIONAL);
cacheConfig.setCacheMode(PARTITIONED);
cacheConfig.setBackups(1);
cacheConfig.setCopyOnRead(TRUE);
cacheConfig.setPartitionLossPolicy(IGNITE);
cacheConfig.setQueryParallelism(2);
cacheConfig.setReadFromBackup(TRUE);
cacheConfig.setRebalanceBatchSize(524288);
cacheConfig.setRebalanceThrottle(100);
cacheConfig.setIndexedTypes(person_key.class, Person.class);
cacheConfig.setOnheapCacheEnabled(FALSE);
cacheConfig.setStatisticsEnabled(TRUE);
cacheManager.createCache("PersonCache", cacheConfig);
*Now, after creating the cache and adding data to it, I was able to see
cache size and I am able to retrieve data from my cache using the key.
However, my SQL query is not returning any data. Upon checking the cache
metadata, I found that indexes (both individual and group) were not created
correctly. The metadata looks as follows -*
{
"cacheName": "PersonCache",
"types": [
"Person"
],
"keyClasses": {
"person_key": "java.lang.Object"
},
"valClasses": {
"Person": "java.lang.Object"
},
"fields": {
"Person": {
"name": "java.lang.String",
"id": "java.lang.String",
"country": "java.lang.String",
"department": "java.lang.String",
"stateCode": "java.lang.Integer",
"activityStatus": "java.lang.Integer",
}
},
"indexes": {
"Person": [
{
"name": "PERSON_NAME_IDX",
"fields": [
"NAME"
],
"descendings": [],
"unique": false
}
]
}
}
Can someone help me understand why I am not able to retrieve data using SQL
query and why indexes have not been created appropriately?
Thanks!
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache Indexes not getting created Ignite v2.1
Posted by iostream <si...@gmail.com>.
Hi, any update on this?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache Indexes not getting created Ignite v2.1
Posted by iostream <si...@gmail.com>.
Hi,
I have marked all my fields with @QuerySqlField annotation because I want to
expose all my fields to SQL Query. I do not want to create an index on
"name".
I use the same setup across all my environments. In my lower environments, I
am able to retrieve data using both SQL query on DBeaver and SQLFieldsQuery
in my Java Application as follows -
IgniteCache<person_key, Person> cache = Ignition.ignite()
.cache("PersonCache");
SqlFieldsQuery query = new SqlFieldsQuery("SELECT * from
"PersonCache".Person where name = ?")
.setArgs("ABC");
In my PROD env, SQL query on DBeaver and SQLFieldsQuery are not returning
any data.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache Indexes not getting created Ignite v2.1
Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,
You mark field "name" with @QueryTextField and it can be used for TextQuery
only.
Looks like a bug that index type is missed in metatada. I'll check if it is
so and fill a ticket.
Field "name" should be annotated with @QuerySqlField(index = true) to allow
SQL layer use this field in SQL query and build and use index on this field.
On Fri, Sep 29, 2017 at 11:47 AM, iostream <si...@gmail.com> wrote:
> *I get metadata using REST API -*
>
> http://localhost:8080/ignite?cmd=metadata
>
> *SQL Query -*
>
> Select * from "PersonCache".Person where name = "ABC";
>
> As I already mentioned, I am able to retrieve records using Key, but SQL
> query is not able to get any data.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
--
Best regards,
Andrey V. Mashenkov
Re: Cache Indexes not getting created Ignite v2.1
Posted by iostream <si...@gmail.com>.
*I get metadata using REST API -*
http://localhost:8080/ignite?cmd=metadata
*SQL Query -*
Select * from "PersonCache".Person where name = "ABC";
As I already mentioned, I am able to retrieve records using Key, but SQL
query is not able to get any data.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Cache Indexes not getting created Ignite v2.1
Posted by Nikolai Tikhonov <nt...@apache.org>.
Hello,
I started grid with your configuration and see that all indexes were
properly created. Can you share your SQL query?
BTW how you get the metadata? I recommend use for this H2 debug console.
How use it, you can read there:
https://apacheignite.readme.io/docs#using-h2-debug-console
On Thu, Sep 28, 2017 at 10:26 AM, iostream <si...@gmail.com> wrote:
> *Hi,
>
> I have a setup with 20 ignite cache servers (v2.1). I create my cache using
> a client, steps are as follows -
>
> 1. Client connects to the ignite cluster during startup.
> 2. During startup, client checks if my cache is already created (cache name
> - "Person")
> 3. If cache is already created, client does nothing. If cache is not
> already
> created, the client creates the cache.*
>
> *My Cache value object looks like this -*
>
> public class Person implements Serializable {
>
> @QuerySqlField(index = true, orderedGroups = {
> @QuerySqlField.Group(name = "personGroup", order =
> 3, descending = true)
> })
> @QueryTextField
> private String name;
> @QuerySqlField(index = true, orderedGroups = {
> @QuerySqlField.Group(name = "personGroup", order =
> 4, descending = true)
> })
> private String id;
> @QuerySqlField(index = true, orderedGroups = {
> @QuerySqlField.Group(name = "personGroup", order =
> 0, descending = false)
> })
> private String country;
> @QuerySqlField(index = true, orderedGroups = {
> @QuerySqlField.Group(name = "personGroup", order =
> 2, descending = false)
> })
> private String department;
> @QuerySqlField(index = true, orderedGroups = {
> @QuerySqlField.Group(name = "personGroup", order =
> 1, descending = false)
> })
> private Integer stateCode;
> @QuerySqlField
> private Integer activityStatus;
>
> }
>
> *As can be seen, I have created a group index - personGroup.
>
> The cache creation code in the client looks as follows -*
>
> if (cacheManager.getCache("PersonCache") == null) {
> CacheConfiguration<person_key, Person> cacheConfig
> = new
> CacheConfiguration<>();
> cacheConfig.setAtomicityMode(TRANSACTIONAL);
> cacheConfig.setCacheMode(PARTITIONED);
> cacheConfig.setBackups(1);
> cacheConfig.setCopyOnRead(TRUE);
> cacheConfig.setPartitionLossPolicy(IGNITE);
> cacheConfig.setQueryParallelism(2);
> cacheConfig.setReadFromBackup(TRUE);
> cacheConfig.setRebalanceBatchSize(524288);
> cacheConfig.setRebalanceThrottle(100);
> cacheConfig.setIndexedTypes(person_key.class, Person.class);
> cacheConfig.setOnheapCacheEnabled(FALSE);
> cacheConfig.setStatisticsEnabled(TRUE);
> cacheManager.createCache("PersonCache", cacheConfig);
>
> *Now, after creating the cache and adding data to it, I was able to see
> cache size and I am able to retrieve data from my cache using the key.
> However, my SQL query is not returning any data. Upon checking the cache
> metadata, I found that indexes (both individual and group) were not created
> correctly. The metadata looks as follows -*
>
> {
> "cacheName": "PersonCache",
> "types": [
> "Person"
> ],
> "keyClasses": {
> "person_key": "java.lang.Object"
> },
> "valClasses": {
> "Person": "java.lang.Object"
> },
> "fields": {
> "Person": {
> "name": "java.lang.String",
> "id": "java.lang.String",
> "country": "java.lang.String",
> "department": "java.lang.String",
> "stateCode": "java.lang.Integer",
> "activityStatus": "java.lang.Integer",
> }
> },
> "indexes": {
> "Person": [
> {
> "name": "PERSON_NAME_IDX",
> "fields": [
> "NAME"
> ],
> "descendings": [],
> "unique": false
> }
> ]
> }
> }
>
> Can someone help me understand why I am not able to retrieve data using SQL
> query and why indexes have not been created appropriately?
>
> Thanks!
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>