use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseFloatCompVector.
public static CompSparseFloatVector mergeSparseFloatCompVector(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();
SparseFloatVector[] splitVecs = new SparseFloatVector[size];
for (int i = 0; i < size; i++) {
if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
splitVecs[i] = new SparseFloatVector((int) meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((IndexPartGetFloatResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
}
}
return new CompSparseFloatVector(meta.getId(), param.getRowId(), (int) meta.getColNum(), partKeys.toArray(new PartitionKey[0]), splitVecs);
}
use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseDoubleCompVector.
public static CompSparseLongKeyDoubleVector mergeSparseDoubleCompVector(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);
int size = partKeys.size();
SparseLongKeyDoubleVector[] splitVecs = new SparseLongKeyDoubleVector[size];
for (int i = 0; i < size; i++) {
if (param.getPartKeyToIndexesMap().containsKey(partKeys.get(i))) {
splitVecs[i] = new SparseLongKeyDoubleVector(meta.getColNum(), param.getPartKeyToIndexesMap().get(partKeys.get(i)), ((LongIndexGetResult) partKeyToResultMap.get(partKeys.get(i))).getValues());
}
}
CompSparseLongKeyDoubleVector vector = new CompSparseLongKeyDoubleVector(meta.getId(), param.getRowId(), meta.getColNum(), partKeys.toArray(new PartitionKey[0]), splitVecs);
return vector;
}
use of com.tencent.angel.PartitionKey in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseFloatVector.
public static SparseFloatVector mergeSparseFloatVector(IndexGetParam param, List<PartitionGetResult> partResults) {
SparseFloatVector vector = new SparseFloatVector((int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum(), param.size());
for (PartitionGetResult part : partResults) {
PartitionKey partKey = ((IndexPartGetFloatResult) part).getPartKey();
int[] 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.PartitionKey in project angel by Tencent.
the class ValuesCombineUtils method mergeSparseIntVector.
public static SparseIntVector mergeSparseIntVector(IndexGetParam param, List<PartitionGetResult> partResults) {
SparseIntVector vector = new SparseIntVector((int) PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getColNum(), 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.PartitionKey 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;
}
Aggregations