Search in sources :

Example 1 with ServerLongIntRow

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

the class RowSplitCombineUtils method combineServerLongIntRowSplits.

private static Vector combineServerLongIntRowSplits(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();
    }
    LongIntVector row = VFactory.sparseLongKeyIntVector(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();
        }
        ((ServerLongIntRow) rowSplits.get(i)).mergeTo(row);
    }
    row.setClock(clock);
    return row;
}
Also used : LongIntVector(com.tencent.angel.ml.math2.vector.LongIntVector) ServerLongIntRow(com.tencent.angel.ps.storage.vector.ServerLongIntRow)

Example 2 with ServerLongIntRow

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

the class GetOutDegreeFunc method partitionGet.

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

Example 3 with ServerLongIntRow

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

the class MergeUtils method combineServerLongIntRowSplits.

private static Vector combineServerLongIntRowSplits(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();
    }
    LongIntVector row = VFactory.sparseLongKeyIntVector(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;
        }
        ((ServerLongIntRow) rowSplits.get(i)).mergeTo(row);
    }
    return row;
}
Also used : LongIntVector(com.tencent.angel.ml.math2.vector.LongIntVector) ServerLongIntRow(com.tencent.angel.ps.storage.vector.ServerLongIntRow)

Example 4 with ServerLongIntRow

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

the class GraphMatrixUtils method getPSLongKeyIntRow.

public static ServerLongIntRow getPSLongKeyIntRow(PSContext psContext, PartitionGetParam partParam, int rowId) {
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
    return (ServerLongIntRow) (((RowBasedPartition) part).getRow(rowId));
}
Also used : ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition) ServerLongIntRow(com.tencent.angel.ps.storage.vector.ServerLongIntRow)

Example 5 with ServerLongIntRow

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

the class ReadTag method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    GeneralPartGetParam param = (GeneralPartGetParam) partParam;
    KeyPart keyPart = param.getIndicesPart();
    long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
    ServerLongIntRow row = GraphMatrixUtils.getPSLongKeyIntRow(psContext, param, param.getRowId());
    DynamicLongArray nodes = new DynamicLongArray(nodeIds.length);
    for (int i = 0; i < nodeIds.length; i++) {
        long nodeId = nodeIds[i];
        if (row.get(nodeId) > 0) {
            nodes.add(nodeId);
        }
    }
    return new PartReadTagResult(nodes.getData());
}
Also used : DynamicLongArray(com.tencent.angel.common.collections.DynamicLongArray) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp) ServerLongIntRow(com.tencent.angel.ps.storage.vector.ServerLongIntRow)

Aggregations

ServerLongIntRow (com.tencent.angel.ps.storage.vector.ServerLongIntRow)6 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)3 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)3 LongIntVector (com.tencent.angel.ml.math2.vector.LongIntVector)2 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)2 DynamicLongArray (com.tencent.angel.common.collections.DynamicLongArray)1 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)1 ILongKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)1 Long2IntMap (it.unimi.dsi.fastutil.longs.Long2IntMap)1