Search in sources :

Example 1 with Person

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

the class IgniteSqlQueryBenchmark method setUp.

/** {@inheritDoc} */
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);
    println(cfg, "Populating query data...");
    long start = System.nanoTime();
    try (IgniteDataStreamer<Integer, Person> dataLdr = ignite().dataStreamer(cache.getName())) {
        for (int i = 0; i < args.range() && !Thread.currentThread().isInterrupted(); i++) {
            dataLdr.addData(i, new Person(i, "firstName" + i, "lastName" + i, i * 1000));
            if (i % 100000 == 0)
                println(cfg, "Populated persons: " + i);
        }
    }
    println(cfg, "Finished populating query data in " + ((System.nanoTime() - start) / 1_000_000) + " ms.");
}
Also used : Person(org.apache.ignite.yardstick.cache.model.Person)

Example 2 with Person

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

the class IgniteSqlQueryJoinBenchmark method setUp.

/** {@inheritDoc} */
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);
    println(cfg, "Populating query data...");
    long start = System.nanoTime();
    try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cache.getName())) {
        final int orgRange = args.range() / 10;
        // Populate organizations.
        for (int i = 0; i < orgRange && !Thread.currentThread().isInterrupted(); i++) dataLdr.addData(i, new Organization(i, "org" + i));
        dataLdr.flush();
        // Populate persons.
        for (int i = orgRange; i < orgRange + args.range() && !Thread.currentThread().isInterrupted(); i++) {
            Person p = new Person(i, nextRandom(orgRange), "firstName" + i, "lastName" + i, (i - orgRange) * 1000);
            dataLdr.addData(i, p);
            if (i % 100000 == 0)
                println(cfg, "Populated persons: " + i);
        }
    }
    println(cfg, "Finished populating join query data in " + ((System.nanoTime() - start) / 1_000_000) + " ms.");
}
Also used : Organization(org.apache.ignite.yardstick.cache.model.Organization) Person(org.apache.ignite.yardstick.cache.model.Person)

Example 3 with Person

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

the class IgniteSqlQueryBenchmark 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<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 + ']');
    }
    return true;
}
Also used : Person(org.apache.ignite.yardstick.cache.model.Person) Cache(javax.cache.Cache) IgniteCache(org.apache.ignite.IgniteCache)

Example 4 with Person

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

the class IgniteSqlQueryDistributedJoinBenchmark method loadCacheData.

/**
 * {@inheritDoc}
 */
@Override
protected void loadCacheData(String cacheName) {
    try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName)) {
        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();
    }
}
Also used : Organization(org.apache.ignite.yardstick.cache.model.Organization) Person(org.apache.ignite.yardstick.cache.model.Person)

Example 5 with Person

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

the class IgniteSqlQueryJoinBenchmark method loadCacheData.

/**
 * {@inheritDoc}
 */
@Override
protected void loadCacheData(String cacheName) {
    if (args.range() < 100)
        throw new IllegalArgumentException("Invalid range: " + args.range());
    try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName)) {
        final int orgRange = args.range() / 10;
        // Populate organizations.
        for (int i = 0; i < orgRange && !Thread.currentThread().isInterrupted(); i++) dataLdr.addData(i, new Organization(i, "org" + i));
        dataLdr.flush();
        // Populate persons.
        for (int i = orgRange; i < orgRange + args.range() && !Thread.currentThread().isInterrupted(); i++) {
            Person p = new Person(i, nextRandom(orgRange), "firstName" + i, "lastName" + i, (i - orgRange) * 1000);
            dataLdr.addData(i, p);
            if (i % 100000 == 0)
                println(cfg, "Populated persons: " + i);
        }
    }
}
Also used : Organization(org.apache.ignite.yardstick.cache.model.Organization) Person(org.apache.ignite.yardstick.cache.model.Person)

Aggregations

Person (org.apache.ignite.yardstick.cache.model.Person)14 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)5 Organization (org.apache.ignite.yardstick.cache.model.Organization)5 Cache (javax.cache.Cache)4 IgniteCache (org.apache.ignite.IgniteCache)4 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)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