Search in sources :

Example 1 with ServerLongLongRow

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

the class GetNumNeighborEdgesFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    PartGetNumNeighborEdgesParam param = (PartGetNumNeighborEdgesParam) partParam;
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
    ServerLongLongRow row = (ServerLongLongRow) (((RowBasedPartition) part).getRow(0));
    long[] nodeIds = param.getNodeIds();
    long[] numEdges = new long[nodeIds.length];
    for (int i = 0; i < nodeIds.length; i++) {
        numEdges[i] = row.get(nodeIds[i]);
    }
    return new PartGetNumNeighborEdgesResult(part.getPartitionKey().getPartitionId(), numEdges);
}
Also used : ServerLongLongRow(com.tencent.angel.ps.storage.vector.ServerLongLongRow) ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Example 2 with ServerLongLongRow

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

the class MergeUtils method combineServerLongLongRowSplits.

private static Vector combineServerLongLongRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
    long colNum = matrixMeta.getColNum();
    int elemNum = 0;
    int size = rowSplits.size();
    for (int i = 0; i < size; i++) {
        elemNum += rowSplits.get(i).size();
    }
    LongLongVector row = VFactory.sparseLongKeyLongVector(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;
        }
        ((ServerLongLongRow) rowSplits.get(i)).mergeTo(row);
    }
    return row;
}
Also used : ServerLongLongRow(com.tencent.angel.ps.storage.vector.ServerLongLongRow) LongLongVector(com.tencent.angel.ml.math2.vector.LongLongVector)

Example 3 with ServerLongLongRow

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

the class RowSplitCombineUtils method combineServerLongLongRowSplits.

private static Vector combineServerLongLongRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
    long colNum = matrixMeta.getColNum();
    int elemNum = 0;
    int size = rowSplits.size();
    for (int i = 0; i < size; i++) {
        elemNum += rowSplits.get(i).size();
    }
    LongLongVector row = VFactory.sparseLongKeyLongVector(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();
        }
        ((ServerLongLongRow) rowSplits.get(i)).mergeTo(row);
    }
    row.setClock(clock);
    return row;
}
Also used : ServerLongLongRow(com.tencent.angel.ps.storage.vector.ServerLongLongRow) LongLongVector(com.tencent.angel.ml.math2.vector.LongLongVector)

Example 4 with ServerLongLongRow

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

the class InitNumNeighborEdgesFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    PartInitNumNeighborEdgesParam param = (PartInitNumNeighborEdgesParam) partParam;
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    RowBasedPartition part = (RowBasedPartition) matrix.getPartition(partParam.getPartKey().getPartitionId());
    ServerLongLongRow row = (ServerLongLongRow) part.getRow(0);
    ObjectIterator<Long2LongMap.Entry> iter = param.getNodeIdToNumEdges().long2LongEntrySet().iterator();
    row.startWrite();
    try {
        while (iter.hasNext()) {
            Long2LongMap.Entry entry = iter.next();
            row.set(entry.getLongKey(), entry.getLongValue());
        }
    } finally {
        row.endWrite();
    }
}
Also used : Long2LongMap(it.unimi.dsi.fastutil.longs.Long2LongMap) ServerLongLongRow(com.tencent.angel.ps.storage.vector.ServerLongLongRow) ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition)

Aggregations

ServerLongLongRow (com.tencent.angel.ps.storage.vector.ServerLongLongRow)4 LongLongVector (com.tencent.angel.ml.math2.vector.LongLongVector)2 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)2 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)2 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)1 Long2LongMap (it.unimi.dsi.fastutil.longs.Long2LongMap)1