【发布时间】:2021-10-08 12:44:25
【问题描述】:
我正在使用 ignite 缓存并执行以下 sql 查询。
IgniteCache<String, ClassName> cache = ignite.cache(CACHE_NAME);
private static final String sql = "Select timestamp from cache1 where orderId = ? and timestamp <= ? and timestamp >= ? ";
SqlFieldsQuery sqlQ = new SqlFieldsQuery(sql).setArgs(id, t1, t2);
try (QueryCursor<List<?>> cursor = cache.query(sqlQ)) {
for (List<?> row : cursor) {
timestamps.add((Long) row.get(0));
}
现在我想从两个不同的缓存中查询并获取联合。我能够成功编写 SQL 联合操作。
private static final String sqlTwoCaches = "Select timestamp from cache1 union all Select timestamp from cache2 order by timestamp";
我想将两个缓存中的时间戳结果添加到单个数组列表中。我想知道如何使用查询游标?现在有两个缓存,这部分怎么做? (QueryCursor<List<?>> cursor = cache.query(sqlTwoCaches))
或者有没有其他方法可以做到这一点?
【问题讨论】:
标签: java sql union ignite gridgain