Search in sources :

Example 6 with PartGeneralGetResult

use of com.tencent.angel.graph.model.general.get.PartGeneralGetResult in project angel by Tencent.

the class GetByteNeighbor 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[] data = partResult.getData();
        for (int i = 0; i < nodeIds.length; i++) {
            if (data[i] != null) {
                byte[] serializedNeighbors = ((ByteArrayElement) data[i]).getData();
                if (serializedNeighbors.length > 0) {
                    nodeIdToNeighbors.put(nodeIds[i], ScalaKryoInstantiator.defaultPool().fromBytes(serializedNeighbors, long[].class));
                } else {
                    nodeIdToNeighbors.put(nodeIds[i], emptyLongs);
                }
            } else {
                nodeIdToNeighbors.put(nodeIds[i], 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) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) ByteArrayElement(com.tencent.angel.ps.storage.vector.element.ByteArrayElement) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) GetLongsResult(com.tencent.angel.graph.common.psf.result.GetLongsResult)

Aggregations

PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)6 IElement (com.tencent.angel.ps.storage.vector.element.IElement)6 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)5 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)5 GetLongsResult (com.tencent.angel.graph.common.psf.result.GetLongsResult)3 AngelException (com.tencent.angel.exception.AngelException)1 GetFloatsResult (com.tencent.angel.graph.common.psf.result.GetFloatsResult)1 DynamicNeighborElement (com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement)1 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)1 GeneralPartGetParam (com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam)1 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)1 ByteArrayElement (com.tencent.angel.ps.storage.vector.element.ByteArrayElement)1 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)1 ILongKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)1 Tuple3 (scala.Tuple3)1