Search in sources :

Example 6 with Node

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

the class InitNeighbor method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    InitNeighborPartParam param = (InitNeighborPartParam) partParam;
    ServerLongAnyRow row = (ServerLongAnyRow) (psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0));
    long[] keys = param.getKeys();
    long[][] neighborArrays = param.getNeighborArrays();
    int[][] edgeTypes = param.getEdgeTypeArrays();
    int[][] neighborTypes = param.getDstTypeArrays();
    row.startWrite();
    try {
        for (int i = 0; i < keys.length; i++) {
            Node node = (Node) row.get(keys[i]);
            if (node == null) {
                node = new Node();
                row.set(keys[i], node);
            }
            node.setNeighbors(neighborArrays[i]);
            if (edgeTypes != null)
                node.setEdgeTypes(edgeTypes[i]);
            if (neighborTypes != null)
                node.setTypes(neighborTypes[i]);
        }
    } finally {
        row.endWrite();
    }
}
Also used : Node(com.tencent.angel.graph.data.Node) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 7 with Node

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

the class SampleNeighborPartResult method bufferLen.

@Override
public int bufferLen() {
    int len = 4 + 4 + 4 + ByteBufSerdeUtils.serializedBooleanLen(sampleTypes);
    for (int i = 0; i < keys.length; i++) {
        Node node = (Node) row.get(keys[i]);
        if (node == null) {
            len += 4;
            continue;
        }
        long[] neighbor = node.getNeighbors();
        if (neighbor == null || neighbor.length == 0) {
            len += 4;
            continue;
        }
        int size = numSample;
        if (numSample <= 0 || numSample >= neighbor.length) {
            size = neighbor.length;
        }
        len += 4;
        if (sampleTypes) {
            for (int j = 0; j < size; j++) {
                len += 8 + 4;
            }
        } else {
            for (int j = 0; j < size; j++) {
                len += 8;
            }
        }
    }
    return len;
}
Also used : Node(com.tencent.angel.graph.data.Node)

Example 8 with Node

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

the class NnzEdge method processRow.

@Override
public double processRow(ServerRow row) {
    LongElementStorage storage = ((ServerLongAnyRow) row).getStorage();
    ObjectIterator<Long2ObjectMap.Entry<IElement>> it = storage.iterator();
    long size = 0;
    while (it.hasNext()) {
        Node node = (Node) (it.next().getValue());
        if (node.getNeighbors() != null) {
            size += node.getNeighbors().length;
        }
    }
    return size;
}
Also used : Node(com.tencent.angel.graph.data.Node) LongElementStorage(com.tencent.angel.ps.storage.vector.storage.LongElementStorage) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 9 with Node

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

the class NnzNeighbor method processRow.

@Override
public double processRow(ServerRow row) {
    LongElementStorage storage = ((ServerLongAnyRow) row).getStorage();
    ObjectIterator<Long2ObjectMap.Entry<IElement>> it = storage.iterator();
    int size = 0;
    while (it.hasNext()) {
        Node node = (Node) (it.next().getValue());
        if (node.getNeighbors() != null) {
            size++;
        }
    }
    return size;
}
Also used : Node(com.tencent.angel.graph.data.Node) LongElementStorage(com.tencent.angel.ps.storage.vector.storage.LongElementStorage) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Aggregations

Node (com.tencent.angel.graph.data.Node)9 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)7 LongElementStorage (com.tencent.angel.ps.storage.vector.storage.LongElementStorage)3 Random (java.util.Random)2 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)1 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)1 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)1 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)1 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)1 LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)1