use of com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow in project angel by Tencent.
the class Increment method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] partRows, PartitionUpdateParam param) {
CommonParam.PSFPartitionUpdateParam partParam = (CommonParam.PSFPartitionUpdateParam) param;
int[] rows = partParam.getInts();
long[] cols = partParam.getLongs();
double[] values = partParam.getDoubles();
for (ServerSparseDoubleLongKeyRow partRow : partRows) {
int rowId = partRow.getRowId();
ArrayList<Integer> indics = new ArrayList<Integer>();
for (int i = 0; i < rows.length; i++) {
if (rowId == rows[i] && cols[i] >= partRow.getStartCol() && cols[i] < partRow.getEndCol()) {
indics.add(i);
}
}
try {
partRow.getLock().writeLock().lock();
Long2DoubleOpenHashMap rowData = partRow.getData();
for (Integer i : indics) {
if (rowData.containsKey(cols[i])) {
rowData.addTo(cols[i], values[i]);
} else {
rowData.put(cols[i], values[i]);
}
}
} finally {
partRow.getLock().writeLock().unlock();
}
}
}
use of com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow in project angel by Tencent.
the class Fill method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] partRows, PartitionUpdateParam param) {
CommonParam.PSFPartitionUpdateParam partParam = (CommonParam.PSFPartitionUpdateParam) param;
int[] rows = partParam.getInts();
long[] cols = partParam.getLongs();
double[] values = partParam.getDoubles();
for (ServerSparseDoubleLongKeyRow partRow : partRows) {
int rowId = partRow.getRowId();
ArrayList<Integer> indics = new ArrayList<Integer>();
for (int i = 0; i < rows.length; i++) {
if (rowId == rows[i] && cols[i] >= partRow.getStartCol() && cols[i] < partRow.getEndCol()) {
indics.add(i);
}
}
try {
partRow.getLock().writeLock().lock();
Long2DoubleOpenHashMap rowData = partRow.getData();
for (Integer i : indics) {
rowData.put(cols[i], values[i]);
}
} finally {
partRow.getLock().writeLock().unlock();
}
}
}
use of com.tencent.angel.ps.impl.matrix.ServerSparseDoubleLongKeyRow in project angel by Tencent.
the class SparsePush method doUpdate.
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, PartitionUpdateParam param) {
CommonParam.PSFPartitionUpdateParam partParam = (CommonParam.PSFPartitionUpdateParam) param;
int rowId = partParam.getInts()[0];
long[] indices = partParam.getLongs();
double[] values = partParam.getDoubles();
ServerSparseDoubleLongKeyRow row = rows[rowId];
Long2DoubleOpenHashMap data = new Long2DoubleOpenHashMap(indices, values);
row.setIndex2ValueMap(data);
}
Aggregations