Search in sources :

Example 6 with ILongKeyPartOp

use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.

the class GeneralGetUtils method partitionGet.

public static PartitionGetResult partitionGet(PSContext psContext, PartitionGetParam partParam) {
    GeneralPartGetParam param = (GeneralPartGetParam) partParam;
    KeyPart keyPart = param.getIndicesPart();
    // Long type node id
    long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
    // Get data
    IElement[] data = new IElement[nodeIds.length];
    for (int i = 0; i < nodeIds.length; i++) {
        data[i] = row.get(nodeIds[i]);
    }
    MatrixMeta meta = psContext.getMatrixMetaManager().getMatrixMeta(param.getMatrixId());
    try {
        return new PartGeneralGetResult(meta.getValueClass(), nodeIds, data);
    } catch (ClassNotFoundException e) {
        throw new AngelException("Can not get value class ");
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) GeneralPartGetParam(com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam) IElement(com.tencent.angel.ps.storage.vector.element.IElement) PartGeneralGetResult(com.tencent.angel.graph.model.general.get.PartGeneralGetResult) MatrixMeta(com.tencent.angel.ml.matrix.MatrixMeta) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)

Example 7 with ILongKeyPartOp

use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.

the class SampleNeighbor method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    PartSampleNeighborParam sampleParam = (PartSampleNeighborParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, partParam);
    ILongKeyPartOp split = (ILongKeyPartOp) sampleParam.getIndicesPart();
    long[] nodeIds = split.getKeys();
    Long2ObjectOpenHashMap<long[]> nodeId2SampleNeighbors = SampleUtils.sampleByCount(row, sampleParam.getCount(), nodeIds, System.currentTimeMillis());
    return new PartSampleNeighborResult(sampleParam.getPartKey().getPartitionId(), nodeId2SampleNeighbors);
}
Also used : ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)

Example 8 with ILongKeyPartOp

use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.

the class SampleEdgeFeat method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    PartSampleEdgeFeatParam sampleParam = (PartSampleEdgeFeatParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, partParam);
    ILongKeyPartOp split = (ILongKeyPartOp) sampleParam.getIndicesPart();
    long[] nodeIds = split.getKeys();
    Tuple2<Long2ObjectOpenHashMap<long[]>, Long2ObjectOpenHashMap<IntFloatVector[]>> nodeId2SampleNeighbors = SampleUtils.sampleEdgeFeat(row, sampleParam.getCount(), nodeIds, System.currentTimeMillis());
    return new PartSampleEdgeFeatResult(sampleParam.getPartKey().getPartitionId(), nodeId2SampleNeighbors._1, nodeId2SampleNeighbors._2);
}
Also used : Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)

Example 9 with ILongKeyPartOp

use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.

the class ReadTag method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    GeneralPartGetParam param = (GeneralPartGetParam) partParam;
    KeyPart keyPart = param.getIndicesPart();
    long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
    ServerLongIntRow row = GraphMatrixUtils.getPSLongKeyIntRow(psContext, param, param.getRowId());
    DynamicLongArray nodes = new DynamicLongArray(nodeIds.length);
    for (int i = 0; i < nodeIds.length; i++) {
        long nodeId = nodeIds[i];
        if (row.get(nodeId) > 0) {
            nodes.add(nodeId);
        }
    }
    return new PartReadTagResult(nodes.getData());
}
Also used : DynamicLongArray(com.tencent.angel.common.collections.DynamicLongArray) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp) ServerLongIntRow(com.tencent.angel.ps.storage.vector.ServerLongIntRow)

Example 10 with ILongKeyPartOp

use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.

the class GetCloseness method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    GetHyperLogLogPartParam param = (GetHyperLogLogPartParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
    ILongKeyPartOp keyPart = (ILongKeyPartOp) param.getNodes();
    long[] nodes = keyPart.getKeys();
    long n = param.getN();
    Long2DoubleOpenHashMap closenesses = new Long2DoubleOpenHashMap();
    for (int i = 0; i < nodes.length; i++) {
        HyperLogLogPlusElement hllElem = (HyperLogLogPlusElement) row.get(nodes[i]);
        if (hllElem.getCloseness() < n - 1) {
            closenesses.put(nodes[i], 0);
        } else {
            closenesses.put(nodes[i], (double) n / (double) hllElem.getCloseness());
        }
    }
    return new GetClosenessPartResult(closenesses);
}
Also used : Long2DoubleOpenHashMap(it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyPartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)

Aggregations

ILongKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp)11 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)9 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)3 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)3 Tuple3 (scala.Tuple3)2 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)1 DynamicLongArray (com.tencent.angel.common.collections.DynamicLongArray)1 AngelException (com.tencent.angel.exception.AngelException)1 PartGetLongsResult (com.tencent.angel.graph.common.psf.result.PartGetLongsResult)1 PartGeneralGetResult (com.tencent.angel.graph.model.general.get.PartGeneralGetResult)1 TypeNeighborElement (com.tencent.angel.graph.model.neighbor.simplewithtype.TypeNeighborElement)1 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)1 GeneralPartGetParam (com.tencent.angel.ml.matrix.psf.get.base.GeneralPartGetParam)1 ServerLongIntRow (com.tencent.angel.ps.storage.vector.ServerLongIntRow)1 IElement (com.tencent.angel.ps.storage.vector.element.IElement)1 ValuePart (com.tencent.angel.psagent.matrix.transport.router.ValuePart)1 IIntKeyPartOp (com.tencent.angel.psagent.matrix.transport.router.operator.IIntKeyPartOp)1 DoubleValuesPart (com.tencent.angel.psagent.matrix.transport.router.value.DoubleValuesPart)1 FloatValuesPart (com.tencent.angel.psagent.matrix.transport.router.value.FloatValuesPart)1