use of com.tencent.angel.ml.math.TVector in project angel by Tencent.
the class CompSparseIntMatrixOpLog method split.
/**
* Split the update according to the matrix partitions
*
* @param psUpdateData partition -> row split list map
*/
public void split(Map<PartitionKey, List<RowUpdateSplit>> psUpdateData) {
long startTime = System.currentTimeMillis();
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
List<PartitionKey> partitions = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
int row = matrixMeta.getRowNum();
for (int rowId = 0; rowId < row; rowId++) {
TVector vector = getRow(rowId);
if (vector == null)
continue;
// Filter it, removing zero values
if (enableFilter && isNeedFilter(vector)) {
vector = vector.filter(0.0);
}
// Doing average or not
if (matrixMeta.isAverage()) {
vector.timesBy(1.0 / PSAgentContext.get().getTotalTaskNum());
}
// Split this row according the matrix partitions
Map<PartitionKey, RowUpdateSplit> splits = RowUpdateSplitUtils.split(vector, partitions);
removeRow(rowId);
// Add the splits to the result container
for (Map.Entry<PartitionKey, RowUpdateSplit> entry : splits.entrySet()) {
List<RowUpdateSplit> rowSplits = psUpdateData.get(entry.getKey());
if (rowSplits == null) {
rowSplits = new ArrayList<>();
psUpdateData.put(entry.getKey(), rowSplits);
}
rowSplits.add(entry.getValue());
}
}
LOG.debug("taking " + (System.currentTimeMillis() - startTime) + " ms to split logs for matrix=" + matrixId);
}
Aggregations