use of org.apache.ignite.cache.query.SqlQuery in project ignite by apache.
the class IgniteSqlQueryPutBenchmark 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 IgniteRepositoryQuery method prepareQuery.
/**
* @param prmtrs Prmtrs.
* @return prepared query for execution
*/
@NotNull
private Query prepareQuery(Object[] prmtrs) {
Object[] parameters = prmtrs;
String sql = qry.sql();
Query query;
switch(qry.options()) {
case SORTING:
sql = IgniteQueryGenerator.addSorting(new StringBuilder(sql), (Sort) parameters[parameters.length - 1]).toString();
parameters = Arrays.copyOfRange(parameters, 0, parameters.length - 1);
break;
case PAGINATION:
sql = IgniteQueryGenerator.addPaging(new StringBuilder(sql), (Pageable) parameters[parameters.length - 1]).toString();
parameters = Arrays.copyOfRange(parameters, 0, parameters.length - 1);
break;
}
if (qry.isFieldQuery()) {
SqlFieldsQuery sqlFieldsQry = new SqlFieldsQuery(sql);
sqlFieldsQry.setArgs(parameters);
query = sqlFieldsQry;
} else {
SqlQuery sqlQry = new SqlQuery(type, sql);
sqlQry.setArgs(parameters);
query = sqlQry;
}
return query;
}
Aggregations