Search in sources :

Example 11 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project geode by apache.

the class DiskInitFile method saveCrfIds.

private void saveCrfIds() {
    for (LongIterator i = this.crfIds.iterator(); i.hasNext(); ) {
        writeIFRecord(IFREC_CRF_CREATE, i.next());
        this.ifLiveRecordCount++;
        this.ifTotalRecordCount++;
    }
}
Also used : LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Example 12 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project Nukkit by Nukkit.

the class Player method orderChunks.

protected boolean orderChunks() {
    if (!this.connected) {
        return false;
    }
    Timings.playerChunkOrderTimer.startTiming();
    this.nextChunkOrderRun = 200;
    loadQueue.clear();
    Long2ObjectOpenHashMap<Boolean> lastChunk = new Long2ObjectOpenHashMap<>(this.usedChunks);
    int centerX = (int) this.x >> 4;
    int centerZ = (int) this.z >> 4;
    int radius = spawned ? this.chunkRadius : (int) Math.ceil(Math.sqrt(spawnThreshold));
    int radiusSqr = radius * radius;
    long index;
    for (int x = 0; x <= radius; x++) {
        int xx = x * x;
        for (int z = 0; z <= x; z++) {
            int distanceSqr = xx + z * z;
            if (distanceSqr > radiusSqr)
                continue;
            /* Top right quadrant */
            if (this.usedChunks.get(index = Level.chunkHash(centerX + x, centerZ + z)) != Boolean.TRUE) {
                this.loadQueue.put(index, Boolean.TRUE);
            }
            lastChunk.remove(index);
            /* Top left quadrant */
            if (this.usedChunks.get(index = Level.chunkHash(centerX - x - 1, centerZ + z)) != Boolean.TRUE) {
                this.loadQueue.put(index, Boolean.TRUE);
            }
            lastChunk.remove(index);
            /* Bottom right quadrant */
            if (this.usedChunks.get(index = Level.chunkHash(centerX + x, centerZ - z - 1)) != Boolean.TRUE) {
                this.loadQueue.put(index, Boolean.TRUE);
            }
            lastChunk.remove(index);
            /* Bottom left quadrant */
            if (this.usedChunks.get(index = Level.chunkHash(centerX - x - 1, centerZ - z - 1)) != Boolean.TRUE) {
                this.loadQueue.put(index, Boolean.TRUE);
            }
            lastChunk.remove(index);
            if (x != z) {
                /* Top right quadrant mirror */
                if (this.usedChunks.get(index = Level.chunkHash(centerX + z, centerZ + x)) != Boolean.TRUE) {
                    this.loadQueue.put(index, Boolean.TRUE);
                }
                lastChunk.remove(index);
                /* Top left quadrant mirror */
                if (this.usedChunks.get(index = Level.chunkHash(centerX - z - 1, centerZ + x)) != Boolean.TRUE) {
                    this.loadQueue.put(index, Boolean.TRUE);
                }
                lastChunk.remove(index);
                /* Bottom right quadrant mirror */
                if (this.usedChunks.get(index = Level.chunkHash(centerX + z, centerZ - x - 1)) != Boolean.TRUE) {
                    this.loadQueue.put(index, Boolean.TRUE);
                }
                lastChunk.remove(index);
                /* Bottom left quadrant mirror */
                if (this.usedChunks.get(index = Level.chunkHash(centerX - z - 1, centerZ - x - 1)) != Boolean.TRUE) {
                    this.loadQueue.put(index, Boolean.TRUE);
                }
                lastChunk.remove(index);
            }
        }
    }
    LongIterator keys = lastChunk.keySet().iterator();
    while (keys.hasNext()) {
        index = keys.nextLong();
        this.unloadChunk(Level.getHashX(index), Level.getHashZ(index));
    }
    Timings.playerChunkOrderTimer.stopTiming();
    return true;
}
Also used : Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Example 13 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project presto by prestodb.

the class KHyperLogLog method jaccardIndex.

public static double jaccardIndex(KHyperLogLog a, KHyperLogLog b) {
    int sizeOfSmallerSet = Math.min(a.minhash.size(), b.minhash.size());
    LongSortedSet minUnion = new LongRBTreeSet(a.minhash.keySet());
    minUnion.addAll(b.minhash.keySet());
    int intersection = 0;
    int i = 0;
    LongIterator iterator = minUnion.iterator();
    while (iterator.hasNext()) {
        long key = iterator.nextLong();
        if (a.minhash.containsKey(key) && b.minhash.containsKey(key)) {
            intersection++;
        }
        i++;
        if (i >= sizeOfSmallerSet) {
            break;
        }
    }
    return intersection / (double) sizeOfSmallerSet;
}
Also used : LongRBTreeSet(it.unimi.dsi.fastutil.longs.LongRBTreeSet) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator) LongSortedSet(it.unimi.dsi.fastutil.longs.LongSortedSet)

Example 14 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project symja_android_library by axkr.

the class InstantColumn method removeMissing.

@Override
public InstantColumn removeMissing() {
    InstantColumn noMissing = emptyCopy();
    LongIterator iterator = longIterator();
    while (iterator.hasNext()) {
        long i = iterator.nextLong();
        if (!valueIsMissing(i)) {
            noMissing.appendInternal(i);
        }
    }
    return noMissing;
}
Also used : LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Example 15 with LongIterator

use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.

the class IntLongVector method max.

public long max() {
    IntLongVectorStorage idstorage = (IntLongVectorStorage) storage;
    if (idstorage.size() == 0)
        return 0;
    long maxval = Long.MIN_VALUE;
    if (idstorage.isSparse()) {
        LongIterator iter = idstorage.valueIterator();
        while (iter.hasNext()) {
            long val = iter.nextLong();
            if (val > maxval) {
                maxval = val;
            }
        }
    } else {
        for (long val : idstorage.getValues()) {
            if (val > maxval) {
                maxval = val;
            }
        }
    }
    return maxval;
}
Also used : IntLongVectorStorage(com.tencent.angel.ml.math2.storage.IntLongVectorStorage) LongIterator(it.unimi.dsi.fastutil.longs.LongIterator)

Aggregations

LongIterator (it.unimi.dsi.fastutil.longs.LongIterator)20 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)5 LongLongVectorStorage (com.tencent.angel.ml.math2.storage.LongLongVectorStorage)5 LongVectorStorage (com.tencent.angel.ml.math2.storage.LongVectorStorage)2 HyperLogLog (com.facebook.airlift.stats.cardinality.HyperLogLog)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1 LongRBTreeSet (it.unimi.dsi.fastutil.longs.LongRBTreeSet)1 LongSortedSet (it.unimi.dsi.fastutil.longs.LongSortedSet)1 ChunkPos (net.minecraft.world.level.ChunkPos)1 ForcedChunksSavedData (net.minecraft.world.level.ForcedChunksSavedData)1