Search in sources :

Example 31 with Random

use of jetbrains.exodus.util.Random in project xodus by JetBrains.

the class StressTests method xd_347_like.

static void xd_347_like(PersistentEntityStoreImpl store, int count) {
    final List<Entity> issues = store.computeInTransaction(txn -> {
        final List<Entity> result = new ArrayList<>();
        for (final Entity issue : txn.getAll("Issue")) {
            result.add(issue);
        }
        while (result.size() < 10000) {
            result.add(txn.newEntity("Issue"));
        }
        return result;
    });
    final Random rnd = new Random(346);
    for (int i = 0; i < count; ++i) {
        store.executeInTransaction(txn -> {
            for (int j = 0; j < 100; ++j) {
                issues.get(rnd.nextInt(issues.size())).setProperty("created", System.currentTimeMillis());
                issues.get(rnd.nextInt(issues.size())).setProperty("updated", System.currentTimeMillis());
            }
        });
        if (i % 10 == 0) {
            logger.info((i * 100 / count) + "%\r");
        }
    }
}
Also used : Random(jetbrains.exodus.util.Random) ArrayList(java.util.ArrayList)

Aggregations

Random (jetbrains.exodus.util.Random)31 Test (org.junit.Test)28 java.util (java.util)2 ArrayList (java.util.ArrayList)2 ObjectProcedure (jetbrains.exodus.core.dataStructures.hash.ObjectProcedure)2 Assert (org.junit.Assert)2 List (java.util.List)1 TreeSet (java.util.TreeSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)1 ByteIterable (jetbrains.exodus.ByteIterable)1 ComparableSet (jetbrains.exodus.bindings.ComparableSet)1 Pair (jetbrains.exodus.core.dataStructures.Pair)1 LongHashMap (jetbrains.exodus.core.dataStructures.hash.LongHashMap)1 LongHashSet (jetbrains.exodus.core.dataStructures.hash.LongHashSet)1 Cursor (jetbrains.exodus.env.Cursor)1 Before (org.junit.Before)1