use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseLongVector.
public static LongLongVector mergeSparseLongVector(LongIndexGetParam param, List<PartitionGetResult> partResults) {
long dim = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum();
LongLongVector vector = VFactory.sparseLongKeyLongVector(dim, param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((IndexPartGetResult) part).getPartKey();
long[] indexes = param.getPartKeyToIndexesMap().get(partKey);
long[] values = ((IndexPartGetLongResult) part).getValues();
for (int i = 0; i < indexes.length; i++) {
vector.set(indexes[i], values[i]);
}
}
vector.setMatrixId(param.getMatrixId());
vector.setRowId(param.getRowId());
return vector;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseIntVector.
public static IntIntVector mergeSparseIntVector(IndexGetParam param, List<PartitionGetResult> partResults) {
int dim = (int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum();
IntIntVector vector = VFactory.sparseIntVector(dim, param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((IndexPartGetIntResult) part).getPartKey();
int[] indexes = param.getPartKeyToIndexesMap().get(partKey);
int[] values = ((IndexPartGetIntResult) part).getValues();
for (int i = 0; i < indexes.length; i++) {
vector.set(indexes[i], values[i]);
}
}
vector.setMatrixId(param.getMatrixId());
vector.setRowId(param.getRowId());
return vector;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseIntVector.
public static LongIntVector mergeSparseIntVector(LongIndexGetParam param, List<PartitionGetResult> partResults) {
long dim = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum();
LongIntVector vector = VFactory.sparseLongKeyIntVector(dim, param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((IndexPartGetResult) part).getPartKey();
long[] indexes = param.getPartKeyToIndexesMap().get(partKey);
int[] values = ((IndexPartGetIntResult) part).getValues();
for (int i = 0; i < indexes.length; i++) {
vector.set(indexes[i], values[i]);
}
}
vector.setMatrixId(param.getMatrixId());
vector.setRowId(param.getRowId());
return vector;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseLongVector.
public static IntLongVector mergeSparseLongVector(IndexGetParam param, List<PartitionGetResult> partResults) {
int dim = (int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum();
IntLongVector vector = VFactory.sparseLongVector(dim, param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((IndexPartGetLongResult) part).getPartKey();
int[] indexes = param.getPartKeyToIndexesMap().get(partKey);
long[] values = ((IndexPartGetLongResult) part).getValues();
for (int i = 0; i < indexes.length; i++) {
if (i < 10) {
LOG.debug("merge index = " + indexes[i] + ", value = " + values[i]);
}
vector.set(indexes[i], values[i]);
}
}
vector.setMatrixId(param.getMatrixId());
vector.setRowId(param.getRowId());
return vector;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseIntCompVector.
public static CompLongIntVector mergeSparseIntCompVector(LongIndexGetParam 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);
long dim = meta.getColNum();
long subDim = meta.getBlockColNum();
int size = partKeys.size();
LongIntVector[] splitVecs = new LongIntVector[size];
for (int i = 0; i < size; i++) {
if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
int[] values = ((IndexPartGetIntResult) partKeyToResultMap.get(partKeys.get(i))).getValues();
long[] indices = param.getPartKeyToIndexesMap().get(partKeys.get(i));
transformIndices(indices, partKeys.get(i));
splitVecs[i] = VFactory.sparseLongKeyIntVector(subDim, indices, values);
} else {
splitVecs[i] = VFactory.sparseLongKeyIntVector(subDim, 0);
}
}
CompLongIntVector vector = VFactory.compLongIntVector(dim, splitVecs, subDim);
vector.setMatrixId(param.getMatrixId());
vector.setRowId(param.getRowId());
return vector;
}
Aggregations