Search in sources :

Example 1 with RowUpdateSplit

use of com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit in project angel by Tencent.

the class MatrixClientAdapter method flush.

/**
 * Flush the matrix oplog to parameter servers.
 *
 * @param matrixId    matrix id
 * @param taskContext task context
 * @param matrixOpLog matrix oplog
 * @param updateClock true means we should update the clock value after update matrix
 * @return Future<VoidResult> flush future result
 */
public Future<VoidResult> flush(int matrixId, TaskContext taskContext, MatrixOpLog matrixOpLog, boolean updateClock) {
    if (!updateClock && (matrixOpLog == null)) {
        FutureResult<VoidResult> ret = new FutureResult<VoidResult>();
        ret.set(new VoidResult(ResponseType.SUCCESS));
        return ret;
    }
    Map<PartitionKey, List<RowUpdateSplit>> psUpdateData = new HashMap<PartitionKey, List<RowUpdateSplit>>();
    FlushRequest request = new FlushRequest(taskContext.getMatrixClock(matrixId), taskContext.getIndex(), matrixId, matrixOpLog, updateClock);
    LOG.debug("start to flush update for matrix=" + matrixId + ", taskIndex=" + taskContext.getIndex());
    long startTs = System.currentTimeMillis();
    // Split the matrix oplog according to the matrix partitions
    if (matrixOpLog != null) {
        matrixOpLog.split(psUpdateData);
    }
    LOG.debug("split use time=" + (System.currentTimeMillis() - startTs));
    // If need update clock, we should send requests to all partitions
    if (updateClock) {
        fillPartRequestForClock(matrixId, psUpdateData, taskContext);
    }
    FlushResponseCache cache = new FlushResponseCache(psUpdateData.size());
    pushUpdates(matrixId, psUpdateData, taskContext, updateClock, cache);
    requestToResponseMap.put(request, cache);
    return cache.getMergedResult();
}
Also used : VoidResult(com.tencent.angel.ml.matrix.psf.update.enhance.VoidResult) FutureResult(com.tencent.angel.psagent.matrix.transport.FutureResult) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) Int2IntOpenHashMap(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap) PartitionKey(com.tencent.angel.PartitionKey) RowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit)

Aggregations

PartitionKey (com.tencent.angel.PartitionKey)1 VoidResult (com.tencent.angel.ml.matrix.psf.update.enhance.VoidResult)1 RowUpdateSplit (com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit)1 FutureResult (com.tencent.angel.psagent.matrix.transport.FutureResult)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1