Search in sources :

Example 1 with IndexPartGetLongResult

use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam param) {
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0);
    ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.iterator();
    LongArrayList nodes = new LongArrayList();
    long start = param.getPartKey().getStartCol();
    while (it.hasNext()) {
        Long2ObjectMap.Entry entry = it.next();
        Node node = (Node) entry.getValue();
        if (node.getFeats() != null && node.getNeighbors() == null) {
            nodes.add(entry.getLongKey() + start);
        }
    }
    return new IndexPartGetLongResult(param.getPartKey(), nodes.toLongArray());
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) Node(com.tencent.angel.graph.data.Node) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 2 with IndexPartGetLongResult

use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam param) {
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
    ObjectIterator<Entry<IElement>> it = row.iterator();
    LongArrayList nodes = new LongArrayList();
    Boolean isHash = ((PartGetNodesParam) param).getHash();
    long start = isHash ? 0 : param.getPartKey().getStartCol();
    while (it.hasNext()) {
        Long2ObjectMap.Entry entry = it.next();
        GraphNode node = (GraphNode) entry.getValue();
        if (node.getFeats() != null && node.getNeighbors() == null) {
            nodes.add(entry.getLongKey() + start);
        }
    }
    return new IndexPartGetLongResult(param.getPartKey(), nodes.toLongArray());
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) Entry(it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Entry(it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) GraphNode(com.tencent.angel.graph.data.GraphNode) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 3 with IndexPartGetLongResult

use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
    ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 0);
    LongArrayList ret = new LongArrayList();
    row.startRead();
    try {
        ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.iterator();
        while (it.hasNext()) {
            Long2ObjectMap.Entry<IElement> entry = it.next();
            ret.add(entry.getLongKey() + partParam.getPartKey().getStartCol());
        }
    } finally {
        row.endRead();
    }
    return new IndexPartGetLongResult(part.getPartitionKey(), ret.toLongArray());
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) IElement(com.tencent.angel.ps.storage.vector.element.IElement) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Example 4 with IndexPartGetLongResult

use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.

the class GetNodes method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
    ServerRow ranks = psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 2);
    FloatVector ranksVector = ServerRowUtils.getVector((ServerLongFloatRow) ranks);
    long[] ret;
    if (ranksVector instanceof IntFloatVector)
        ret = gatherNodes((IntFloatVector) ranksVector, part.getPartitionKey().getStartCol());
    else if (ranksVector instanceof LongFloatVector)
        ret = gatherNodes((LongFloatVector) ranksVector, part.getPartitionKey().getStartCol());
    else {
        throw new AngelException("vector should be intfloat or longfloat but is " + ranksVector.getClass().getName());
    }
    return new IndexPartGetLongResult(part.getPartitionKey(), ret);
}
Also used : AngelException(com.tencent.angel.exception.AngelException) IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector) FloatVector(com.tencent.angel.ml.math2.vector.FloatVector) LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Example 5 with IndexPartGetLongResult

use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult 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)

Aggregations

IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)6 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)3 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)3 LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)3 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)2 GetRowResult (com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult)2 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)2 AngelException (com.tencent.angel.exception.AngelException)1 GraphNode (com.tencent.angel.graph.data.GraphNode)1 Node (com.tencent.angel.graph.data.Node)1 FloatVector (com.tencent.angel.ml.math2.vector.FloatVector)1 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)1 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)1 IElement (com.tencent.angel.ps.storage.vector.element.IElement)1 Entry (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry)1