use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseDoubleVector.
public static SparseDoubleVector mergeSparseDoubleVector(IndexGetParam param, List<PartitionGetResult> partResults) {
SparseDoubleVector vector = new SparseDoubleVector((int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum(), param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((IndexPartGetDoubleResult) part).getPartKey();
int[] indexes = param.getPartKeyToIndexesMap().get(partKey);
double[] values = ((IndexPartGetDoubleResult) 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 mergeSparseDoubleVector.
public static SparseLongKeyDoubleVector mergeSparseDoubleVector(LongIndexGetParam param, List<PartitionGetResult> partResults) {
SparseLongKeyDoubleVector vector = new SparseLongKeyDoubleVector(PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum(), param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((LongIndexGetResult) part).partKey;
long[] indexes = param.getPartKeyToIndexesMap().get(partKey);
double[] values = ((LongIndexGetResult) 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 PSFGetHandler method handle.
@Override
public ResponseData handle(RequestHeader header, RequestData data) throws Exception {
GetUDFRequest request = (GetUDFRequest) data;
Class<? extends GetFunc> funcClass = (Class<? extends GetFunc>) Class.forName(request.getGetFuncClass());
Constructor<? extends GetFunc> constructor = funcClass.getConstructor();
constructor.setAccessible(true);
GetFunc func = constructor.newInstance();
// LOG.info("Get PSF func = " + func.getClass().getName());
func.setPsContext(context);
PartitionGetResult partResult = func.partitionGet(request.getPartParam());
return new GetUDFResponse(partResult);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseFloatVector.
public static LongFloatVector mergeSparseFloatVector(LongIndexGetParam param, List<PartitionGetResult> partResults) {
long dim = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum();
LongFloatVector vector = VFactory.sparseLongKeyFloatVector(dim, param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((IndexPartGetResult) part).getPartKey();
long[] indexes = param.getPartKeyToIndexesMap().get(partKey);
float[] values = ((IndexPartGetFloatResult) 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 mergeSparseLongCompVector.
public static CompIntLongVector mergeSparseLongCompVector(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 dim = (int) meta.getColNum();
int subDim = (int) meta.getBlockColNum();
int size = partKeys.size();
IntLongVector[] splitVecs = new IntLongVector[size];
for (int i = 0; i < size; i++) {
if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
long[] values = ((IndexPartGetLongResult) partKeyToResultMap.get(partKeys.get(i))).getValues();
int[] indices = param.getPartKeyToIndexesMap().get(partKeys.get(i));
transformIndices(indices, partKeys.get(i));
splitVecs[i] = VFactory.sparseLongVector(subDim, indices, values);
} else {
splitVecs[i] = VFactory.sparseLongVector(subDim, 0);
}
}
CompIntLongVector vector = VFactory.compIntLongVector(dim, splitVecs, subDim);
vector.setMatrixId(param.getMatrixId());
vector.setRowId(param.getRowId());
return vector;
}
Aggregations