[JBoss JIRA] (ISPN-2826) CacheQuery.list() returns List<Object>, which is hard to cast
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2826?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero edited comment on ISPN-2826 at 2/15/13 4:05 PM:
----------------------------------------------------------------
Hi Ray, thanks for the idea, but without large changes in functionality that can't be fixed: technically your query could target multiple types which have no types in common:
{code}
CacheQuery query = searchManager.getQuery(luceneQuery, Book.class, Airplane.class, User.class);
{code}
So even if we used extended generics all over, there would be mixed results. Also, one can not infer the type from the original Cache<?,?> generic values as, even when knowing it's a Cache<String,Book> one might want to use projections to extract the titles in one-shot.
I agree we should improve the API, but we'd likely need additional methods.
was (Author: sannegrinovero):
Hi Ray, thanks for the idea, but without large changes in functionality that can't be fixed: technically your query could target multiple types which have no types in common:
{code}
CacheQuery query = searchManager.getQuery(luceneQuery, Book.class, Airplanes.class, Users.class);
{code}
So even if we used extended generics all over, there would be mixed results. Also, one can not infer the type from the original Cache<?,?> generic values as, even when knowing it's a Cache<String,Book> one might want to use projections to extract the titles in one-shot.
I agree we should improve the API, but we'd likely need additional methods.
> CacheQuery.list() returns List<Object>, which is hard to cast
> -------------------------------------------------------------
>
> Key: ISPN-2826
> URL: https://issues.jboss.org/browse/ISPN-2826
> Project: Infinispan
> Issue Type: Feature Request
> Components: Querying
> Reporter: Ray Tsang
> Assignee: Sanne Grinovero
>
> In example for Books in https://docs.jboss.org/author/display/ISPN/Querying+Infinispan
> ~~ snip snip ~~
> CacheQuery query = searchManager.getQuery(luceneQuery, Book.class);
> // and there are your results!
> List<Book> objectList = query.list();
> ~~ snip snip ~~
> This doesn't actually work. CacheQuery.list() returns List<Object>
> Thus, you will need to cast: List<Book> books = (List<Book>) cq.list();
> But this wouldn't work... Instead you'll end up doing: List<Book> books = (List<Book>)(List<?>) cq.list();
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month
[JBoss JIRA] (ISPN-2821) Correct Query Sort tests
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero updated ISPN-2821:
----------------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request: https://github.com/infinispan/infinispan/pull/1667
> Correct Query Sort tests
> ------------------------
>
> Key: ISPN-2821
> URL: https://issues.jboss.org/browse/ISPN-2821
> Project: Infinispan
> Issue Type: Task
> Components: Querying
> Reporter: Anna Manukyan
> Assignee: Sanne Grinovero
> Priority: Minor
> Fix For: 5.3.0.Alpha1
>
> Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow.
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects.
> Then the age is changed for them (set to other values), and query is run using sort by age.
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order.
> The code is:
> {code}
> Person person2 = new Person();
> person2.setAge(30);
> //some other setters
> Person person3 = new Person();
> person3.setAge(25);
> // some other setters
> cache.put("key1", person2);
> cache.put("key2", person3);
> person2.setAge(35);
> person3.setAge(12);
> Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
> queryParser = createQueryParser("name");
> Query luceneQuery = queryParser.parse("Goat");
> CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
> cacheQuery.sort(sort);
> List<Object> found = cacheQuery.list();
> assert found.size() == 2;
> assert found.get(0).equals(person2); //<------ The first element should be the one with higher age, but in reality in the first place it is person3
> assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine.
> {code}
> Person person2 = new Person();
> person2.setAge(25);
> //some other setters
> Person person3 = new Person();
> person3.setAge(30);
> // some other setters
> //............ the rest of the code
> {code}
> You can find attached the test file itself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month
[JBoss JIRA] (ISPN-2821) Correct Query Sort tests
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero updated ISPN-2821:
----------------------------------
Fix Version/s: 5.3.0.Alpha1
> Correct Query Sort tests
> ------------------------
>
> Key: ISPN-2821
> URL: https://issues.jboss.org/browse/ISPN-2821
> Project: Infinispan
> Issue Type: Task
> Components: Querying
> Reporter: Anna Manukyan
> Assignee: Sanne Grinovero
> Priority: Minor
> Fix For: 5.3.0.Alpha1
>
> Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow.
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects.
> Then the age is changed for them (set to other values), and query is run using sort by age.
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order.
> The code is:
> {code}
> Person person2 = new Person();
> person2.setAge(30);
> //some other setters
> Person person3 = new Person();
> person3.setAge(25);
> // some other setters
> cache.put("key1", person2);
> cache.put("key2", person3);
> person2.setAge(35);
> person3.setAge(12);
> Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
> queryParser = createQueryParser("name");
> Query luceneQuery = queryParser.parse("Goat");
> CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
> cacheQuery.sort(sort);
> List<Object> found = cacheQuery.list();
> assert found.size() == 2;
> assert found.get(0).equals(person2); //<------ The first element should be the one with higher age, but in reality in the first place it is person3
> assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine.
> {code}
> Person person2 = new Person();
> person2.setAge(25);
> //some other setters
> Person person3 = new Person();
> person3.setAge(30);
> // some other setters
> //............ the rest of the code
> {code}
> You can find attached the test file itself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month
[JBoss JIRA] (ISPN-2821) Correct Query Sort tests
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero commented on ISPN-2821:
---------------------------------------
Hi Anna,
the original test was misleading: no put operations where performed so changing the Age had no effect on the data stored in the grid. I'm improving it and will send a pull request soon. Thanks!
> Correct Query Sort tests
> ------------------------
>
> Key: ISPN-2821
> URL: https://issues.jboss.org/browse/ISPN-2821
> Project: Infinispan
> Issue Type: Bug
> Components: Querying
> Affects Versions: 5.2.0.Final, 5.2.1.Final
> Reporter: Anna Manukyan
> Assignee: Sanne Grinovero
> Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow.
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects.
> Then the age is changed for them (set to other values), and query is run using sort by age.
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order.
> The code is:
> {code}
> Person person2 = new Person();
> person2.setAge(30);
> //some other setters
> Person person3 = new Person();
> person3.setAge(25);
> // some other setters
> cache.put("key1", person2);
> cache.put("key2", person3);
> person2.setAge(35);
> person3.setAge(12);
> Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
> queryParser = createQueryParser("name");
> Query luceneQuery = queryParser.parse("Goat");
> CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
> cacheQuery.sort(sort);
> List<Object> found = cacheQuery.list();
> assert found.size() == 2;
> assert found.get(0).equals(person2); //<------ The first element should be the one with higher age, but in reality in the first place it is person3
> assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine.
> {code}
> Person person2 = new Person();
> person2.setAge(25);
> //some other setters
> Person person3 = new Person();
> person3.setAge(30);
> // some other setters
> //............ the rest of the code
> {code}
> You can find attached the test file itself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month
[JBoss JIRA] (ISPN-2821) Correct Query Sort tests
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero updated ISPN-2821:
----------------------------------
Issue Type: Task (was: Bug)
> Correct Query Sort tests
> ------------------------
>
> Key: ISPN-2821
> URL: https://issues.jboss.org/browse/ISPN-2821
> Project: Infinispan
> Issue Type: Task
> Components: Querying
> Affects Versions: 5.2.0.Final, 5.2.1.Final
> Reporter: Anna Manukyan
> Assignee: Sanne Grinovero
> Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow.
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects.
> Then the age is changed for them (set to other values), and query is run using sort by age.
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order.
> The code is:
> {code}
> Person person2 = new Person();
> person2.setAge(30);
> //some other setters
> Person person3 = new Person();
> person3.setAge(25);
> // some other setters
> cache.put("key1", person2);
> cache.put("key2", person3);
> person2.setAge(35);
> person3.setAge(12);
> Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
> queryParser = createQueryParser("name");
> Query luceneQuery = queryParser.parse("Goat");
> CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
> cacheQuery.sort(sort);
> List<Object> found = cacheQuery.list();
> assert found.size() == 2;
> assert found.get(0).equals(person2); //<------ The first element should be the one with higher age, but in reality in the first place it is person3
> assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine.
> {code}
> Person person2 = new Person();
> person2.setAge(25);
> //some other setters
> Person person3 = new Person();
> person3.setAge(30);
> // some other setters
> //............ the rest of the code
> {code}
> You can find attached the test file itself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month
[JBoss JIRA] (ISPN-2821) Correct Query Sort tests
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero updated ISPN-2821:
----------------------------------
Priority: Minor (was: Major)
> Correct Query Sort tests
> ------------------------
>
> Key: ISPN-2821
> URL: https://issues.jboss.org/browse/ISPN-2821
> Project: Infinispan
> Issue Type: Task
> Components: Querying
> Affects Versions: 5.2.0.Final, 5.2.1.Final
> Reporter: Anna Manukyan
> Assignee: Sanne Grinovero
> Priority: Minor
> Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow.
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects.
> Then the age is changed for them (set to other values), and query is run using sort by age.
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order.
> The code is:
> {code}
> Person person2 = new Person();
> person2.setAge(30);
> //some other setters
> Person person3 = new Person();
> person3.setAge(25);
> // some other setters
> cache.put("key1", person2);
> cache.put("key2", person3);
> person2.setAge(35);
> person3.setAge(12);
> Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
> queryParser = createQueryParser("name");
> Query luceneQuery = queryParser.parse("Goat");
> CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
> cacheQuery.sort(sort);
> List<Object> found = cacheQuery.list();
> assert found.size() == 2;
> assert found.get(0).equals(person2); //<------ The first element should be the one with higher age, but in reality in the first place it is person3
> assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine.
> {code}
> Person person2 = new Person();
> person2.setAge(25);
> //some other setters
> Person person3 = new Person();
> person3.setAge(30);
> // some other setters
> //............ the rest of the code
> {code}
> You can find attached the test file itself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month
[JBoss JIRA] (ISPN-2821) Correct Query Sort tests
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero updated ISPN-2821:
----------------------------------
Affects Version/s: (was: 5.2.0.Final)
(was: 5.2.1.Final)
> Correct Query Sort tests
> ------------------------
>
> Key: ISPN-2821
> URL: https://issues.jboss.org/browse/ISPN-2821
> Project: Infinispan
> Issue Type: Task
> Components: Querying
> Reporter: Anna Manukyan
> Assignee: Sanne Grinovero
> Priority: Minor
> Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow.
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects.
> Then the age is changed for them (set to other values), and query is run using sort by age.
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order.
> The code is:
> {code}
> Person person2 = new Person();
> person2.setAge(30);
> //some other setters
> Person person3 = new Person();
> person3.setAge(25);
> // some other setters
> cache.put("key1", person2);
> cache.put("key2", person3);
> person2.setAge(35);
> person3.setAge(12);
> Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
> queryParser = createQueryParser("name");
> Query luceneQuery = queryParser.parse("Goat");
> CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
> cacheQuery.sort(sort);
> List<Object> found = cacheQuery.list();
> assert found.size() == 2;
> assert found.get(0).equals(person2); //<------ The first element should be the one with higher age, but in reality in the first place it is person3
> assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine.
> {code}
> Person person2 = new Person();
> person2.setAge(25);
> //some other setters
> Person person3 = new Person();
> person3.setAge(30);
> // some other setters
> //............ the rest of the code
> {code}
> You can find attached the test file itself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month
[JBoss JIRA] (ISPN-2821) Correct Query Sort tests
by Sanne Grinovero (JIRA)
[ https://issues.jboss.org/browse/ISPN-2821?page=com.atlassian.jira.plugin.... ]
Sanne Grinovero updated ISPN-2821:
----------------------------------
Summary: Correct Query Sort tests (was: CacheQuery sort() sorts entries in reverse order when cache values are updated )
> Correct Query Sort tests
> ------------------------
>
> Key: ISPN-2821
> URL: https://issues.jboss.org/browse/ISPN-2821
> Project: Infinispan
> Issue Type: Bug
> Components: Querying
> Affects Versions: 5.2.0.Final, 5.2.1.Final
> Reporter: Anna Manukyan
> Assignee: Sanne Grinovero
> Attachments: LocalCacheTest.java
>
>
> While test development for the Query module, I've noticed some strange behaviour, which I couldn't explain anyhow.
> The case is the following:
> 3 new objects type of Person are created and put to the cache. The age parameter is set for all these objects.
> Then the age is changed for them (set to other values), and query is run using sort by age.
> The thing is that even though the sort is descending by default for integers, but the returned result list is sorted in ascending order.
> The code is:
> {code}
> Person person2 = new Person();
> person2.setAge(30);
> //some other setters
> Person person3 = new Person();
> person3.setAge(25);
> // some other setters
> cache.put("key1", person2);
> cache.put("key2", person3);
> person2.setAge(35);
> person3.setAge(12);
> Sort sort = new Sort( new SortField("age", SortField.STRING)); //<--- The same happens for SortField.INT
> queryParser = createQueryParser("name");
> Query luceneQuery = queryParser.parse("Goat");
> CacheQuery cacheQuery = Search.getSearchManager(cache).getQuery(luceneQuery);
> cacheQuery.sort(sort);
> List<Object> found = cacheQuery.list();
> assert found.size() == 2;
> assert found.get(0).equals(person2); //<------ The first element should be the one with higher age, but in reality in the first place it is person3
> assert found.get(1).equals(person3);
> {code}
> By the way, if initially you'll set the values in other order, then the test passes - the sorting works fine.
> {code}
> Person person2 = new Person();
> person2.setAge(25);
> //some other setters
> Person person3 = new Person();
> person3.setAge(30);
> // some other setters
> //............ the rest of the code
> {code}
> You can find attached the test file itself.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 1 month