Search in sources :

Example 46 with ServerLongAnyRow

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

the class GraphMatrixUtils method getPSLongKeyRow.

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

Example 47 with ServerLongAnyRow

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

the class PushNeighbor method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    PushNeighborPartitionParam pparam = (PushNeighborPartitionParam) partParam;
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(pparam.getPartKey(), 0);
    Long2ObjectOpenHashMap<long[]> nodeIdToNeighborIndices = pparam.getNodeIdToNeighborIndices();
    ObjectIterator<Long2ObjectMap.Entry<long[]>> iter = nodeIdToNeighborIndices.long2ObjectEntrySet().iterator();
    row.startWrite();
    try {
        while (iter.hasNext()) {
            Long2ObjectMap.Entry<long[]> entry = iter.next();
            row.set(entry.getLongKey(), new LongArrayElement(entry.getValue()));
        }
    } finally {
        row.endWrite();
    }
}
Also used : Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) LongArrayElement(com.tencent.angel.ps.storage.vector.element.LongArrayElement) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 48 with ServerLongAnyRow

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

the class InitNodeFeats method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    InitNodeFeatsPartParam param = (InitNodeFeatsPartParam) partParam;
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0);
    long[] nodeIds = param.getNodeIds();
    IntFloatVector[] feats = param.getFeats();
    row.startWrite();
    try {
        for (int i = 0; i < nodeIds.length; i++) {
            Node node = (Node) row.get(nodeIds[i]);
            if (node == null) {
                node = new Node();
                row.set(nodeIds[i], node);
            }
            node.setFeats(feats[i]);
        }
    } finally {
        row.endWrite();
    }
}
Also used : Node(com.tencent.angel.graph.data.Node) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 49 with ServerLongAnyRow

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

the class PullMaxDegree method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 0);
    int partResult = Integer.MIN_VALUE;
    ObjectIterator<Long2ObjectMap.Entry<IElement>> iter = row.iterator();
    while (iter.hasNext()) {
        Long2ObjectMap.Entry<IElement> entry = iter.next();
        LongArrayElement value = (LongArrayElement) entry.getValue();
        int length = value.getData().length;
        if (length > partResult) {
            partResult = length;
        }
    }
    return new PullMaxDegreePartitionResult(partResult);
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) LongArrayElement(com.tencent.angel.ps.storage.vector.element.LongArrayElement) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 50 with ServerLongAnyRow

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

the class PushPathTail method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    PushPathTailPartitionParam pparam = (PushPathTailPartitionParam) partParam;
    PartitionKey partKey = pparam.getPartKey();
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(pparam.getPartKey(), 0);
    Long2LongOpenHashMap pathTail = pparam.getPathTail();
    PathQueue.pushBatch(partKey.getPartitionId(), row, pathTail);
// int completeCount = 0;
// ArrayList<WalkPath> paths = new ArrayList<>(pathTail.size());
// 
// row.startWrite();
// try {
// ObjectIterator<Map.Entry<Long, Long>> iter = pathTail.entrySet().iterator();
// while (iter.hasNext()) {
// Map.Entry<Long, Long> entry = iter.next();
// long key = entry.getKey();
// long tail = entry.getValue();
// 
// WalkPath wPath = (WalkPath) row.get(key);
// wPath.add2Path(tail);
// 
// if (wPath.isComplete()) {
// completeCount += 1;
// } else {
// paths.add(wPath);
// }
// }
// } finally {
// row.endWrite();
// }
// 
// if (completeCount != 0) {
// PathQueue.progress(partKey.getPartitionId(), completeCount);
// }
// 
// if (!paths.isEmpty()) {
// PathQueue.pushBatch(partKey.getPartitionId(), paths);
// }
}
Also used : Long2LongOpenHashMap(it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap) PartitionKey(com.tencent.angel.PartitionKey) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Aggregations

ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)69 IElement (com.tencent.angel.ps.storage.vector.element.IElement)19 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)15 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)15 ILongKeyAnyValuePartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)13 GeneralPartUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam)12 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)12 GraphNode (com.tencent.angel.graph.data.GraphNode)11 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)11 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)11 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)9 ILongKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)9 Random (java.util.Random)9 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)8 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)8 InvalidParameterException (com.tencent.angel.exception.InvalidParameterException)7 Node (com.tencent.angel.graph.data.Node)7 LongElementStorage (com.tencent.angel.ps.storage.vector.storage.LongElementStorage)6 GeneralPartGetParam (com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam)3 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)3