Search in sources :

Example 1 with ServerIntLongRow

use of com.tencent.angel.ps.storage.vector.ServerIntLongRow in project angel by Tencent.

the class MergeUtils method combineServerIntLongRowSplits.

private static Vector combineServerIntLongRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
    int colNum = (int) matrixMeta.getColNum();
    int elemNum = 0;
    int size = rowSplits.size();
    for (int i = 0; i < size; i++) {
        elemNum += rowSplits.get(i).size();
    }
    IntLongVector row;
    if (matrixMeta.isHash()) {
        row = VFactory.sparseLongVector(colNum, elemNum);
    } else {
        if (elemNum >= (int) (storageConvFactor * colNum)) {
            row = VFactory.denseLongVector(colNum);
        } else {
            row = VFactory.sparseLongVector(colNum, elemNum);
        }
    }
    row.setMatrixId(matrixMeta.getId());
    row.setRowId(rowIndex);
    Collections.sort(rowSplits, serverRowComp);
    for (int i = 0; i < size; i++) {
        if (rowSplits.get(i) == null) {
            continue;
        }
        ((ServerIntLongRow) rowSplits.get(i)).mergeTo(row);
    }
    return row;
}
Also used : IntLongVector(com.tencent.angel.ml.math2.vector.IntLongVector) ServerIntLongRow(com.tencent.angel.ps.storage.vector.ServerIntLongRow)

Example 2 with ServerIntLongRow

use of com.tencent.angel.ps.storage.vector.ServerIntLongRow in project angel by Tencent.

the class RowSplitCombineUtils method combineServerIntLongRowSplits.

private static Vector combineServerIntLongRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
    int colNum = (int) matrixMeta.getColNum();
    int elemNum = 0;
    int size = rowSplits.size();
    for (int i = 0; i < size; i++) {
        elemNum += rowSplits.get(i).size();
    }
    IntLongVector row;
    if (elemNum >= (int) (storageConvFactor * colNum)) {
        row = VFactory.denseLongVector(colNum);
    } else {
        row = VFactory.sparseLongVector(colNum, elemNum);
    }
    row.setMatrixId(matrixMeta.getId());
    row.setRowId(rowIndex);
    Collections.sort(rowSplits, serverRowComp);
    int clock = Integer.MAX_VALUE;
    for (int i = 0; i < size; i++) {
        if (rowSplits.get(i) == null) {
            continue;
        }
        if (rowSplits.get(i).getClock() < clock) {
            clock = rowSplits.get(i).getClock();
        }
        ((ServerIntLongRow) rowSplits.get(i)).mergeTo(row);
    }
    row.setClock(clock);
    return row;
}
Also used : IntLongVector(com.tencent.angel.ml.math2.vector.IntLongVector) ServerIntLongRow(com.tencent.angel.ps.storage.vector.ServerIntLongRow)

Aggregations

IntLongVector (com.tencent.angel.ml.math2.vector.IntLongVector)2 ServerIntLongRow (com.tencent.angel.ps.storage.vector.ServerIntLongRow)2