Search in sources :

Example 1 with GetFloatsResult

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

the class GetNodeAttrs method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int resultSize = 0;
    for (PartitionGetResult result : partResults) {
        resultSize += ((PartGeneralGetResult) result).getNodeIds().length;
    }
    Long2ObjectOpenHashMap<float[]> nodeIdToAttrs = new Long2ObjectOpenHashMap<>(resultSize);
    for (PartitionGetResult result : partResults) {
        PartGeneralGetResult partResult = (PartGeneralGetResult) result;
        long[] nodeIds = partResult.getNodeIds();
        IElement[] attrs = partResult.getData();
        for (int i = 0; i < nodeIds.length; i++) {
            if (attrs[i] != null) {
                nodeIdToAttrs.put(nodeIds[i], ((FloatArrayElement) attrs[i]).getData());
            } else {
                nodeIdToAttrs.put(nodeIds[i], emptyFloats);
            }
        }
    }
    return new GetFloatsResult(nodeIdToAttrs);
}
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) GetFloatsResult(com.tencent.angel.graph.common.psf.result.GetFloatsResult) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Aggregations

GetFloatsResult (com.tencent.angel.graph.common.psf.result.GetFloatsResult)1 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)1 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)1 IElement (com.tencent.angel.ps.storage.vector.element.IElement)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1