use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class SparsePush method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, PartitionUpdateParam param) {
CommonParam.PSFPartitionUpdateParam partParam = (CommonParam.PSFPartitionUpdateParam) param;
int rowId = partParam.getInts()[0];
long[] indices = partParam.getLongs();
double[] values = partParam.getDoubles();
ServerSparseDoubleLongKeyRow row = rows[rowId];
Long2DoubleOpenHashMap data = new Long2DoubleOpenHashMap(indices, values);
row.setIndex2ValueMap(data);
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Sqrt method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows) {
Long2DoubleOpenHashMap from = rows[0].getData();
Long2DoubleOpenHashMap to = from.clone();
for (Map.Entry<Long, Double> entry : to.long2DoubleEntrySet()) {
to.put(entry.getKey().longValue(), Math.sqrt(entry.getValue()));
}
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class SubS method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, double[] values) {
double scalar = values[0];
Long2DoubleOpenHashMap from = rows[0].getData();
Long2DoubleOpenHashMap to = from.clone();
to.defaultReturnValue(scalar);
for (Map.Entry<Long, Double> entry : to.long2DoubleEntrySet()) {
entry.setValue(entry.getValue() - scalar);
}
rows[1].setIndex2ValueMap(to);
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class MapWithIndex method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
MapWithIndexFunc mapper = (MapWithIndexFunc) func;
Long2DoubleOpenHashMap data1 = rows[0].getData();
Long2DoubleOpenHashMap data2 = data1.clone();
// TODO: a better way is needed to deal with defaultValue
assert (data2.defaultReturnValue() == 0.0);
for (java.util.Map.Entry<Long, Double> entry : data2.long2DoubleEntrySet()) {
entry.setValue(mapper.call(entry.getKey().intValue(), entry.getValue()));
}
rows[1].setIndex2ValueMap(data2);
}
use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.
the class Zip2MapWithIndex method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
Zip2MapWithIndexFunc mapper = (Zip2MapWithIndexFunc) func;
Long2DoubleOpenHashMap from1 = rows[0].getData();
Long2DoubleOpenHashMap from2 = rows[1].getData();
Long2DoubleOpenHashMap to = from1.clone();
// TODO: a better way is needed to deal with defaultValue
assert (from1.defaultReturnValue() == 0.0 && from2.defaultReturnValue() == 0.0);
LongSet keySet = from1.keySet();
keySet.addAll(from2.keySet());
for (long key : keySet) {
to.put(key, mapper.call((int) key, from1.get(key), from2.get(key)));
}
rows[2].setIndex2ValueMap(to);
}
Aggregations