Search in sources :

Example 16 with GraphNode

use of com.tencent.angel.graph.data.GraphNode in project angel by Tencent.

the class InitNodeTypes method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    GeneralPartUpdateParam param = (GeneralPartUpdateParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
    ILongKeyAnyValuePartOp keyValuePart = (ILongKeyAnyValuePartOp) param.getKeyValuePart();
    long[] nodeIds = keyValuePart.getKeys();
    IElement[] neighbors = keyValuePart.getValues();
    row.startWrite();
    try {
        for (int i = 0; i < nodeIds.length; i++) {
            GraphNode graphNode = (GraphNode) row.get(nodeIds[i]);
            if (graphNode == null) {
                graphNode = new GraphNode();
                row.set(nodeIds[i], graphNode);
            }
            graphNode.setTypes(((NodeType) neighbors[i]).getTypes());
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) GeneralPartUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam) GraphNode(com.tencent.angel.graph.data.GraphNode) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyAnyValuePartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)

Aggregations

GraphNode (com.tencent.angel.graph.data.GraphNode)16 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)11 GeneralPartUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam)7 IElement (com.tencent.angel.ps.storage.vector.element.IElement)7 ILongKeyAnyValuePartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)7 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)5 Random (java.util.Random)4 LongElementStorage (com.tencent.angel.ps.storage.vector.storage.LongElementStorage)3 Tuple2 (scala.Tuple2)3 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)1 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)1 Entry (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry)1 LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)1 Tuple3 (scala.Tuple3)1