use of org.apache.ignite.cache.query.SqlQuery in project ignite by apache.
the class IgniteCacheReplicatedQuerySelfTest method testClientOnlyNode.
/**
* @throws Exception If failed.
*/
public void testClientOnlyNode() throws Exception {
try {
Ignite g = startGrid("client");
IgniteCache<Integer, Integer> c = jcache(g, Integer.class, Integer.class);
for (int i = 0; i < 10; i++) c.put(i, i);
// Client cache should be empty.
assertEquals(0, c.localSize());
Collection<Cache.Entry<Integer, Integer>> res = c.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 5 order by _key")).getAll();
assertEquals(5, res.size());
int i = 5;
for (Cache.Entry<Integer, Integer> e : res) {
assertEquals(i, e.getKey().intValue());
assertEquals(i, e.getValue().intValue());
i++;
}
} finally {
stopGrid("client");
}
}
use of org.apache.ignite.cache.query.SqlQuery in project ignite by apache.
the class DynamicIndexAbstractSelfTest method assertSqlCompositeData.
/**
* Assert SQL simple data state.
*
* @param node Node.
* @param sql SQL query.
* @param expSize Expected size.
*/
protected static void assertSqlCompositeData(Ignite node, String sql, int expSize) {
SqlQuery qry = new SqlQuery(typeName(ValueClass.class), sql).setArgs(SQL_ARG_1, SQL_ARG_2);
List<Cache.Entry<BinaryObject, BinaryObject>> res = node.cache(CACHE_NAME).withKeepBinary().query(qry).getAll();
Set<Long> ids = new HashSet<>();
for (Cache.Entry<BinaryObject, BinaryObject> entry : res) {
long id = entry.getKey().field(FIELD_KEY);
long field1 = entry.getValue().field(FIELD_NAME_1_ESCAPED);
long field2 = entry.getValue().field(FIELD_NAME_2_ESCAPED);
assertTrue(field1 >= SQL_ARG_2);
assertEquals(id, field1);
assertEquals(id, field2);
assertTrue(ids.add(id));
}
assertEquals("Size mismatch [exp=" + expSize + ", actual=" + res.size() + ", ids=" + ids + ']', expSize, res.size());
}
use of org.apache.ignite.cache.query.SqlQuery in project ignite by apache.
the class IgniteSqlMergeQueryBenchmark method executeQuery.
/**
* @param minSalary Min salary.
* @param maxSalary Max salary.
* @return Query result.
* @throws Exception If failed.
*/
private Collection<Cache.Entry<Integer, Object>> executeQuery(double minSalary, double maxSalary) throws Exception {
SqlQuery qry = new SqlQuery(Person.class, "salary >= ? and salary <= ?");
qry.setArgs(minSalary, maxSalary);
return cache.query(qry).getAll();
}
use of org.apache.ignite.cache.query.SqlQuery in project ignite by apache.
the class IgniteSqlQueryPutSeparatedBenchmark method executeQuery.
/**
* @param minSalary Min salary.
* @param maxSalary Max salary.
* @return Query result.
* @throws Exception If failed.
*/
private Collection<Cache.Entry<Integer, Object>> executeQuery(double minSalary, double maxSalary) throws Exception {
SqlQuery qry = new SqlQuery(Person.class, "salary >= ? and salary <= ?");
qry.setArgs(minSalary, maxSalary);
return cache.query(qry).getAll();
}
use of org.apache.ignite.cache.query.SqlQuery in project ignite by apache.
the class IgniteSqlQueryBenchmark method executeQuery.
/**
* @param minSalary Min salary.
* @param maxSalary Max salary.
* @return Query result.
* @throws Exception If failed.
*/
private Collection<Cache.Entry<Integer, Object>> executeQuery(double minSalary, double maxSalary) throws Exception {
SqlQuery qry = new SqlQuery(Person.class, "salary >= ? and salary <= ?");
qry.setArgs(minSalary, maxSalary);
return cache.query(qry).getAll();
}
Aggregations