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