use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class ServerSparseDoubleLongKeyRow method deserialize.
@Override
public void deserialize(ByteBuf buf) {
try {
lock.writeLock().lock();
super.deserialize(buf);
int elemNum = buf.readInt();
index2ValueMap = new Long2DoubleOpenHashMap(elemNum);
for (int i = 0; i < elemNum; i++) {
index2ValueMap.put(buf.readLong(), buf.readDouble());
}
} finally {
lock.writeLock().unlock();
}
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Amax method doProcessRow.
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
Long2DoubleOpenHashMap data = row.getIndex2ValueMap();
double amax = Math.abs(data.defaultReturnValue());
for (Map.Entry<Long, Double> entry : data.long2DoubleEntrySet()) {
amax = Math.max(amax, Math.abs(entry.getValue()));
}
return amax;
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Amin method doProcessRow.
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
Long2DoubleOpenHashMap data = row.getIndex2ValueMap();
double amin = Math.abs(data.defaultReturnValue());
for (Map.Entry<Long, Double> entry : data.long2DoubleEntrySet()) {
amin = Math.min(amin, Math.abs(entry.getValue()));
}
return amin;
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Asum method doProcessRow.
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
long entireSize = row.getEndCol() - row.getStartCol();
Long2DoubleOpenHashMap data = row.getData();
double asum = 0.0;
for (Map.Entry<Long, Double> entry : data.long2DoubleEntrySet()) {
asum += Math.abs(entry.getValue());
}
asum += Math.abs(data.defaultReturnValue()) * (entireSize - data.size());
return asum;
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Dot method doProcessRow.
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row1, ServerSparseDoubleLongKeyRow row2) {
long entireSize = row1.getEndCol() - row2.getStartCol();
Long2DoubleOpenHashMap data1 = row1.getIndex2ValueMap();
Long2DoubleOpenHashMap data2 = row2.getIndex2ValueMap();
LongSet keys = data1.keySet();
keys.addAll(data2.keySet());
double sum = 0.0;
for (long key : keys) {
sum += data1.get(key) * data2.get(key);
}
sum += (entireSize - keys.size()) * data1.defaultReturnValue() * data2.defaultReturnValue();
return sum;
}
Aggregations