Search in sources :

Example 26 with ServerMatrix

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);
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) MatrixStorageManager(com.tencent.angel.ps.storage.MatrixStorageManager)

Example 27 with ServerMatrix

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);
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition)

Example 28 with ServerMatrix

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;
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) ObjectNotFoundException(com.tencent.angel.ps.server.data.exception.ObjectNotFoundException) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Example 29 with ServerMatrix

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;
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) ObjectNotFoundException(com.tencent.angel.ps.server.data.exception.ObjectNotFoundException) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Example 30 with ServerMatrix

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();
    }
}
Also used : Long2LongMap(it.unimi.dsi.fastutil.longs.Long2LongMap) ServerLongLongRow(com.tencent.angel.ps.storage.vector.ServerLongLongRow) ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition)

Aggregations

ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)39 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)28 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)22 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)15 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)5 Random (java.util.Random)5 ServerIntAnyRow (com.tencent.angel.ps.storage.vector.ServerIntAnyRow)4 CSRPartition (com.tencent.angel.ps.storage.partition.CSRPartition)3 IntCSRStorage (com.tencent.angel.ps.storage.partition.storage.IntCSRStorage)3 ServerLongIntRow (com.tencent.angel.ps.storage.vector.ServerLongIntRow)3 AngelException (com.tencent.angel.exception.AngelException)2 MatrixFormat (com.tencent.angel.model.output.format.MatrixFormat)2 Pair (com.tencent.angel.protobuf.generated.MLProtos.Pair)2 ParameterServer (com.tencent.angel.ps.ParameterServer)2 ObjectNotFoundException (com.tencent.angel.ps.server.data.exception.ObjectNotFoundException)2 MatrixStorageManager (com.tencent.angel.ps.storage.MatrixStorageManager)2 ServerAnyAnyRow (com.tencent.angel.ps.storage.vector.ServerAnyAnyRow)2 ServerLongLongRow (com.tencent.angel.ps.storage.vector.ServerLongLongRow)2 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)2 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)2