Search in sources :

Example 11 with ILongKeyAnyValuePartOp

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

the class InitNodeAttrs method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    GeneralPartUpdateParam initParam = (GeneralPartUpdateParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, initParam);
    // Get nodes and features
    ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) initParam.getKeyValuePart();
    long[] nodeIds = split.getKeys();
    IElement[] neighbors = split.getValues();
    row.startWrite();
    try {
        for (int i = 0; i < nodeIds.length; i++) {
            row.set(nodeIds[i], neighbors[i]);
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) GeneralPartUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyAnyValuePartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)

Example 12 with ILongKeyAnyValuePartOp

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

the class UpdateHyperLogLog method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    UpdateHyperLogLogPartParam param = (UpdateHyperLogLogPartParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
    ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) param.getKeyValuePart();
    int p = param.getP();
    int sp = param.getSp();
    long seed = param.getSeed();
    long[] keys = split.getKeys();
    IElement[] values = split.getValues();
    row.startWrite();
    try {
        if (keys != null && keys.length > 0 && values != null && values.length > 0) {
            for (int i = 0; i < keys.length; i++) {
                long key = keys[i];
                HyperLogLogPlus value = ((HLLPlusElement) values[i]).getCounter();
                if (!row.exist(key))
                    row.set(key, new HyperLogLogPlusElement(key, p, sp, seed));
                HyperLogLogPlusElement hllElem = (HyperLogLogPlusElement) row.get(key);
                if (hllElem.isActive()) {
                    hllElem.merge(value);
                }
            }
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) HyperLogLogPlus(com.clearspring.analytics.stream.cardinality.HyperLogLogPlus) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyAnyValuePartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)

Example 13 with ILongKeyAnyValuePartOp

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

the class InitNeighbors method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    GeneralPartUpdateParam initParam = (GeneralPartUpdateParam) partParam;
    ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, initParam);
    // Get nodes and features
    ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) initParam.getKeyValuePart();
    long[] nodeIds = split.getKeys();
    IElement[] neighbors = split.getValues();
    row.startWrite();
    try {
        for (int i = 0; i < nodeIds.length; i++) {
            row.set(nodeIds[i], neighbors[i]);
        }
    } finally {
        row.endWrite();
    }
}
Also used : IElement(com.tencent.angel.ps.storage.vector.element.IElement) GeneralPartUpdateParam(com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ILongKeyAnyValuePartOp(com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)

Aggregations

ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)13 IElement (com.tencent.angel.ps.storage.vector.element.IElement)13 ILongKeyAnyValuePartOp (com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyAnyValuePartOp)13 GeneralPartUpdateParam (com.tencent.angel.ml.matrix.psf.update.base.GeneralPartUpdateParam)12 GraphNode (com.tencent.angel.graph.data.GraphNode)7 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)1 DynamicNeighborElement (com.tencent.angel.graph.model.neighbor.dynamic.DynamicNeighborElement)1 LongArrayElement (com.tencent.angel.ps.storage.vector.element.LongArrayElement)1