Search in sources :

Example 1 with GetLongsResult

use of com.tencent.angel.graph.common.psf.result.GetLongsResult in project angel by Tencent.

the class GetNeighborsWithCount method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int resultSize = 0;
    for (PartitionGetResult result : partResults) {
        resultSize += ((PartGetNeighborWithCountResult) result).getNodeIds().length;
    }
    Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(resultSize);
    for (PartitionGetResult result : partResults) {
        PartGetNeighborWithCountResult getResult = (PartGetNeighborWithCountResult) result;
        long[] nodeIds = getResult.getNodeIds();
        long[][] objs = getResult.getData();
        for (int i = 0; i < nodeIds.length; i++) {
            nodeIdToNeighbors.put(nodeIds[i], objs[i]);
        }
    }
    return new GetLongsResult(nodeIdToNeighbors);
}
Also used : 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)

Example 2 with GetLongsResult

use of com.tencent.angel.graph.common.psf.result.GetLongsResult 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)

Example 3 with GetLongsResult

use of com.tencent.angel.graph.common.psf.result.GetLongsResult in project angel by Tencent.

the class GetLongNeighbor 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) {
                nodeIdToNeighbors.put(nodeIds[i], ((LongArrayElement) neighbors[i]).getData());
            } 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) 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)

Example 4 with GetLongsResult

use of com.tencent.angel.graph.common.psf.result.GetLongsResult in project angel by Tencent.

the class Sample method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int resultSize = 0;
    for (PartitionGetResult result : partResults) {
        resultSize += ((PartGetLongsResult) result).getData().length;
    }
    Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(resultSize);
    for (PartitionGetResult result : partResults) {
        PartGetLongsResult partResult = (PartGetLongsResult) result;
        long[] nodeIds = partResult.getNodeIds();
        long[][] samples = partResult.getData();
        for (int i = 0; i < nodeIds.length; i++) {
            nodeIdToNeighbors.put(nodeIds[i], samples[i]);
        }
    }
    return new GetLongsResult(nodeIdToNeighbors);
}
Also used : PartGetLongsResult(com.tencent.angel.graph.common.psf.result.PartGetLongsResult) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult) PartGetLongsResult(com.tencent.angel.graph.common.psf.result.PartGetLongsResult) GetLongsResult(com.tencent.angel.graph.common.psf.result.GetLongsResult)

Example 5 with GetLongsResult

use of com.tencent.angel.graph.common.psf.result.GetLongsResult 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

GetLongsResult (com.tencent.angel.graph.common.psf.result.GetLongsResult)5 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)5 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)5 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)3 IElement (com.tencent.angel.ps.storage.vector.element.IElement)3 PartGetLongsResult (com.tencent.angel.graph.common.psf.result.PartGetLongsResult)1 DynamicNeighborElement (com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement)1 ByteArrayElement (com.tencent.angel.ps.storage.vector.element.ByteArrayElement)1