在GridGain中计算查询

时间:2014-08-01 20:00:46

标签: gridgain

GridGain中是否有计数查询?

GridCacheQuery<Map.Entry<Long, Person>> qry =
    queries.createSqlQuery(Person.class, "select count() from Person where street = ?");
int count = qry.execute("streetname").get();

1 个答案:

答案 0 :(得分:1)

尝试SQL字段查询,可以选择特定列而不是整个类:

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);