Search in sources :

Example 21 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
    ServerRow ranks = psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 2);
    FloatVector ranksVector = ServerRowUtils.getVector((ServerLongFloatRow) ranks);
    long[] ret;
    if (ranksVector instanceof IntFloatVector)
        ret = gatherNodes((IntFloatVector) ranksVector, part.getPartitionKey().getStartCol());
    else if (ranksVector instanceof LongFloatVector)
        ret = gatherNodes((LongFloatVector) ranksVector, part.getPartitionKey().getStartCol());
    else {
        throw new AngelException("vector should be intfloat or longfloat but is " + ranksVector.getClass().getName());
    }
    return new IndexPartGetLongResult(part.getPartitionKey(), ret);
}
Also used : AngelException(com.tencent.angel.exception.AngelException) IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector) FloatVector(com.tencent.angel.ml.math2.vector.FloatVector) LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 22 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class ByteBufSerdeUtils method deserializeServerRow.

public static ServerRow deserializeServerRow(ByteBuf in) {
    ServerRow rowSplit = ServerRowFactory.createEmptyServerRow(RowType.valueOf(in.readInt()));
    rowSplit.deserialize(in);
    return rowSplit;
}
Also used : ServerRow(com.tencent.angel.ps.storage.vector.ServerRow)

Example 23 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class GetRowsHandler method handle.

@Override
public ResponseData handle(RequestHeader header, RequestData data) throws Exception {
    GetRowsSplitRequest request = (GetRowsSplitRequest) data;
    int[] rowIds = request.getRowIds();
    ServerRow[] rows = new ServerRow[rowIds.length];
    for (int i = 0; i < rowIds.length; i++) {
        rows[i] = MatrixUtils.getRow(context.getMatrixStorageManager(), header.matrixId, header.partId, rowIds[i]);
    }
    return new GetRowsSplitResponse(rows);
}
Also used : GetRowsSplitResponse(com.tencent.angel.ps.server.data.response.GetRowsSplitResponse) GetRowsSplitRequest(com.tencent.angel.ps.server.data.request.GetRowsSplitRequest) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow)

Example 24 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class IndexGetRowHandler method handle.

@Override
public ResponseData handle(RequestHeader header, RequestData data) throws Exception {
    IndexPartGetRowRequest request = (IndexPartGetRowRequest) data;
    KeyPart keyPart = request.getKeyPart();
    ServerRow row = MatrixUtils.getRow(context.getMatrixStorageManager(), header.matrixId, header.partId, request.getRowId());
    ValuePart result;
    StreamIndexPartGetRowResponse response;
    row.startRead();
    try {
        result = ServerRowUtils.getByKeys(row, keyPart);
        response = new StreamIndexPartGetRowResponse(result);
        return response;
    } finally {
        row.endRead();
    }
}
Also used : IndexPartGetRowRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowRequest) ValuePart(com.tencent.angel.psagent.matrix.transport.router.ValuePart) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) StreamIndexPartGetRowResponse(com.tencent.angel.ps.server.data.response.StreamIndexPartGetRowResponse)

Example 25 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class SparseServerRowsStorage method deserialize.

@Override
public void deserialize(ByteBuf input) {
    super.deserialize(input);
    // Array size
    input.readInt();
    // Actual write row number
    int writeRowNum = input.readInt();
    data = new HashMap<>(writeRowNum);
    // Rows data
    for (int i = 0; i < writeRowNum; i++) {
        // Row id
        int index = input.readInt();
        // Create empty server row
        ServerRow row = ServerRowFactory.createEmptyServerRow(RowType.valueOf(input.readInt()));
        // Row data
        row.deserialize(input);
        data.put(index, row);
    }
}
Also used : ServerRow(com.tencent.angel.ps.storage.vector.ServerRow)

Aggregations

ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)42 Vector (com.tencent.angel.ml.math2.vector.Vector)13 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)6 PartIncrementRowsParam (com.tencent.angel.ml.matrix.psf.update.update.PartIncrementRowsParam)5 RowUpdateSplit (com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit)5 ArrayList (java.util.ArrayList)5 PartitionKey (com.tencent.angel.PartitionKey)4 ServerIntIntRow (com.tencent.angel.ps.storage.vector.ServerIntIntRow)4 AngelException (com.tencent.angel.exception.AngelException)2 FloatVector (com.tencent.angel.ml.math2.vector.FloatVector)2 RowType (com.tencent.angel.ml.matrix.RowType)2 PartitionGetRowsParam (com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam)2 GetRowSplitResponse (com.tencent.angel.ps.server.data.response.GetRowSplitResponse)2 GetRowsSplitResponse (com.tencent.angel.ps.server.data.response.GetRowsSplitResponse)2 Response (com.tencent.angel.ps.server.data.response.Response)2 MatrixStorageManager (com.tencent.angel.ps.storage.MatrixStorageManager)2 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)2 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)2 ServerRowsStorage (com.tencent.angel.ps.storage.partition.storage.ServerRowsStorage)2 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)2