Search in sources :

Example 1 with GetRowsSplitResponse

use of com.tencent.angel.ps.server.data.response.GetRowsSplitResponse in project angel by Tencent.

the class GetRowsHandler method merge.

private Vector[] merge(int matrixId, int[] rowIds, Collection<Response> responses) {
    Map<Integer, List<ServerRow>> rowIdToserverRows = new HashMap<>(rowIds.length);
    int valueNum = responses.size();
    for (Response response : responses) {
        ServerRow[] serverRows = ((GetRowsSplitResponse) (response.getData())).getRowsSplit();
        for (int j = 0; j < serverRows.length; j++) {
            int rowId = serverRows[j].getRowId();
            List<ServerRow> rowSplits = rowIdToserverRows.get(rowId);
            if (rowSplits == null) {
                rowSplits = new ArrayList<>(valueNum);
                rowIdToserverRows.put(rowId, rowSplits);
            }
            rowSplits.add(serverRows[j]);
        }
    }
    Vector[] vectors = new Vector[rowIds.length];
    for (int i = 0; i < rowIds.length; i++) {
        vectors[i] = MergeUtils.combineServerRowSplits(rowIdToserverRows.get(rowIds[i]), matrixId, rowIds[i]);
        vectors[i].setMatrixId(matrixId);
        vectors[i].setRowId(rowIds[i]);
    }
    return vectors;
}
Also used : HashMap(java.util.HashMap) Response(com.tencent.angel.ps.server.data.response.Response) GetRowsSplitResponse(com.tencent.angel.ps.server.data.response.GetRowsSplitResponse) GetRowsSplitResponse(com.tencent.angel.ps.server.data.response.GetRowsSplitResponse) ArrayList(java.util.ArrayList) List(java.util.List) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) Vector(com.tencent.angel.ml.math2.vector.Vector)

Example 2 with GetRowsSplitResponse

use of com.tencent.angel.ps.server.data.response.GetRowsSplitResponse in project angel by Tencent.

the class GetRowsHandler method parseResponse.

@Override
public ResponseData parseResponse(ByteBuf in) {
    GetRowsSplitResponse response = new GetRowsSplitResponse();
    response.deserialize(in);
    return response;
}
Also used : GetRowsSplitResponse(com.tencent.angel.ps.server.data.response.GetRowsSplitResponse)

Example 3 with GetRowsSplitResponse

use of com.tencent.angel.ps.server.data.response.GetRowsSplitResponse 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)

Aggregations

GetRowsSplitResponse (com.tencent.angel.ps.server.data.response.GetRowsSplitResponse)3 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)2 Vector (com.tencent.angel.ml.math2.vector.Vector)1 GetRowsSplitRequest (com.tencent.angel.ps.server.data.request.GetRowsSplitRequest)1 Response (com.tencent.angel.ps.server.data.response.Response)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1