use of com.tencent.angel.ml.math.TVector in project angel by Tencent.
the class RowSplitCombineUtils method combineServerDenseFloatRowSplits.
private static TVector combineServerDenseFloatRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
int colNum = (int) matrixMeta.getColNum();
float[] dataArray = new float[colNum];
Collections.sort(rowSplits, serverRowComp);
int clock = Integer.MAX_VALUE;
int size = rowSplits.size();
for (int i = 0; i < size; i++) {
if (rowSplits.get(i).getClock() < clock) {
clock = rowSplits.get(i).getClock();
}
((ServerDenseFloatRow) rowSplits.get(i)).mergeTo(dataArray);
}
TVector row = new DenseFloatVector(colNum, dataArray);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
row.setClock(clock);
return row;
}
use of com.tencent.angel.ml.math.TVector in project angel by Tencent.
the class RowSplitCombineUtils method combineServerSparseDoubleRowSplits.
private static TVector combineServerSparseDoubleRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
int colNum = (int) matrixMeta.getColNum();
int splitNum = rowSplits.size();
int totalElemNum = 0;
int[] lens = new int[splitNum];
Collections.sort(rowSplits, serverRowComp);
int elemNum = 0;
for (int i = 0; i < splitNum; i++) {
elemNum = rowSplits.get(i).size();
totalElemNum += elemNum;
lens[i] = elemNum;
}
int[] indexes = new int[totalElemNum];
double[] values = new double[totalElemNum];
int clock = Integer.MAX_VALUE;
int startPos = 0;
for (int i = 0; i < splitNum; i++) {
if (rowSplits.get(i).getClock() < clock) {
clock = rowSplits.get(i).getClock();
}
((ServerSparseDoubleRow) rowSplits.get(i)).mergeTo(indexes, values, startPos, lens[i]);
startPos += lens[i];
}
TVector row = new SparseDoubleVector(colNum, indexes, values);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
row.setClock(clock);
return row;
}
use of com.tencent.angel.ml.math.TVector in project angel by Tencent.
the class RowSplitCombineUtils method combineServerSparseDoubleLongKeyRowSplits.
private static TVector combineServerSparseDoubleLongKeyRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
int colNum = (int) matrixMeta.getColNum();
int splitNum = rowSplits.size();
int totalElemNum = 0;
int[] lens = new int[splitNum];
Collections.sort(rowSplits, serverRowComp);
int elemNum = 0;
for (int i = 0; i < splitNum; i++) {
elemNum = rowSplits.get(i).size();
totalElemNum += elemNum;
lens[i] = elemNum;
}
long[] indexes = new long[totalElemNum];
double[] values = new double[totalElemNum];
int clock = Integer.MAX_VALUE;
int startPos = 0;
for (int i = 0; i < splitNum; i++) {
if (rowSplits.get(i).getClock() < clock) {
clock = rowSplits.get(i).getClock();
}
((ServerSparseDoubleLongKeyRow) rowSplits.get(i)).mergeTo(indexes, values, startPos, lens[i]);
startPos += lens[i];
}
TVector row = new SparseLongKeyDoubleVector(colNum, indexes, values);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
row.setClock(clock);
return row;
}
use of com.tencent.angel.ml.math.TVector in project angel by Tencent.
the class RowSplitCombineUtils method combineDenseDoubleRowSplits.
private static TVector combineDenseDoubleRowSplits(GetRowPipelineCache pipelineCache, MatrixMeta matrixMeta, int rowIndex) throws InterruptedException {
int colNum = (int) matrixMeta.getColNum();
double[] dataArray = new double[colNum];
int clock = Integer.MAX_VALUE;
while (true) {
ServerRow split = pipelineCache.poll();
if (split == null) {
TVector row = new DenseDoubleVector(colNum, dataArray);
row.setClock(clock);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
return row;
}
if (split.getClock() < clock) {
clock = split.getClock();
}
((ServerDenseDoubleRow) split).mergeTo(dataArray);
}
}
use of com.tencent.angel.ml.math.TVector in project angel by Tencent.
the class RowSplitCombineUtils method combineDenseIntRowSplits.
private static TVector combineDenseIntRowSplits(GetRowPipelineCache pipelineCache, MatrixMeta matrixMeta, int rowIndex) throws InterruptedException {
int colNum = (int) matrixMeta.getColNum();
int[] dataArray = new int[colNum];
int clock = Integer.MAX_VALUE;
while (true) {
ServerRow split = pipelineCache.poll();
if (split == null) {
TVector row = new DenseIntVector(colNum, dataArray);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
row.setClock(clock);
return row;
}
if (split.getClock() < clock) {
clock = split.getClock();
}
((ServerDenseIntRow) split).mergeTo(dataArray);
}
}
Aggregations