Search in sources :

Example 6 with Person

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;
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Person(org.apache.ignite.yardstick.cache.model.Person) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery)

Example 7 with Person

use of org.apache.ignite.yardstick.cache.model.Person in project ignite by apache.

the class IgniteSqlQueryJoinBenchmark method test.

/** {@inheritDoc} */
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
    double salary = ThreadLocalRandom.current().nextDouble() * args.range() * 1000;
    double maxSalary = salary + 1000;
    Collection<List<?>> lists = executeQueryJoin(salary, maxSalary);
    for (List<?> l : lists) {
        double sal = (Double) l.get(4);
        if (sal < salary || sal > maxSalary) {
            Person p = new Person();
            p.setId((Integer) l.get(0));
            p.setOrganizationId((Integer) l.get(1));
            p.setFirstName((String) l.get(2));
            p.setLastName((String) l.get(3));
            p.setSalary(sal);
            throw new Exception("Invalid person retrieved [min=" + salary + ", max=" + maxSalary + ", person=" + p + ']');
        }
    }
    return true;
}
Also used : List(java.util.List) Person(org.apache.ignite.yardstick.cache.model.Person)

Example 8 with Person

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();
    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;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Person(org.apache.ignite.yardstick.cache.model.Person) Cache(javax.cache.Cache) IgniteCache(org.apache.ignite.IgniteCache)

Example 9 with Person

use of org.apache.ignite.yardstick.cache.model.Person in project ignite by apache.

the class IgniteSqlQueryDistributedJoinBenchmark method setUp.

/** {@inheritDoc} */
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);
    broadcast = broadcastJoin();
    println(cfg, "Populating query data...");
    long start = System.nanoTime();
    range = args.range();
    if (range <= 0)
        throw new IllegalArgumentException();
    try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cache.getName())) {
        for (int orgId = 0; orgId < range; orgId++) {
            dataLdr.addData(orgId, new Organization(orgId, "org" + orgId));
            int personId = range + orgId;
            Person p = new Person(personId, orgId, "firstName" + personId, "lastName" + personId, 1000);
            dataLdr.addData(personId, p);
            if (orgId % 1000 == 0 && Thread.currentThread().isInterrupted())
                return;
        }
        dataLdr.close();
    }
    println(cfg, "Finished populating join query [orgCnt=" + range + ", personCnt=" + range + ", broadcastJoin=" + broadcast + ", time=" + ((System.nanoTime() - start) / 1_000_000) + "ms]");
    executeQueryJoin(0, broadcast, true);
}
Also used : Organization(org.apache.ignite.yardstick.cache.model.Organization) Person(org.apache.ignite.yardstick.cache.model.Person)

Example 10 with Person

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;
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Person(org.apache.ignite.yardstick.cache.model.Person) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery)

Aggregations

Person (org.apache.ignite.yardstick.cache.model.Person)12 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)5 Cache (javax.cache.Cache)4 IgniteCache (org.apache.ignite.IgniteCache)4 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)3 Organization (org.apache.ignite.yardstick.cache.model.Organization)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 List (java.util.List)1 BinaryObject (org.apache.ignite.binary.BinaryObject)1 Identifier (org.apache.ignite.yardstick.cache.load.model.key.Identifier)1 Mark (org.apache.ignite.yardstick.cache.load.model.key.Mark)1 Car (org.apache.ignite.yardstick.cache.load.model.value.Car)1 Truck (org.apache.ignite.yardstick.cache.load.model.value.Truck)1 Account (org.apache.ignite.yardstick.cache.model.Account)1 Person1 (org.apache.ignite.yardstick.cache.model.Person1)1 Person2 (org.apache.ignite.yardstick.cache.model.Person2)1 Person8 (org.apache.ignite.yardstick.cache.model.Person8)1