Search in sources :

Example 1 with ServerPartition

use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.

the class PS2PSPusherImpl method recover.

@Override
public FutureResult<Response> recover(final RecoverPartKey partKey) {
    FutureResult<Response> result = new FutureResult<>();
    workerPool.execute(() -> {
        ServerPartition part = context.getMatrixStorageManager().getPart(partKey.partKey.getMatrixId(), partKey.partKey.getPartitionId());
        if (part == null) {
            result.set(new Response(ResponseType.UNKNOWN_ERROR, "Can not find partition " + partKey.partKey.getMatrixId() + ":" + partKey.partKey.getPartitionId()));
            return;
        }
        try {
            part.waitAndSetReadOnly();
            result.set(psClient.recoverPart(partKey.psLoc.psId, partKey.psLoc.loc, part).get());
        } catch (Throwable e) {
            result.set(new Response(ResponseType.NETWORK_ERROR, e.getMessage()));
            LOG.error("handle recover event " + partKey + " failed ", e);
        } finally {
            part.setState(PartitionState.READ_AND_WRITE);
            LOG.info("ps " + context.getPSAttemptId() + " set partition " + part.getPartitionKey() + " to " + part.getState());
        }
    });
    return result;
}
Also used : Response(com.tencent.angel.ml.matrix.transport.Response) FutureResult(com.tencent.angel.psagent.matrix.transport.FutureResult) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Example 2 with ServerPartition

use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.

the class ArrayAggrFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
    if (part != null) {
        int rowId = ((ArrayAggrParam.ArrayPartitionAggrParam) partKey).getRowId();
        if (Utils.withinPart(part.getPartitionKey(), new int[] { rowId })) {
            ServerRow row = part.getRow(rowId);
            long[] colsParam = ((ArrayAggrParam.ArrayPartitionAggrParam) partKey).getCols();
            List<Map.Entry<Long, Double>> result = processRow(row, colsParam);
            long[] cols = new long[result.size()];
            double[] values = new double[result.size()];
            for (int i = 0; i < result.size(); i++) {
                cols[i] = result.get(i).getKey();
                values[i] = result.get(i).getValue();
            }
            return new ArrayPartitionAggrResult(cols, values);
        }
    }
    return null;
}
Also used : ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Example 3 with ServerPartition

use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.

the class MultiAggrFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
    int[] rowIds = ((MultiAggrParam.MultiPartitionAggrParam) partKey).getRowIds();
    double[] result = null;
    if (Utils.withinPart(partKey.getPartKey(), rowIds)) {
        if (part != null) {
            ServerRow[] rows = new ServerRow[rowIds.length];
            for (int i = 0; i < rowIds.length; i++) {
                rows[i] = part.getRow(rowIds[i]);
            }
            result = processRows(rows);
        }
    }
    return new ArrayPartitionAggrResult(result);
}
Also used : ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Example 4 with ServerPartition

use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.

the class FullUpdateFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
    if (part != null) {
        FullUpdateParam.FullPartitionUpdateParam ff = (FullUpdateParam.FullPartitionUpdateParam) partParam;
        update(part, partParam.getPartKey(), ff.getValues());
    }
}
Also used : ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Example 5 with ServerPartition

use of com.tencent.angel.ps.impl.matrix.ServerPartition in project angel by Tencent.

the class MUpdateFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
    if (part != null) {
        MUpdateParam.MPartitionUpdateParam m = (MUpdateParam.MPartitionUpdateParam) partParam;
        int[] rowIds = m.getRowIds();
        if (Utils.withinPart(partParam.getPartKey(), rowIds)) {
            ServerRow[] rows = new ServerRow[rowIds.length];
            for (int i = 0; i < rowIds.length; i++) {
                rows[i] = part.getRow(rowIds[i]);
            }
            update(rows);
        }
    }
}
Also used : ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Aggregations

ServerPartition (com.tencent.angel.ps.impl.matrix.ServerPartition)18 ServerRow (com.tencent.angel.ps.impl.matrix.ServerRow)9 Response (com.tencent.angel.ml.matrix.transport.Response)2 FutureResult (com.tencent.angel.psagent.matrix.transport.FutureResult)2 PartitionKey (com.tencent.angel.PartitionKey)1 ParameterServerId (com.tencent.angel.ps.ParameterServerId)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1