Search in sources :

Example 6 with GeneralPartGetParam

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

the class IntKeysGetParam method split.

@Override
public List<PartitionGetParam> split() {
    // Get matrix meta
    MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    PartitionKey[] parts = meta.getPartitionKeys();
    // Split
    KeyPart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, false);
    // Generate Part psf get param
    List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
    assert parts.length == nodeIdsParts.length;
    for (int i = 0; i < parts.length; i++) {
        if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
            partParams.add(new GeneralPartGetParam(matrixId, parts[i], nodeIdsParts[i]));
        }
    }
    return partParams;
}
Also used : GeneralPartGetParam(com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam) MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 7 with GeneralPartGetParam

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

the class GetNodeAttrsParam method split.

@Override
public List<PartitionGetParam> split() {
    // Get matrix meta
    MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
    PartitionKey[] parts = meta.getPartitionKeys();
    // Split
    KeyPart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, false);
    // Generate Part psf get param
    List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
    assert parts.length == nodeIdsParts.length;
    for (int i = 0; i < parts.length; i++) {
        if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
            partParams.add(new GeneralPartGetParam(matrixId, parts[i], nodeIdsParts[i]));
        }
    }
    return partParams;
}
Also used : GeneralPartGetParam(com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam) MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 8 with GeneralPartGetParam

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

the class GetNodeFeats method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    GeneralPartGetParam param = (GeneralPartGetParam) partParam;
    KeyPart keyPart = param.getIndicesPart();
    switch(keyPart.getKeyType()) {
        case LONG:
            {
                // Long type node id
                long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
                ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
                Long2ObjectOpenHashMap<IntFloatVector> nodeIdToFeats = new Long2ObjectOpenHashMap<>(nodeIds.length);
                for (long nodeId : nodeIds) {
                    if (row.get(nodeId) == null) {
                        // If node not exist, just skip
                        continue;
                    }
                    IntFloatVector feat = ((GraphNode) (row.get(nodeId))).getFeats();
                    if (feat != null) {
                        nodeIdToFeats.put(nodeId, feat);
                    }
                }
                return new PartGetNodeFeatsResult(param.getPartKey().getPartitionId(), nodeIdToFeats);
            }
        default:
            {
                // TODO: support String, Int, and Any type node id
                throw new InvalidParameterException("Unsupport index type " + keyPart.getKeyType());
            }
    }
}
Also used : InvalidParameterException(com.tencent.angel.exception.InvalidParameterException) GeneralPartGetParam(com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector)

Aggregations

GeneralPartGetParam (com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam)8 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)8 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)5 PartitionKey (com.tencent.angel.PartitionKey)4 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)4 ArrayList (java.util.ArrayList)4 InvalidParameterException (com.tencent.angel.exception.InvalidParameterException)3 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)3 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)2 AngelException (com.tencent.angel.exception.AngelException)1 PartGetIntArrayAttrsResult (com.tencent.angel.graph.client.psf.get.utils.PartGetIntArrayAttrsResult)1 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)1 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 ServerLongFloatRow (com.tencent.angel.ps.storage.vector.ServerLongFloatRow)1 IElement (com.tencent.angel.ps.storage.vector.element.IElement)1 ILongKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)1 FloatArrayList (it.unimi.dsi.fastutil.floats.FloatArrayList)1 LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)1