Search in sources :

Example 6 with ServerIntIntRow

use of com.tencent.angel.ps.storage.vector.ServerIntIntRow in project angel by Tencent.

the class LikelihoodFunc method partitionGet.

@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    PartitionKey pkey = partParam.getPartKey();
    pkey = psContext.getMatrixMetaManager().getMatrixMeta(pkey.getMatrixId()).getPartitionMeta(pkey.getPartitionId()).getPartitionKey();
    int ws = pkey.getStartRow();
    int es = pkey.getEndRow();
    if (partParam instanceof LikelihoodParam.LikelihoodPartParam) {
        LikelihoodParam.LikelihoodPartParam param = (LikelihoodParam.LikelihoodPartParam) partParam;
        float beta = param.getBeta();
        double lgammaBeta = Gamma.logGamma(beta);
        double ll = 0;
        for (int w = ws; w < es; w++) {
            ServerRow row = psContext.getMatrixStorageManager().getRow(pkey, w);
            try {
                row.startRead();
                ll += likelihood((ServerIntIntRow) row, beta, lgammaBeta);
            } finally {
                row.endRead();
            }
        }
        return new ScalarPartitionAggrResult(ll);
    } else {
        throw new AngelException("Should be LikelihoodParam.LikelihoodPartParam");
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) ScalarPartitionAggrResult(com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarPartitionAggrResult) PartitionKey(com.tencent.angel.PartitionKey) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) ServerIntIntRow(com.tencent.angel.ps.storage.vector.ServerIntIntRow)

Aggregations

ServerIntIntRow (com.tencent.angel.ps.storage.vector.ServerIntIntRow)6 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)4 PartitionKey (com.tencent.angel.PartitionKey)3 IntIntVector (com.tencent.angel.ml.math2.vector.IntIntVector)2 AngelException (com.tencent.angel.exception.AngelException)1 ScalarPartitionAggrResult (com.tencent.angel.ml.matrix.psf.aggr.enhance.ScalarPartitionAggrResult)1 PartitionGetRowsParam (com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam)1 MatrixStorageManager (com.tencent.angel.ps.storage.MatrixStorageManager)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 HashMap (java.util.HashMap)1