use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class GetClosenessPartResult method deserialize.
@Override
public void deserialize(ByteBuf input) {
int size = input.readInt();
closenesses = new Long2DoubleOpenHashMap();
for (int i = 0; i < size; i++) {
long key = input.readLong();
double val = input.readDouble();
closenesses.put(key, val);
}
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Min method doProcessRow.
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
Long2DoubleOpenHashMap data = row.getIndex2ValueMap();
double amin = data.defaultReturnValue();
for (Map.Entry<Long, Double> entry : data.long2DoubleEntrySet()) {
amin = Math.min(amin, entry.getValue());
}
return amin;
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Nrm2 method doProcessRow.
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
long entireSize = row.getEndCol() - row.getStartCol();
double qSum = 0.0;
Long2DoubleOpenHashMap data = row.getIndex2ValueMap();
for (Map.Entry<Long, Double> entry : data.long2DoubleEntrySet()) {
qSum += Math.pow(entry.getValue(), 2);
}
qSum += Math.pow(data.defaultReturnValue(), 2) * (entireSize - data.size());
return qSum;
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Fill method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] partRows, PartitionUpdateParam param) {
CommonParam.PSFPartitionUpdateParam partParam = (CommonParam.PSFPartitionUpdateParam) param;
int[] rows = partParam.getInts();
long[] cols = partParam.getLongs();
double[] values = partParam.getDoubles();
for (ServerSparseDoubleLongKeyRow partRow : partRows) {
int rowId = partRow.getRowId();
ArrayList<Integer> indics = new ArrayList<Integer>();
for (int i = 0; i < rows.length; i++) {
if (rowId == rows[i] && cols[i] >= partRow.getStartCol() && cols[i] < partRow.getEndCol()) {
indics.add(i);
}
}
try {
partRow.getLock().writeLock().lock();
Long2DoubleOpenHashMap rowData = partRow.getData();
for (Integer i : indics) {
rowData.put(cols[i], values[i]);
}
} finally {
partRow.getLock().writeLock().unlock();
}
}
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Abs method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows) {
Long2DoubleOpenHashMap from = rows[0].getIndex2ValueMap();
Long2DoubleOpenHashMap to = from.clone();
to.defaultReturnValue(Math.abs(to.defaultReturnValue()));
for (Map.Entry<Long, Double> entry : to.long2DoubleEntrySet()) {
entry.setValue(Math.abs(entry.getValue()));
}
rows[1].setIndex2ValueMap(to);
}
Aggregations