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");
}
}
Aggregations