use of com.tencent.angel.ps.storage.matrix.ServerMatrix in project angel by Tencent.
the class MasterRecoverTest method checkMatrixInfo.
private void checkMatrixInfo(ParameterServer ps, int w1Id, int w2Id, int w1Clock, int w2Clock) {
MatrixStorageManager matrixPartManager = ps.getMatrixStorageManager();
ConcurrentHashMap<Integer, ServerMatrix> matrixIdMap = matrixPartManager.getMatrices();
ServerMatrix sw1 = matrixIdMap.get(w1Id);
ServerMatrix sw2 = matrixIdMap.get(w2Id);
assertTrue(sw1 != null);
assertTrue(sw2 != null);
LOG.info("======================partition key is " + sw1.getPartition(0).getPartitionKey());
LOG.info("======================partition key is " + sw1.getPartition(1).getPartitionKey());
assertEquals(sw1.getPartition(0).getPartitionKey().getStartRow(), 0);
assertEquals(sw1.getPartition(0).getPartitionKey().getEndRow(), 1);
assertEquals(sw1.getPartition(0).getPartitionKey().getStartCol(), 0);
assertEquals(sw1.getPartition(0).getPartitionKey().getEndCol(), 50000);
assertEquals(sw1.getPartition(0).getPartitionKey().getMatrixId(), w1Id);
assertEquals(sw1.getPartition(0).getPartitionKey().getPartitionId(), 0);
assertEquals(sw1.getPartition(1).getPartitionKey().getStartRow(), 0);
assertEquals(sw1.getPartition(1).getPartitionKey().getEndRow(), 1);
assertEquals(sw1.getPartition(1).getPartitionKey().getStartCol(), 50000);
assertEquals(sw1.getPartition(1).getPartitionKey().getEndCol(), 100000);
assertEquals(sw1.getPartition(1).getPartitionKey().getMatrixId(), w1Id);
assertEquals(sw1.getPartition(1).getPartitionKey().getPartitionId(), 1);
assertEquals(sw2.getPartition(0).getPartitionKey().getStartRow(), 0);
assertEquals(sw2.getPartition(0).getPartitionKey().getEndRow(), 1);
assertEquals(sw2.getPartition(0).getPartitionKey().getStartCol(), 0);
assertEquals(sw2.getPartition(0).getPartitionKey().getEndCol(), 50000);
assertEquals(sw2.getPartition(0).getPartitionKey().getMatrixId(), w2Id);
assertEquals(sw2.getPartition(0).getPartitionKey().getPartitionId(), 0);
assertEquals(sw2.getPartition(1).getPartitionKey().getStartRow(), 0);
assertEquals(sw2.getPartition(1).getPartitionKey().getEndRow(), 1);
assertEquals(sw2.getPartition(1).getPartitionKey().getStartCol(), 50000);
assertEquals(sw2.getPartition(1).getPartitionKey().getEndCol(), 100000);
assertEquals(sw2.getPartition(1).getPartitionKey().getMatrixId(), w2Id);
assertEquals(sw2.getPartition(1).getPartitionKey().getPartitionId(), 1);
}
use of com.tencent.angel.ps.storage.matrix.ServerMatrix in project angel by Tencent.
the class IncrementRows method getVector.
/**
* Get inner vector from server matrix, it is can be only use in RowBasedPartition and basic row
* type
*
* @param matrixId matrix id
* @param rowId row id
* @param part partition key
* @return inner vector
*/
protected Vector getVector(int matrixId, int rowId, PartitionKey part) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(matrixId);
ServerRow psRow = ((RowBasedPartition) matrix.getPartition(part.getPartitionId())).getRow(rowId);
return ServerRowUtils.getVector(psRow);
}
use of com.tencent.angel.ps.storage.matrix.ServerMatrix in project angel by Tencent.
the class MatrixUtils method getPart.
public static ServerPartition getPart(MatrixStorageManager storageManager, int matrixId, int partId) {
ServerMatrix matrix = storageManager.getMatrix(matrixId);
if (matrix == null) {
throw new ObjectNotFoundException("Can not find matrix " + matrixId);
}
ServerPartition part = matrix.getPartition(partId);
if (part == null) {
throw new ObjectNotFoundException("Can not find partition " + partId + " of matrix " + matrixId);
}
return part;
}
use of com.tencent.angel.ps.storage.matrix.ServerMatrix in project angel by Tencent.
the class MatrixUtils method getRow.
public static ServerRow getRow(MatrixStorageManager storageManager, int matrixId, int partId, int rowId) {
ServerMatrix matrix = storageManager.getMatrix(matrixId);
if (matrix == null) {
throw new ObjectNotFoundException("Can not find matrix " + matrixId);
}
ServerPartition part = matrix.getPartition(partId);
if (part == null) {
throw new ObjectNotFoundException("Can not find partition " + partId + " of matrix " + matrixId);
}
if (!(part instanceof RowBasedPartition)) {
throw new UnsupportedOperationException("Get row only support for RowBasedPartition");
}
ServerRow row = ((RowBasedPartition) part).getRow(rowId);
if (row == null) {
throw new ObjectNotFoundException("Can not find row " + rowId + " of matrix " + matrixId + " in partition " + partId);
}
return row;
}
use of com.tencent.angel.ps.storage.matrix.ServerMatrix in project angel by Tencent.
the class InitNumNeighborEdgesFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartInitNumNeighborEdgesParam param = (PartInitNumNeighborEdgesParam) partParam;
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
RowBasedPartition part = (RowBasedPartition) matrix.getPartition(partParam.getPartKey().getPartitionId());
ServerLongLongRow row = (ServerLongLongRow) part.getRow(0);
ObjectIterator<Long2LongMap.Entry> iter = param.getNodeIdToNumEdges().long2LongEntrySet().iterator();
row.startWrite();
try {
while (iter.hasNext()) {
Long2LongMap.Entry entry = iter.next();
row.set(entry.getLongKey(), entry.getLongValue());
}
} finally {
row.endWrite();
}
}
Aggregations