Search in sources :

Example 1 with ServerSparseDoubleLongKeyRow

use of com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow in project angel by Tencent.

the class Increment 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) {
                if (rowData.containsKey(cols[i])) {
                    rowData.addTo(cols[i], values[i]);
                } else {
                    rowData.put(cols[i], values[i]);
                }
            }
        } finally {
            partRow.getLock().writeLock().unlock();
        }
    }
}
Also used : ServerSparseDoubleLongKeyRow(com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow) ArrayList(java.util.ArrayList) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Example 2 with ServerSparseDoubleLongKeyRow

use of com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow 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();
        }
    }
}
Also used : ServerSparseDoubleLongKeyRow(com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow) ArrayList(java.util.ArrayList) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Example 3 with ServerSparseDoubleLongKeyRow

use of com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow 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);
}
Also used : ServerSparseDoubleLongKeyRow(com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow) CommonParam(com.tencent.angel.ml.matrix.psf.common.CommonParam) Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)

Aggregations

ServerSparseDoubleLongKeyRow (com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow)3 Long2DoubleOpenHashMap (it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap)3 ArrayList (java.util.ArrayList)2 CommonParam (com.tencent.angel.ml.matrix.psf.common.CommonParam)1