use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class QuantifyFloatFunc method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
if (part != null) {
QuantifyFloatPartParam cp = (QuantifyFloatPartParam) partParam;
ServerRow row = part.getRow(cp.getRowId());
if (row != null) {
update(row, cp.getArraySlice());
}
}
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class InitAliasTable method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
InitAliasTablePartParam param = (InitAliasTablePartParam) partParam;
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
RowBasedPartition part = (RowBasedPartition) matrix.getPartition(partParam.getPartKey().getPartitionId());
ServerLongAnyRow row = (ServerLongAnyRow) part.getRow(0);
ObjectIterator<Long2ObjectMap.Entry<AliasElement>> iter = param.getNodeId2Neighbors().long2ObjectEntrySet().iterator();
row.startWrite();
try {
while (iter.hasNext()) {
Long2ObjectMap.Entry<AliasElement> entry = iter.next();
AliasElement element = entry.getValue();
if (element == null) {
row.set(entry.getLongKey(), null);
} else {
row.set(entry.getLongKey(), new AliasElement(element.getNeighborIds(), element.getAccept(), element.getAlias()));
}
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class ComputeW method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
if (partParam instanceof MultiRowPartitionUpdateParam) {
MultiRowPartitionUpdateParam param = (MultiRowPartitionUpdateParam) partParam;
int[] rowIds = param.getRowIds();
double[][] values = param.getValues();
double alpha = values[0][0];
double beta = values[0][1];
double lambda1 = values[0][2];
double lambda2 = values[0][3];
int offset = (int) values[1][0];
RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(param.getPartKey());
for (int i = 0; i < offset; i++) {
Vector z = ServerRowUtils.getVector(part.getRow(rowIds[0] * offset + i));
Vector n = ServerRowUtils.getVector(part.getRow(rowIds[1] * offset + i));
Vector w = Ufuncs.ftrlthreshold(z, n, alpha, beta, lambda1, lambda2);
ServerRowUtils.setVector(part.getRow(rowIds[2] * offset + i), w.ifilter(1e-11));
}
// // calculate bias
// if (param.getPartKey().getStartCol() <= 0 && param.getPartKey().getEndCol() > 0) {
// double zVal = VectorUtils.getDouble(z, 0);
// double nVal = VectorUtils.getDouble(n, 0);
// VectorUtils.setFloat(w, 0, (float) (-1.0 * alpha * zVal / (beta + Math.sqrt(nVal))));
// }
}
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class IndexGet method partitionGet.
/**
* Each server partition execute this function and return values of specified index.
*
* @param partParam the partition parameter
* @return values of specified index
*/
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
long startTs = System.currentTimeMillis();
RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
PartitionGetResult result = null;
if (part != null) {
int rowId = ((IndexPartGetParam) partParam).getRowId();
int[] indexes = ((IndexPartGetParam) partParam).getIndexes();
ServerRow row = part.getRow(rowId);
RowType rowType = row.getRowType();
switch(rowType) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
case T_DOUBLE_DENSE_COMPONENT:
case T_DOUBLE_SPARSE_COMPONENT:
{
result = new IndexPartGetDoubleResult(partParam.getPartKey(), ((ServerIntDoubleRow) row).get(indexes));
break;
}
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
case T_FLOAT_DENSE_COMPONENT:
case T_FLOAT_SPARSE_COMPONENT:
{
result = new IndexPartGetFloatResult(partParam.getPartKey(), ((ServerIntFloatRow) row).get(indexes));
break;
}
case T_INT_DENSE:
case T_INT_SPARSE:
case T_INT_DENSE_COMPONENT:
case T_INT_SPARSE_COMPONENT:
{
result = new IndexPartGetIntResult(partParam.getPartKey(), ((ServerIntIntRow) row).get(indexes));
break;
}
case T_LONG_DENSE:
case T_LONG_SPARSE:
case T_LONG_DENSE_COMPONENT:
case T_LONG_SPARSE_COMPONENT:
{
result = new IndexPartGetLongResult(partParam.getPartKey(), ((ServerIntLongRow) row).get(indexes));
break;
}
default:
throw new UnsupportedOperationException("Unsupport operation: update " + rowType + " to " + this.getClass().getName());
}
}
LOG.debug("Partition get use time=" + (System.currentTimeMillis() - startTs) + " ms");
return result;
}
use of com.tencent.angel.ps.storage.partition.RowBasedPartition in project angel by Tencent.
the class IncrementRows method getVector.
/**
* Get inner vector from server matrix, it is can be only use in RowBasedPartition and basic row
* type
*
* @param matrixId matrix id
* @param rowId row id
* @param part partition key
* @return inner vector
*/
protected Vector getVector(int matrixId, int rowId, PartitionKey part) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(matrixId);
ServerRow psRow = ((RowBasedPartition) matrix.getPartition(part.getPartitionId())).getRow(rowId);
return ServerRowUtils.getVector(psRow);
}
Aggregations