Reputation: 31
Is there a count query in GridGain?
GridCacheQuery<Map.Entry<Long, Person>> qry =
queries.createSqlQuery(Person.class, "select count() from Person where street = ?");
int count = qry.execute("streetname").get();
Upvotes: 0
Views: 105
Reputation: 2292
Try SQL fields query which can select specific columns instead of the whole class:
GridCacheQuery<List<?>> qry = queries.createSqlFieldsQuery(
"select count() from Person where street = ?");
Collection<List<?>> rows = qry.execute("streetname").get();
List<?> firstRow = rows.get(0);
int count = (Integer)firstRow.get(0);
Upvotes: 1