Search in sources :

Example 1 with Person1

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

the class IgniteReplaceIndexedValue1Benchmark method test.

/**
 * {@inheritDoc}
 */
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
    ThreadLocalRandom rnd = ThreadLocalRandom.current();
    IgniteCache<Integer, Object> cache = cacheForOperation();
    cache.replace(rnd.nextInt(args.range()), new Person1(rnd.nextInt(args.range())));
    return true;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Person1(org.apache.ignite.yardstick.cache.model.Person1) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom)

Example 2 with Person1

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

the class IgniteSqlUpdateBenchmark method setUp.

/**
 * {@inheritDoc}
 */
@Override
public void setUp(final BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);
    final AtomicInteger i = new AtomicInteger();
    Collection<Thread> setupThreads = new ArrayList<>(cfg.threads());
    for (int j = 0; j < cfg.threads(); j++) {
        Thread t = new Thread() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void run() {
                int k;
                while ((k = i.getAndIncrement()) < args.range()) {
                    cache().put(k, new Person1(k));
                    if (++k % 100000 == 0)
                        BenchmarkUtils.println(cfg, "UPDATE setUp: have successfully put " + k + " items");
                }
            }
        };
        setupThreads.add(t);
        t.start();
    }
    for (Thread t : setupThreads) t.join();
}
Also used : Person1(org.apache.ignite.yardstick.cache.model.Person1) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList)

Example 3 with Person1

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

the class IgnitePutIfAbsentIndexedValue1Benchmark method test.

/**
 * {@inheritDoc}
 */
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
    IgniteCache<Integer, Object> cache = cacheForOperation();
    int key = insCnt.getAndIncrement();
    cache.putIfAbsent(key, new Person1(key));
    return true;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Person1(org.apache.ignite.yardstick.cache.model.Person1)

Example 4 with Person1

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

the class ModelUtil method create.

/**
 * @param c model class
 * @param id object id
 * @return object from model
 */
public static Object create(Class c, int id) {
    Object res;
    switch(c.getSimpleName()) {
        case "Double":
            res = id;
            break;
        case "Identifier":
            res = new Identifier(id, "id " + id);
            break;
        case "Mark":
            res = new Mark(id, UUID.nameUUIDFromBytes(Integer.toString(id).getBytes()));
            break;
        case "Integer":
            res = id;
            break;
        case "UUID":
            res = UUID.nameUUIDFromBytes(Integer.toString(id).getBytes());
            break;
        case "Car":
            int colorCnt = Color.values().length;
            res = new Car(id, "Mark " + id, id / 2.123 * 100, Color.values()[id % colorCnt]);
            break;
        case "Truck":
            int colors = Color.values().length;
            res = new Truck(id, "Mark " + id, id / 2.123 * 100, Color.values()[id % colors], id / 4.123 * 100);
            break;
        case "Person":
            res = new Person(id, id + 1, "First Name " + id, "Last Name " + id, id / 2.123 * 100);
            break;
        case "Organization":
            res = new Organization(id, "Organization " + id);
            break;
        case "Account":
            res = new Account(id);
            break;
        case "Person1":
            res = new Person1(id);
            break;
        case "Person2":
            res = new Person2(id);
            break;
        case "Person8":
            res = new Person8(id);
            break;
        case "String":
            res = String.valueOf(id);
            break;
        default:
            throw new IllegalArgumentException("Unsupported class: " + c.getSimpleName());
    }
    return res;
}
Also used : Account(org.apache.ignite.yardstick.cache.model.Account) Organization(org.apache.ignite.yardstick.cache.model.Organization) Mark(org.apache.ignite.yardstick.cache.load.model.key.Mark) Truck(org.apache.ignite.yardstick.cache.load.model.value.Truck) Person8(org.apache.ignite.yardstick.cache.model.Person8) Identifier(org.apache.ignite.yardstick.cache.load.model.key.Identifier) Person1(org.apache.ignite.yardstick.cache.model.Person1) Car(org.apache.ignite.yardstick.cache.load.model.value.Car) Person2(org.apache.ignite.yardstick.cache.model.Person2) Person(org.apache.ignite.yardstick.cache.model.Person)

Example 5 with Person1

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

the class IgniteReplaceIndexedValue1Benchmark method setUp.

/**
 * {@inheritDoc}
 */
@Override
public void setUp(final BenchmarkConfiguration cfg) throws Exception {
    super.setUp(cfg);
    final AtomicInteger i = new AtomicInteger();
    Collection<Thread> setupThreads = new ArrayList<>(cfg.threads());
    for (int j = 0; j < cfg.threads(); j++) {
        Thread t = new Thread() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void run() {
                int k;
                while ((k = i.getAndIncrement()) < args.range()) {
                    cache().put(k, new Person1(k));
                    if (++k % 100000 == 0)
                        BenchmarkUtils.println(cfg, "REPLACE setUp: have successfully put " + k + " items");
                }
            }
        };
        setupThreads.add(t);
        t.start();
    }
    for (Thread t : setupThreads) t.join();
}
Also used : Person1(org.apache.ignite.yardstick.cache.model.Person1) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList)

Aggregations

Person1 (org.apache.ignite.yardstick.cache.model.Person1)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 ArrayList (java.util.ArrayList)3 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)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 Organization (org.apache.ignite.yardstick.cache.model.Organization)1 Person (org.apache.ignite.yardstick.cache.model.Person)1 Person2 (org.apache.ignite.yardstick.cache.model.Person2)1 Person8 (org.apache.ignite.yardstick.cache.model.Person8)1