use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class GetCloseness method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Long2DoubleOpenHashMap closenesses = new Long2DoubleOpenHashMap();
for (PartitionGetResult r : partResults) {
GetClosenessPartResult rr = (GetClosenessPartResult) r;
closenesses.putAll(rr.getClosenesses());
}
return new GetClosenessResult(closenesses);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class FullPull method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
int endRow = -1;
int endCol = -1;
for (PartitionGetResult partResult : partResults) {
FullPartitionAggrResult result = (FullPartitionAggrResult) partResult;
int[] partInfo = result.getPartInfo();
assert (partInfo.length == 4);
if (endRow < partInfo[1])
endRow = partInfo[1];
if (endCol < partInfo[3])
endCol = partInfo[3];
}
double[][] result = new double[endRow][endCol];
for (PartitionGetResult partResult : partResults) {
FullPartitionAggrResult aggrResult = (FullPartitionAggrResult) partResult;
double[][] pResult = aggrResult.getResult();
int[] partInfo = aggrResult.getPartInfo();
int thisStartRow = partInfo[0];
int thisEndRow = partInfo[1];
int thisStartCol = partInfo[2];
int thisEndCol = partInfo[3];
int thisColSize = thisEndCol - thisStartCol;
for (int i = 0; i < pResult.length; i++) {
System.arraycopy(pResult[i], 0, result[thisStartRow + i], thisStartCol, thisColSize);
}
}
return new FullAggrResult(result);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class PullWithCols method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
ArrayList<Long> cols = new ArrayList<>();
ArrayList<Double> result = new ArrayList<>();
for (PartitionGetResult part : partResults) {
ArrayPartitionAggrResult partResult = (ArrayPartitionAggrResult) part;
long[] keys = partResult.getCols();
double[] values = partResult.getResult();
assert (keys.length == values.length);
for (int i = 0; i < keys.length; i++) {
cols.add(keys[i]);
result.add(values[i]);
}
}
return new ArrayAggrResult(Utils.longListToArray(cols), Utils.doubleListToArray(result));
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseDoubleCompVector.
public static CompSparseDoubleVector mergeSparseDoubleCompVector(IndexGetParam param, List<PartitionGetResult> partResults) {
Map<PartitionKey, PartitionGetResult> partKeyToResultMap = mapPartKeyToResult(partResults);
List<PartitionKey> partKeys = getSortedPartKeys(param.matrixId, param.getRowId());
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.matrixId);
int size = partKeys.size();
SparseDoubleVector[] splitVecs = new SparseDoubleVector[size];
for (int i = 0; i < size; i++) {
if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
splitVecs[i] = new SparseDoubleVector((int) meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((IndexPartGetDoubleResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
}
}
return new CompSparseDoubleVector(meta.getId(), param.getRowId(), (int) meta.getColNum(), partKeys.toArray(new PartitionKey[0]), splitVecs);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseIntCompVector.
public static CompSparseIntVector mergeSparseIntCompVector(IndexGetParam param, List<PartitionGetResult> partResults) {
Map<PartitionKey, PartitionGetResult> partKeyToResultMap = mapPartKeyToResult(partResults);
List<PartitionKey> partKeys = getSortedPartKeys(param.matrixId, param.getRowId());
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.matrixId);
int size = partKeys.size();
SparseIntVector[] splitVecs = new SparseIntVector[size];
for (int i = 0; i < size; i++) {
if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
splitVecs[i] = new SparseIntVector((int) meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((IndexPartGetIntResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
}
}
return new CompSparseIntVector(meta.getId(), param.getRowId(), (int) meta.getColNum(), partKeys.toArray(new PartitionKey[0]), splitVecs);
}
Aggregations