Search in sources :

Example 1 with MatrixMeta

use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.

the class MatrixStorageManager method loadMatrix.

private void loadMatrix(Path inputPath, int matrixId) throws IOException {
    ServerMatrix matrix = context.getMatrixStorageManager().getMatrix(matrixId);
    MatrixMeta matrixMeta = context.getMatrixMetaManager().getMatrixMeta(matrixId);
    if (matrix != null) {
        if (inputPath == null) {
            try {
                inputPath = recover.getSnapshotPath(matrixId);
            } catch (IOException e) {
                LOG.error("Get snapshot path failed, ", e);
            }
            if (inputPath == null) {
                String loadPathStr = matrixMeta.getAttribute(MatrixConf.MATRIX_LOAD_PATH);
                if (loadPathStr != null) {
                    inputPath = new Path(loadPathStr);
                }
            }
        }
        matrix.load(matrixMeta, inputPath);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) ServerMatrix(com.tencent.angel.ps.impl.matrix.ServerMatrix) MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) IOException(java.io.IOException)

Example 2 with MatrixMeta

use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.

the class ParameterServer method buildMatrixReports.

private List<MatrixReportProto> buildMatrixReports() {
    MatrixReportProto.Builder matrixBuilder = MatrixReportProto.newBuilder();
    PartReportProto.Builder partBuilder = PartReportProto.newBuilder();
    List<MatrixReportProto> ret = new ArrayList<>();
    for (MatrixMeta matrix : matrixMetaManager.getMatrixMetas().values()) {
        matrixBuilder.setMatrixId(matrix.getId()).setMatrixName(matrix.getName());
        if (context.getPartReplication() > 1) {
            for (PartitionMeta part : matrix.getPartitionMetas().values()) {
                partBuilder.setPartId(part.getPartId()).setStatus(context.getMatrixStorageManager().getPart(matrix.getId(), part.getPartId()).getState().getNumber());
                matrixBuilder.addPartReports(partBuilder.build());
            }
        }
        ret.add(matrixBuilder.build());
        matrixBuilder.clear();
    }
    return ret;
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) ArrayList(java.util.ArrayList) PartitionMeta(com.tencent.angel.ml.matrix.PartitionMeta)

Example 3 with MatrixMeta

use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.

the class ServerMatrix method init.

public void init() {
    MatrixMeta matrixMeta = context.getMatrixMetaManager().getMatrixMeta(matrixId);
    Map<Integer, PartitionMeta> partMetas = matrixMeta.getPartitionMetas();
    for (PartitionMeta partMeta : partMetas.values()) {
        ServerPartition part = new ServerPartition(partMeta.getPartitionKey(), matrixMeta.getRowType());
        partitionMaps.put(partMeta.getPartId(), part);
        part.init();
    }
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) PartitionMeta(com.tencent.angel.ml.matrix.PartitionMeta)

Example 4 with MatrixMeta

use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.

the class ConsistencyController method isNeedClone.

private boolean isNeedClone(int matrixId) {
    MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    int localTaskNum = PSAgentContext.get().getLocalTaskNum();
    return !matrixMeta.isHogwild() && localTaskNum > 1;
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta)

Example 5 with MatrixMeta

use of com.tencent.angel.ml.matrix.MatrixMeta in project angel by Tencent.

the class CompSparseIntMatrixOpLog method flushToLocalStorage.

/**
 * Flush the update in cache to local matrix storage
 */
public void flushToLocalStorage() {
    MatrixStorage storage = PSAgentContext.get().getMatrixStorageManager().getMatrixStoage(matrixId);
    MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    int row = matrixMeta.getRowNum();
    TVector deltaVector = null;
    TVector vector = null;
    ReentrantReadWriteLock globalStorageLock = storage.getLock();
    try {
        globalStorageLock.writeLock().lock();
        for (int rowIndex = 0; rowIndex < row; rowIndex++) {
            deltaVector = getRow(rowIndex);
            vector = storage.getRow(rowIndex);
            if (deltaVector == null || vector == null)
                continue;
            vector.plusBy(deltaVector, 1.0 / PSAgentContext.get().getTotalTaskNum());
        }
    } finally {
        globalStorageLock.writeLock().unlock();
    }
}
Also used : MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) TVector(com.tencent.angel.ml.math.TVector) MatrixStorage(com.tencent.angel.psagent.matrix.storage.MatrixStorage)

Aggregations

MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)78 PartitionKey (com.tencent.angel.PartitionKey)40 ArrayList (java.util.ArrayList)25 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)13 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)13 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)12 AngelException (com.tencent.angel.exception.AngelException)7 PartitionMeta (com.tencent.angel.ml.matrix.PartitionMeta)7 RowType (com.tencent.angel.ml.matrix.RowType)7 MatrixTransportClient (com.tencent.angel.psagent.matrix.transport.MatrixTransportClient)7 KeyValuePart (com.tencent.angel.psagent.matrix.transport.router.KeyValuePart)7 PartitionUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.PartitionUpdateParam)6 Path (org.apache.hadoop.fs.Path)6 GeneralPartGetParam (com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam)5 ParameterServerId (com.tencent.angel.ps.ParameterServerId)5 FutureResult (com.tencent.angel.psagent.matrix.transport.FutureResult)5 MapResponseCache (com.tencent.angel.psagent.matrix.transport.response.MapResponseCache)5 ResponseCache (com.tencent.angel.psagent.matrix.transport.response.ResponseCache)5 AMMatrixMetaManager (com.tencent.angel.master.matrixmeta.AMMatrixMetaManager)4 Vector (com.tencent.angel.ml.math2.vector.Vector)4