Search in sources :

Example 6 with ServerRow

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

the class BinaryAggrFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
    int rowId1 = ((BinaryAggrParam.BinaryPartitionAggrParam) partKey).getRowId1();
    int rowId2 = ((BinaryAggrParam.BinaryPartitionAggrParam) partKey).getRowId2();
    if (Utils.withinPart(partKey.getPartKey(), new int[] { rowId1, rowId2 })) {
        if (part != null) {
            ServerRow row1 = part.getRow(rowId1);
            ServerRow row2 = part.getRow(rowId2);
            if (row1 != null && row2 != null) {
                double result = processRows(row1, row2);
                return new ScalarPartitionAggrResult(result);
            }
        }
    }
    return null;
}
Also used : ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Example 7 with ServerRow

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

the class UnaryAggrFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partKey) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partKey.getMatrixId(), partKey.getPartKey().getPartitionId());
    if (part != null) {
        int rowId = ((UnaryAggrParam.UnaryPartitionAggrParam) partKey).getRowId();
        if (Utils.withinPart(part.getPartitionKey(), new int[] { rowId })) {
            ServerRow row = part.getRow(rowId);
            double result = processRow(row);
            return new ScalarPartitionAggrResult(result);
        }
    }
    return null;
}
Also used : ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Example 8 with ServerRow

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

the class Utils method pick.

public static ArrayList<Map.Entry<ServerRow, ArrayList<Integer>>> pick(ServerRow[] serverRows, Long[] rows, Long[] cols, Double[] values) {
    assert (rows.length == cols.length && rows.length == values.length);
    ArrayList<Map.Entry<ServerRow, ArrayList<Integer>>> result = new ArrayList<>();
    for (ServerRow row : serverRows) {
        long rowId = row.getRowId();
        long startCol = row.getStartCol();
        long endCol = row.getEndCol();
        ArrayList<Integer> indics = new ArrayList<Integer>();
        for (int i = 0; i <= rows.length; i++) {
            if (rowId == rows[i] && cols[i] >= startCol && cols[i] < endCol) {
                indics.add(i);
            }
        }
        Map.Entry<ServerRow, ArrayList<Integer>> pair = new java.util.AbstractMap.SimpleEntry<>(row, indics);
        result.add(pair);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) Map(java.util.Map)

Example 9 with ServerRow

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

the class CompressUpdateFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
    if (part != null) {
        CompressUpdateParam.CompressPartitionUpdateParam cp = (CompressUpdateParam.CompressPartitionUpdateParam) partParam;
        ServerRow row = part.getRow(cp.getRowId());
        if (row != null) {
            update(row, cp.getArraySlice());
        }
    }
}
Also used : ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Example 10 with ServerRow

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

the class MFUpdateFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
    if (part != null) {
        MFUpdateParam.MFPartitionUpdateParam mf = (MFUpdateParam.MFPartitionUpdateParam) partParam;
        int[] rowIds = mf.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, mf.getFunc());
        }
    }
}
Also used : ServerRow(com.tencent.angel.ps.impl.matrix.ServerRow) ServerPartition(com.tencent.angel.ps.impl.matrix.ServerPartition)

Aggregations

ServerRow (com.tencent.angel.ps.impl.matrix.ServerRow)12 ServerPartition (com.tencent.angel.ps.impl.matrix.ServerPartition)9 PartitionKey (com.tencent.angel.PartitionKey)1 TVector (com.tencent.angel.ml.math.TVector)1 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)1 ParameterServerId (com.tencent.angel.ps.ParameterServerId)1 MatricesCache (com.tencent.angel.psagent.matrix.cache.MatricesCache)1 MatrixStorage (com.tencent.angel.psagent.matrix.storage.MatrixStorage)1 MatrixTransportClient (com.tencent.angel.psagent.matrix.transport.MatrixTransportClient)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1