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