Search in sources :

Example 46 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class SampleNeighbor method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
    for (PartitionGetResult result : partResults) {
        partIdToResultMap.put(((PartSampleNeighborResult) result).getPartId(), result);
    }
    SampleNeighborParam param = (SampleNeighborParam) getParam();
    long[] nodeIds = param.getNodeIds();
    List<PartitionGetParam> partParams = param.getPartParams();
    Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
    for (PartitionGetParam partParam : partParams) {
        int start = ((PartSampleNeighborParam) partParam).getStartIndex();
        int end = ((PartSampleNeighborParam) partParam).getEndIndex();
        PartSampleNeighborResult partResult = (PartSampleNeighborResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
        long[][] results = partResult.getNodeIdToNeighbors();
        for (int i = start; i < end; i++) {
            nodeIdToNeighbors.put(nodeIds[i], results[i - start]);
        }
    }
    return new SampleNeighborResult(nodeIdToNeighbors);
}
Also used : Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 47 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class SampleNeighbor method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
    for (PartitionGetResult result : partResults) {
        partIdToResultMap.put(((PartSampleNeighborResult) result).getPartId(), result);
    }
    SampleNeighborParam param = (SampleNeighborParam) getParam();
    long[] nodeIds = param.getNodeIds();
    List<PartitionGetParam> partParams = param.getPartParams();
    Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
    for (PartitionGetParam partParam : partParams) {
        int start = ((PartSampleNeighborParam) partParam).getStartIndex();
        int end = ((PartSampleNeighborParam) partParam).getEndIndex();
        PartSampleNeighborResult partResult = (PartSampleNeighborResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
        long[][] results = partResult.getNodeIdToNeighbors();
        for (int i = start; i < end; i++) {
            nodeIdToNeighbors.put(nodeIds[i], results[i - start]);
        }
    }
    return new SampleNeighborResult(nodeIdToNeighbors);
}
Also used : Int2ObjectArrayMap(it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 48 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class SampleNeighbor method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    Long2ObjectOpenHashMap<long[]> nodeIdToSampleNeighbors = new Long2ObjectOpenHashMap<>(((SampleNeighborParam) param).getNodeIds().length);
    for (PartitionGetResult partResult : partResults) {
        // Sample part result
        PartSampleNeighborResult partSampleResult = (PartSampleNeighborResult) partResult;
        // Neighbors
        Long2ObjectOpenHashMap<long[]> partNodeIdToSampleNeighbors = partSampleResult.getNodeIdToSampleNeighbors();
        if (partNodeIdToSampleNeighbors != null) {
            nodeIdToSampleNeighbors.putAll(partNodeIdToSampleNeighbors);
        }
    }
    return new SampleNeighborResult(nodeIdToSampleNeighbors);
}
Also used : Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 49 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class GetNodes method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int size = 0;
    for (PartitionGetResult result : partResults) {
        if (result instanceof IndexPartGetLongResult) {
            size += ((IndexPartGetLongResult) result).getValues().length;
        }
    }
    long[] values = new long[size];
    int start = 0;
    for (PartitionGetResult result : partResults) {
        if (result instanceof IndexPartGetLongResult) {
            long[] vals = ((IndexPartGetLongResult) result).getValues();
            System.arraycopy(vals, 0, values, start, vals.length);
            start += vals.length;
        }
    }
    return new GetRowResult(ResponseType.SUCCESS, VFactory.denseLongVector(values));
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) GetRowResult(com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 50 with PartitionGetResult

use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.

the class GetProgress method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    GetProgressResult result = new GetProgressResult(true, 0.0);
    boolean isFinished = true;
    double percent = 0.0;
    for (PartitionGetResult partResult : partResults) {
        GetProgressPartitionResult part = (GetProgressPartitionResult) partResult;
        isFinished = isFinished && part.isFinished();
        percent += part.getPrecent();
    }
    percent /= partResults.size();
    result.setFinished(isFinished);
    result.setPrecent(percent);
    return result;
}
Also used : PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Aggregations

PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)60 PartitionKey (com.tencent.angel.PartitionKey)24 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)18 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)12 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)6 IElement (com.tencent.angel.ps.storage.vector.element.IElement)6 Int2ObjectArrayMap (it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap)6 GetLongsResult (com.tencent.angel.graph.common.psf.result.GetLongsResult)5 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)5 AngelException (com.tencent.angel.exception.AngelException)2 GetFunc (com.tencent.angel.ml.matrix.psf.get.base.GetFunc)2 GetRowResult (com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult)2 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)2 GetUDFRequest (com.tencent.angel.ps.server.data.request.GetUDFRequest)2 Request (com.tencent.angel.ps.server.data.request.Request)2 GetUDFResponse (com.tencent.angel.ps.server.data.response.GetUDFResponse)2 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)2 UserRequest (com.tencent.angel.psagent.matrix.transport.adapter.UserRequest)2 Tuple3 (scala.Tuple3)2 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)1