Search in sources :

Example 11 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class UpdatePartFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    CSRPartUpdateParam param = (CSRPartUpdateParam) partParam;
    PartitionKey pkey = partParam.getPartKey();
    pkey = psContext.getMatrixMetaManager().getMatrixMeta(pkey.getMatrixId()).getPartitionMeta(pkey.getPartitionId()).getPartitionKey();
    while (param.buf.isReadable()) {
        int row = param.buf.readInt();
        int len = param.buf.readShort();
        ServerRow serverRow = psContext.getMatrixStorageManager().getRow(pkey, row);
        serverRow.getLock().writeLock().lock();
        ServerDenseIntRow denseIntRow = (ServerDenseIntRow) serverRow;
        IntBuffer buffer = denseIntRow.getData();
        for (int i = 0; i < len; i++) {
            short key = param.buf.readShort();
            int val = param.buf.readInt();
            buffer.put(key, buffer.get(key) + val);
        }
        serverRow.getLock().writeLock().unlock();
    }
    param.buf.release();
}
Also used : ServerDenseIntRow(com.tencent.angel.ps.impl.matrix.ServerDenseIntRow) IntBuffer(java.nio.IntBuffer) PartitionKey(com.tencent.angel.PartitionKey) ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow)

Example 12 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class ArrayAggrParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    int size = parts.size();
    List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(size);
    for (PartitionKey part : parts) {
        if (Utils.withinPart(part, new int[] { rowId })) {
            long startCol = part.getStartCol();
            long endCol = part.getEndCol();
            ArrayList<Long> partCols = new ArrayList<>();
            for (long col : this.cols) {
                if (col >= startCol && col < endCol) {
                    partCols.add(col);
                }
            }
            if (partCols.size() > 0) {
                partParams.add(new ArrayPartitionAggrParam(matrixId, part, rowId, Utils.longListToArray(partCols)));
            }
        }
    }
    return partParams;
}
Also used : ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 13 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class UnaryAggrParam method split.

@Override
public List<PartitionGetParam> split() {
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    int size = parts.size();
    List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(size);
    for (PartitionKey part : parts) {
        partParams.add(new UnaryPartitionAggrParam(matrixId, part, rowId));
    }
    return partParams;
}
Also used : ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey) PartitionGetParam(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)

Example 14 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class CommonParam method split.

@Override
public List<PartitionUpdateParam> split() {
    List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    int size = parts.size();
    List<PartitionUpdateParam> partParams = new ArrayList<PartitionUpdateParam>(size);
    for (PartitionKey part : parts) {
        int[] ints = Utils.intListToArray(intArray);
        long[] longs = Utils.longListToArray(longArray);
        float[] floats = Utils.floatListToArray(floatArray);
        double[] doubles = Utils.doubleListToArray(doubleArray);
        PSFPartitionUpdateParam partParam = new PSFPartitionUpdateParam(matrixId, part, ints, longs, floats, doubles);
        partParams.add(partParam);
    }
    return partParams;
}
Also used : PartitionUpdateParam(com.tencent.angel.ml.matrix.psf.update.enhance.PartitionUpdateParam) ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey)

Example 15 with PartitionKey

use of com.tencent.angel.PartitionKey in project angel by Tencent.

the class MFUpdateParam method split.

@Override
public List<PartitionUpdateParam> split() {
    List<PartitionKey> partList = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
    int size = partList.size();
    List<PartitionUpdateParam> partParams = new ArrayList<PartitionUpdateParam>(size);
    for (PartitionKey part : partList) {
        if (Utils.withinPart(part, rowIds)) {
            partParams.add(new MFPartitionUpdateParam(matrixId, part, rowIds, func));
        }
    }
    if (partParams.isEmpty()) {
        System.out.println("Rows must in same partition.");
    }
    return partParams;
}
Also used : ArrayList(java.util.ArrayList) PartitionKey(com.tencent.angel.PartitionKey)

Aggregations

PartitionKey (com.tencent.angel.PartitionKey)80 ArrayList (java.util.ArrayList)17 ByteBuf (io.netty.buffer.ByteBuf)12 Test (org.junit.Test)9 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)8 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)7 PartitionGetParam (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam)7 PartitionLocation (com.tencent.angel.ml.matrix.PartitionLocation)4 ServerRow (com.tencent.angel.ps.impl.matrix.ServerRow)4 ParameterServerId (com.tencent.angel.ps.ParameterServerId)3 RecoverPartKey (com.tencent.angel.ps.recovery.ha.RecoverPartKey)3 FutureResult (com.tencent.angel.psagent.matrix.transport.FutureResult)3 Map (java.util.Map)3 Location (com.tencent.angel.common.location.Location)2 TVector (com.tencent.angel.ml.math.TVector)2 RowType (com.tencent.angel.ml.matrix.RowType)2 PSLocation (com.tencent.angel.ml.matrix.transport.PSLocation)2 MatrixStorageManager (com.tencent.angel.ps.impl.MatrixStorageManager)2 ClockCache (com.tencent.angel.psagent.clock.ClockCache)2 Worker (com.tencent.angel.worker.Worker)2