Search in sources :

Example 21 with ServerLongAnyRow

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

the class InitDynamicNbrs method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    GeneralPartUpdateParam initParam = (GeneralPartUpdateParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, initParam);
    // Get nodes and features
    ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) initParam.getKeyValuePart();
    long[] nodeIds = split.getKeys();
    IElement[] neighbors = split.getValues();
    row.startWrite();
    try {
        for (int i = 0; i < nodeIds.length; i++) {
            LongArrayElement data = (LongArrayElement) neighbors[i];
            DynamicNeighborElement ele = (DynamicNeighborElement) row.get(nodeIds[i]);
            if (ele == null) {
                ele = new DynamicNeighborElement();
                ele.add(data.getData());
                row.set(nodeIds[i], ele);
            } else {
                ele.add(data.getData());
            }
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) GeneralPartUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam) DynamicNeighborElement(com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement) LongArrayElement(com.tencent.angel.ps.storage.vector.element.LongArrayElement) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyAnyValuePartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)

Example 22 with ServerLongAnyRow

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

the class Sample method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    PartSampleParam param = (PartSampleParam) partParam;
    KeyPart keyPart = param.getIndicesPart();
    int sampleType = param.getSampleType();
    long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
    Long2IntOpenHashMap nodeIdToSizes = new Long2IntOpenHashMap(nodeIds.length);
    for (int i = 0; i < nodeIds.length; i++) {
        nodeIdToSizes.addTo(nodeIds[i], 1);
    }
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
    Random r = new Random();
    long[] distinctNodeIds = new long[nodeIdToSizes.size()];
    long[][] samples = new long[nodeIdToSizes.size()][];
    ObjectIterator<Entry> iter = nodeIdToSizes.long2IntEntrySet().fastIterator();
    int index = 0;
    while (iter.hasNext()) {
        Entry entry = iter.next();
        distinctNodeIds[index] = entry.getLongKey();
        TypeNeighborElement element = (TypeNeighborElement) row.get(distinctNodeIds[index]);
        samples[index] = element.Sample(sampleType, r, distinctNodeIds[index], entry.getIntValue());
        index++;
    }
    return new PartGetLongsResult(distinctNodeIds, samples);
}
Also used : Long2IntOpenHashMap(it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp) TypeNeighborElement(com.tencent.angel.graph.model.neighbor.simplewithtype.TypeNeighborElement) Entry(it.unimi.dsi.fastutil.longs.Long2IntMap.Entry) Random(java.util.Random) PartGetLongsResult(com.tencent.angel.graph.common.psf.result.PartGetLongsResult)

Example 23 with ServerLongAnyRow

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

the class NnzFeature 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.getFeats() != 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)

Example 24 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, PartitionGetParam 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 25 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, GeneralPartGetParam 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)

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