Search in sources :

Example 1 with DynamicNeighborElement

use of com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement 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 2 with DynamicNeighborElement

use of com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement in project angel by Tencent.

the class GetSort method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
    RowBasedPartition part = (RowBasedPartition) matrix.getPartition(partParam.getPartKey().getPartitionId());
    ServerLongAnyRow row = (ServerLongAnyRow) part.getRow(0);
    ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.getStorage().iterator();
    row.startWrite();
    try {
        while (it.hasNext()) {
            Long2ObjectMap.Entry<IElement> next = it.next();
            DynamicNeighborElement ele = (DynamicNeighborElement) next.getValue();
            if (ele != null) {
                ele.trans();
            }
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) ServerMatrix(com.tencent.angel.ps.storage.matrix.ServerMatrix) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) DynamicNeighborElement(com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 3 with DynamicNeighborElement

use of com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement in project angel by Tencent.

the class GetNeighbor method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int resultSize = 0;
    for (PartitionGetResult result : partResults) {
        resultSize += ((PartGeneralGetResult) result).getNodeIds().length;
    }
    Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(resultSize);
    for (PartitionGetResult result : partResults) {
        PartGeneralGetResult partResult = (PartGeneralGetResult) result;
        long[] nodeIds = partResult.getNodeIds();
        IElement[] neighbors = partResult.getData();
        for (int i = 0; i < nodeIds.length; i++) {
            if (neighbors[i] != null) {
                byte[] nbrs = ((DynamicNeighborElement) neighbors[i]).getData();
                nodeIdToNeighbors.put(nodeIds[i], ScalaKryoInstantiator.defaultPool().fromBytes(nbrs, long[].class));
            } else {
                nodeIdToNeighbors.put(nodeIds[i], Constents.emptyLongs);
            }
        }
    }
    return new GetLongsResult(nodeIdToNeighbors);
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) PartGeneralGetResult(com.tencent.angel.graph.model.general.get.PartGeneralGetResult) DynamicNeighborElement(com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) GetLongsResult(com.tencent.angel.graph.common.psf.result.GetLongsResult)

Aggregations

DynamicNeighborElement (com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement)3 IElement (com.tencent.angel.ps.storage.vector.element.IElement)3 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)2 GetLongsResult (com.tencent.angel.graph.common.psf.result.GetLongsResult)1 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)1 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)1 GeneralPartUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam)1 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)1 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)1 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)1 ILongKeyAnyValuePartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)1 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1