use of com.tencent.angel.ps.storage.vector.ServerLongFloatRow in project angel by Tencent.
the class GetLabels method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
switch(keyPart.getKeyType()) {
case LONG:
{
// Long type node id
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongFloatRow row = (ServerLongFloatRow) psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0);
LongArrayList keys = new LongArrayList();
FloatArrayList vals = new FloatArrayList();
for (int i = 0; i < nodeIds.length; i++) {
if (row.exist(nodeIds[i])) {
keys.add(nodeIds[i]);
vals.add(row.get(nodeIds[i]));
}
}
return new GetLabelsPartResult(keys.toLongArray(), vals.toFloatArray());
}
default:
{
// TODO: support String, Int, and Any type node id
throw new InvalidParameterException("Unsupport index type " + keyPart.getKeyType());
}
}
}
use of com.tencent.angel.ps.storage.vector.ServerLongFloatRow in project angel by Tencent.
the class RowSplitCombineUtils method combineServerLongFloatRowSplits.
private static Vector combineServerLongFloatRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
long colNum = matrixMeta.getColNum();
int elemNum = 0;
int size = rowSplits.size();
for (int i = 0; i < size; i++) {
elemNum += rowSplits.get(i).size();
}
LongFloatVector row = VFactory.sparseLongKeyFloatVector(colNum, elemNum);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
Collections.sort(rowSplits, serverRowComp);
int clock = Integer.MAX_VALUE;
for (int i = 0; i < size; i++) {
if (rowSplits.get(i) == null) {
continue;
}
if (rowSplits.get(i).getClock() < clock) {
clock = rowSplits.get(i).getClock();
}
((ServerLongFloatRow) rowSplits.get(i)).mergeTo(row);
}
row.setClock(clock);
return row;
}
use of com.tencent.angel.ps.storage.vector.ServerLongFloatRow in project angel by Tencent.
the class MergeUtils method combineServerLongFloatRowSplits.
private static Vector combineServerLongFloatRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
long colNum = matrixMeta.getColNum();
int elemNum = 0;
int size = rowSplits.size();
for (int i = 0; i < size; i++) {
elemNum += rowSplits.get(i).size();
}
LongFloatVector row = VFactory.sparseLongKeyFloatVector(colNum, elemNum);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
Collections.sort(rowSplits, serverRowComp);
for (int i = 0; i < size; i++) {
if (rowSplits.get(i) == null) {
continue;
}
((ServerLongFloatRow) rowSplits.get(i)).mergeTo(row);
}
return row;
}
Aggregations