Search in sources :

Example 6 with LongIterator

use of jetbrains.exodus.core.dataStructures.hash.LongIterator in project xodus by JetBrains.

the class UpdatableEntityIdSortedSetCachedInstanceIterable method getOrCreateIdCollection.

@NotNull
private OrderedEntityIdCollection getOrCreateIdCollection() {
    OrderedEntityIdCollection collection = this.idCollection;
    if (collection == null) {
        PersistentLongSet.ImmutableSet currentSet = localIds.beginRead();
        final long[] result = new long[currentSet.size()];
        final LongIterator it = currentSet.longIterator();
        int i = 0;
        while (it.hasNext()) {
            result[i++] = it.next();
        }
        collection = EntityIdArrayCachedInstanceIterableFactory.makeIdCollection(entityTypeId, result);
        this.idCollection = collection;
    }
    return collection;
}
Also used : LongIterator(jetbrains.exodus.core.dataStructures.hash.LongIterator) PersistentLongSet(jetbrains.exodus.core.dataStructures.persistent.PersistentLongSet) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with LongIterator

use of jetbrains.exodus.core.dataStructures.hash.LongIterator in project xodus by JetBrains.

the class JMHPersistentLongSetIterationBenchmark method iterate23Tree.

@Benchmark
@Warmup(iterations = 6, time = 1)
@Measurement(iterations = 8, time = 1)
@Fork(5)
public long iterate23Tree() {
    LongIterator iterator = treeSet.beginRead().longIterator();
    long result = 0;
    while (iterator.hasNext()) {
        result += iterator.nextLong();
    }
    return result;
}
Also used : LongIterator(jetbrains.exodus.core.dataStructures.hash.LongIterator)

Example 8 with LongIterator

use of jetbrains.exodus.core.dataStructures.hash.LongIterator in project xodus by JetBrains.

the class JMHPersistentLongSetIterationBenchmark method iterateBitTree.

@Benchmark
@Warmup(iterations = 6, time = 1)
@Measurement(iterations = 8, time = 1)
@Fork(5)
public long iterateBitTree() {
    LongIterator iterator = bitTreeSet.beginRead().longIterator();
    long result = 0;
    while (iterator.hasNext()) {
        result += iterator.nextLong();
    }
    return result;
}
Also used : LongIterator(jetbrains.exodus.core.dataStructures.hash.LongIterator)

Aggregations

LongIterator (jetbrains.exodus.core.dataStructures.hash.LongIterator)8 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 java.io (java.io)1 java.util (java.util)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 BackupStrategy (jetbrains.exodus.backup.BackupStrategy)1 VirtualFileDescriptor (jetbrains.exodus.backup.VirtualFileDescriptor)1 LongArrayList (jetbrains.exodus.core.dataStructures.LongArrayList)1 LongHashMap (jetbrains.exodus.core.dataStructures.hash.LongHashMap)1 LongSet (jetbrains.exodus.core.dataStructures.hash.LongSet)1 ObjectProcedureThrows (jetbrains.exodus.core.dataStructures.hash.ObjectProcedureThrows)1 PersistentLongSet (jetbrains.exodus.core.dataStructures.persistent.PersistentLongSet)1 Job (jetbrains.exodus.core.execution.Job)1 StreamCipherProvider (jetbrains.exodus.crypto.StreamCipherProvider)1 Environment (jetbrains.exodus.env.Environment)1 Transaction (jetbrains.exodus.env.Transaction)1 Block (jetbrains.exodus.io.Block)1 DeferredIO (jetbrains.exodus.util.DeferredIO)1 IOUtil (jetbrains.exodus.util.IOUtil)1