use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class SparseLongKeyDoubleVector method resize.
private void resize(int newSize) {
if (indexToValueMap.size() < newSize) {
Long2DoubleOpenHashMap oldMap = indexToValueMap;
indexToValueMap = new Long2DoubleOpenHashMap(newSize);
indexToValueMap.putAll(oldMap);
}
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class ServerSparseDoubleLongKeyRow method readFrom.
@Override
public void readFrom(DataInputStream input) throws IOException {
try {
lock.writeLock().lock();
super.readFrom(input);
int nnz = input.readInt();
if (index2ValueMap.size() < nnz) {
index2ValueMap = new Long2DoubleOpenHashMap(nnz);
}
for (int i = 0; i < nnz; i++) {
index2ValueMap.addTo(input.readLong(), input.readDouble());
}
} finally {
lock.writeLock().unlock();
}
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class ServerSparseDoubleLongKeyRow method resizeHashMap.
private void resizeHashMap(int size) {
if (index2ValueMap.size() < size) {
Long2DoubleOpenHashMap oldMap = index2ValueMap;
index2ValueMap = new Long2DoubleOpenHashMap(size);
index2ValueMap.putAll(oldMap);
}
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project presto by prestodb.
the class KHyperLogLog method uniquenessDistribution.
public Long2DoubleMap uniquenessDistribution(long histogramSize) {
Long2DoubleMap out = new Long2DoubleOpenHashMap();
PrimitiveIterator.OfLong iterator = LongStream.rangeClosed(1, histogramSize).iterator();
while (iterator.hasNext()) {
// Initialize all entries to zero
out.put(iterator.nextLong(), 0D);
}
int size = minhash.size();
for (HyperLogLog hll : minhash.values()) {
long bucket = Math.min(hll.cardinality(), histogramSize);
out.merge(bucket, (double) 1 / size, Double::sum);
}
return out;
}
Aggregations