Search in sources :

Example 1 with Long2DoubleOpenHashMap

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();
    }
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Example 2 with Long2DoubleOpenHashMap

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;
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Map(java.util.Map)

Example 3 with Long2DoubleOpenHashMap

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;
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Map(java.util.Map)

Example 4 with Long2DoubleOpenHashMap

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;
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Map(java.util.Map)

Example 5 with Long2DoubleOpenHashMap

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;
}
Also used : LongSet(it.unimi.dsi.fastutil.longs.LongSet) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Aggregations

Long2DoubleOpenHashMap (it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)59 Map (java.util.Map)29 LongSet (it.unimi.dsi.fastutil.longs.LongSet)7 ServerSparseDoubleLongKeyRow (com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow)3 ArrayList (java.util.ArrayList)2 HyperLogLog (com.facebook.airlift.stats.cardinality.HyperLogLog)1 CommonParam (com.tencent.angel.ml.matrix.psf.common.CommonParam)1 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)1 RowOffset (com.tencent.angel.model.output.format.ModelPartitionMeta.RowOffset)1 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)1 ILongKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)1 Int2DoubleOpenHashMap (it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap)1 Int2FloatOpenHashMap (it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 Long2DoubleMap (it.unimi.dsi.fastutil.longs.Long2DoubleMap)1 PrimitiveIterator (java.util.PrimitiveIterator)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1