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;
}
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;
}
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);
}
Aggregations