Search in sources :

Example 21 with Long2DoubleOpenHashMap

use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.

the class Map method doUpdate.

@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
    MapFunc mapper = (MapFunc) func;
    Long2DoubleOpenHashMap data1 = rows[0].getData();
    Long2DoubleOpenHashMap data2 = data1.clone();
    double defaultValue = data2.defaultReturnValue();
    data2.defaultReturnValue(mapper.call(defaultValue));
    for (java.util.Map.Entry<Long, Double> entry : data2.long2DoubleEntrySet()) {
        double value = entry.getValue();
        entry.setValue(mapper.call(value));
    }
    rows[1].setIndex2ValueMap(data2);
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Example 22 with Long2DoubleOpenHashMap

use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.

the class MapInPlace method doUpdate.

@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
    MapFunc mapper = (MapFunc) func;
    Long2DoubleOpenHashMap data1 = rows[0].getData();
    double defaultValue = data1.defaultReturnValue();
    data1.defaultReturnValue(mapper.call(defaultValue));
    for (java.util.Map.Entry<Long, Double> entry : data1.long2DoubleEntrySet()) {
        double value = entry.getValue();
        entry.setValue(mapper.call(value));
    }
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Example 23 with Long2DoubleOpenHashMap

use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.

the class Zip2Map method doUpdate.

@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
    Zip2MapFunc mapper = (Zip2MapFunc) func;
    Long2DoubleOpenHashMap from1 = rows[0].getData();
    Long2DoubleOpenHashMap from2 = rows[1].getData();
    Long2DoubleOpenHashMap to = from1.clone();
    to.defaultReturnValue(mapper.call(from1.defaultReturnValue(), from2.defaultReturnValue()));
    LongSet keySet = from1.keySet();
    keySet.addAll(from2.keySet());
    for (long key : keySet) {
        to.put(key, mapper.call(from1.get(key), from2.get(key)));
    }
    rows[2].setIndex2ValueMap(to);
}
Also used : LongSet(it.unimi.dsi.fastutil.longs.LongSet) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Example 24 with Long2DoubleOpenHashMap

use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.

the class Zip3Map method doUpdate.

@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
    Zip3MapFunc mapper = (Zip3MapFunc) func;
    Long2DoubleOpenHashMap from1 = rows[0].getData();
    Long2DoubleOpenHashMap from2 = rows[1].getData();
    Long2DoubleOpenHashMap from3 = rows[2].getData();
    Long2DoubleOpenHashMap to = from1.clone();
    to.defaultReturnValue(mapper.call(from1.defaultReturnValue(), from2.defaultReturnValue(), from3.defaultReturnValue()));
    LongSet keySet = from1.keySet();
    keySet.addAll(from2.keySet());
    for (long key : keySet) {
        to.put(key, mapper.call(from1.get(key), from2.get(key), from3.get(key)));
    }
    rows[2].setIndex2ValueMap(to);
}
Also used : LongSet(it.unimi.dsi.fastutil.longs.LongSet) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Example 25 with Long2DoubleOpenHashMap

use of it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap in project angel by Tencent.

the class Zip3MapWithIndex method doUpdate.

@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
    Zip3MapWithIndexFunc mapper = (Zip3MapWithIndexFunc) func;
    Long2DoubleOpenHashMap from1 = rows[0].getData();
    Long2DoubleOpenHashMap from2 = rows[1].getData();
    Long2DoubleOpenHashMap from3 = rows[2].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), from3.get(key)));
    }
    rows[2].setIndex2ValueMap(to);
}
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