Search in sources :

Example 31 with RowBasedPartition

use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.

the class GraphMatrixUtils method getPSIntKeyRow.

public static ServerIntAnyRow getPSIntKeyRow(PSContext psContext, GeneralPartUpdateParam partParam) {
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
    return (ServerIntAnyRow) (((RowBasedPartition) part).getRow(0));
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerIntAnyRow(com.tencent.angel.ps.storage.vector.ServerIntAnyRow) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Example 32 with RowBasedPartition

use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.

the class GraphMatrixUtils method getPSIntKeyRow.

public static ServerIntAnyRow getPSIntKeyRow(PSContext psContext, PartitionGetParam partParam) {
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
    return (ServerIntAnyRow) (((RowBasedPartition) part).getRow(0));
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerIntAnyRow(com.tencent.angel.ps.storage.vector.ServerIntAnyRow) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Example 33 with RowBasedPartition

use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.

the class GetColsFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    PartitionGetColsParam param = (PartitionGetColsParam) partParam;
    int[] rows = param.rows;
    long[] cols = param.cols;
    int matId = param.getMatrixId();
    int partitionId = param.getPartKey().getPartitionId();
    Arrays.sort(rows);
    RowBasedPartition partition = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(matId, partitionId);
    ServerRow[] splits = new ServerRow[rows.length];
    for (int i = 0; i < rows.length; i++) {
        splits[i] = partition.getRow(rows[i]);
    }
    Vector result = doGet(splits, cols, param.func);
    return new PartitionGetColsResult(rows, cols, result);
}
Also used : RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition)

Example 34 with RowBasedPartition

use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.

the class GraphMatrixUtils method getPSLongKeyIntRow.

public static ServerLongIntRow getPSLongKeyIntRow(PSContext psContext, PartitionGetParam partParam, int rowId) {
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
    return (ServerLongIntRow) (((RowBasedPartition) part).getRow(rowId));
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition) ServerLongIntRow(com.tencent.angel.ps.storage.vector.ServerLongIntRow)

Example 35 with RowBasedPartition

use of com.tencent.angel.ps.storage.partition.RowBasedPartition 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

RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)38 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)28 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)20 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)15 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)6 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)5 ServerIntAnyRow (com.tencent.angel.ps.storage.vector.ServerIntAnyRow)4 Random (java.util.Random)4 ServerLongIntRow (com.tencent.angel.ps.storage.vector.ServerLongIntRow)3 Vector (com.tencent.angel.ml.math2.vector.Vector)2 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)2 ServerAnyAnyRow (com.tencent.angel.ps.storage.vector.ServerAnyAnyRow)2 ServerLongLongRow (com.tencent.angel.ps.storage.vector.ServerLongLongRow)2 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)2 AngelException (com.tencent.angel.exception.AngelException)1 Node (com.tencent.angel.graph.data.Node)1 DynamicNeighborElement (com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement)1 NeighborsAliasTableElement (com.tencent.angel.graph.psf.neighbors.samplebyaliastable.samplealiastable.NeighborsAliasTableElement)1 CompIntDoubleVector (com.tencent.angel.ml.math2.vector.CompIntDoubleVector)1 CompIntFloatVector (com.tencent.angel.ml.math2.vector.CompIntFloatVector)1