use of org.apache.ignite.yardstick.cache.model.Person in project ignite by apache.
the class IgniteSqlQueryPutSeparatedBenchmark method test.
/**
* {@inheritDoc}
*/
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
if (cfg.memberId() % 2 == 0) {
double salary = rnd.nextDouble() * args.range() * 1000;
double maxSalary = salary + 1000;
Collection<Cache.Entry<Integer, Object>> entries = executeQuery(salary, maxSalary);
for (Cache.Entry<Integer, Object> entry : entries) {
Person p = (Person) entry.getValue();
if (p.getSalary() < salary || p.getSalary() > maxSalary)
throw new Exception("Invalid person retrieved [min=" + salary + ", max=" + maxSalary + ", person=" + p + ']');
}
} else {
IgniteCache<Integer, Object> cache = cacheForOperation(true);
int i = rnd.nextInt(args.range());
cache.put(i, new Person(i, "firstName" + i, "lastName" + i, i * 1000));
}
return true;
}
use of org.apache.ignite.yardstick.cache.model.Person in project ignite by apache.
the class IgniteSqlUpdateFilteredBenchmark method test.
/**
* {@inheritDoc}
*/
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
if (rnd.nextBoolean()) {
double salary = rnd.nextDouble() * args.range() * 1000;
double maxSalary = salary + 1000;
Long res = (Long) cache().query(new SqlFieldsQuery("update Person set salary = (salary - ?1 + ?2) / 2 " + "where salary >= ?1 and salary <= ?2").setArgs(salary, maxSalary)).getAll().get(0).get(0);
updItemsCnt.getAndAdd(res);
updCnt.getAndIncrement();
} else {
int i = rnd.nextInt(args.range());
cache.put(i, new Person(i, "firstName" + i, "lastName" + i, i * 1000));
putCnt.getAndIncrement();
}
return true;
}
use of org.apache.ignite.yardstick.cache.model.Person in project ignite by apache.
the class IgniteSqlQueryPutBenchmark method test.
/**
* {@inheritDoc}
*/
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
IgniteCache<Integer, Object> cache = cacheForOperation(true);
if (rnd.nextBoolean()) {
double salary = rnd.nextDouble() * args.range() * 1000;
double maxSalary = salary + 1000;
Collection<Cache.Entry<Integer, Object>> entries = executeQuery(salary, maxSalary);
for (Cache.Entry<Integer, Object> entry : entries) {
Person p = (Person) entry.getValue();
if (p.getSalary() < salary || p.getSalary() > maxSalary)
throw new Exception("Invalid person retrieved [min=" + salary + ", max=" + maxSalary + ", person=" + p + ']');
}
qryCnt.getAndIncrement();
} else {
int i = rnd.nextInt(args.range());
cache.put(i, new Person(i, "firstName" + i, "lastName" + i, i * 1000));
putCnt.getAndIncrement();
}
return true;
}
use of org.apache.ignite.yardstick.cache.model.Person in project ignite by apache.
the class IgniteSqlDeleteFilteredBenchmark method test.
/**
* {@inheritDoc}
*/
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
if (rnd.nextBoolean()) {
double salary = rnd.nextDouble() * args.range() * 1000;
double maxSalary = salary + 1000;
Long res = (Long) cache().query(new SqlFieldsQuery("delete from Person where salary >= ? and salary <= ?").setArgs(salary, maxSalary)).getAll().get(0).get(0);
delItemsCnt.getAndAdd(res);
delCnt.getAndIncrement();
} else {
int i = rnd.nextInt(args.range());
cache.put(i, new Person(i, "firstName" + i, "lastName" + i, i * 1000));
putCnt.getAndIncrement();
}
return true;
}
Aggregations