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