Search in sources :

Example 1 with UpdateOp

use of com.tencent.angel.ps.server.data.request.UpdateOp in project angel by Tencent.

the class UpdateColsFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    PartitionUpdateColsParam param = (PartitionUpdateColsParam) partParam;
    int[] rows = param.rows;
    long[] cols = param.cols;
    Vector vector = param.vector;
    UpdateOp op = param.op;
    int matId = param.getMatrixId();
    int partitionId = param.getPartKey().getPartitionId();
    RowBasedPartition partition = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(matId, partitionId);
    switch(partition.getRowType()) {
        case T_DOUBLE_DENSE:
        case T_DOUBLE_SPARSE:
            {
                ServerIntDoubleRow[] doubles = new ServerIntDoubleRow[rows.length];
                for (int r = 0; r < rows.length; r++) doubles[r] = (ServerIntDoubleRow) partition.getRow(rows[r]);
                doUpdate((CompIntDoubleVector) vector, rows, cols, doubles, op);
                return;
            }
        case T_DOUBLE_SPARSE_LONGKEY:
            {
                ServerLongDoubleRow[] doubles = new ServerLongDoubleRow[rows.length];
                for (int r = 0; r < rows.length; r++) doubles[r] = (ServerLongDoubleRow) partition.getRow(rows[r]);
                doUpdate((CompIntDoubleVector) vector, rows, cols, doubles, op);
                return;
            }
        case T_FLOAT_DENSE:
        case T_FLOAT_SPARSE:
            {
                ServerIntFloatRow[] floats = new ServerIntFloatRow[rows.length];
                for (int r = 0; r < rows.length; r++) floats[r] = (ServerIntFloatRow) partition.getRow(rows[r]);
                doUpdate((CompIntFloatVector) vector, rows, cols, floats, op);
                return;
            }
        case T_FLOAT_SPARSE_LONGKEY:
            {
                ServerLongFloatRow[] floats = new ServerLongFloatRow[rows.length];
                for (int r = 0; r < rows.length; r++) floats[r] = (ServerLongFloatRow) partition.getRow(rows[r]);
                doUpdate((CompIntFloatVector) vector, rows, cols, floats, op);
                return;
            }
        default:
            throw new AngelException("Data type should be double or float!");
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) CompIntFloatVector(com.tencent.angel.ml.math2.vector.CompIntFloatVector) UpdateOp(com.tencent.angel.ps.server.data.request.UpdateOp) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) CompIntFloatVector(com.tencent.angel.ml.math2.vector.CompIntFloatVector) CompIntDoubleVector(com.tencent.angel.ml.math2.vector.CompIntDoubleVector) Vector(com.tencent.angel.ml.math2.vector.Vector) CompIntDoubleVector(com.tencent.angel.ml.math2.vector.CompIntDoubleVector)

Aggregations

AngelException (com.tencent.angel.exception.AngelException)1 CompIntDoubleVector (com.tencent.angel.ml.math2.vector.CompIntDoubleVector)1 CompIntFloatVector (com.tencent.angel.ml.math2.vector.CompIntFloatVector)1 Vector (com.tencent.angel.ml.math2.vector.Vector)1 UpdateOp (com.tencent.angel.ps.server.data.request.UpdateOp)1 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)1