use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class FullAggrParam method split.
@Override
public List<PartitionGetParam> split() {
List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
int size = parts.size();
List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(size);
for (PartitionKey part : parts) {
partParams.add(new FullPartitionAggrParam(matrixId, part));
}
return partParams;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class MultiAggrParam method split.
@Override
public List<PartitionGetParam> split() {
List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
int size = parts.size();
List<PartitionGetParam> partParams = new ArrayList<PartitionGetParam>(size);
for (PartitionKey part : parts) {
partParams.add(new MultiPartitionAggrParam(matrixId, part, rowIds));
}
return partParams;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class IntKeysGetParam method split.
@Override
public List<PartitionGetParam> split() {
// Get matrix meta
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
// Split
KeyPart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, false);
// Generate Part psf get param
List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
assert parts.length == nodeIdsParts.length;
for (int i = 0; i < parts.length; i++) {
if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
partParams.add(new GeneralPartGetParam(matrixId, parts[i], nodeIdsParts[i]));
}
}
return partParams;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class GetNeighborWithCountParam method split.
@Override
public List<PartitionGetParam> split() {
// Get matrix meta
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
// Split
KeyValuePart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, count, false);
// Generate Part psf get param
List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
assert parts.length == nodeIdsParts.length;
for (int i = 0; i < parts.length; i++) {
if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
partParams.add(new PartGetNeighborWithCountParam(matrixId, parts[i], nodeIdsParts[i]));
}
}
return partParams;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class GetNeighborAliasTable method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartGetNeighborAliasTableResult) result).getPartId(), result);
}
GetNeighborAliasTableParam param = (GetNeighborAliasTableParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartGetNeighborAliasTableParam) partParam).getStartIndex();
int end = ((PartGetNeighborAliasTableParam) partParam).getEndIndex();
PartGetNeighborAliasTableResult partResult = (PartGetNeighborAliasTableResult) (partIdToResultMap.get(partParam.getPartKey().getPartitionId()));
long[][] results = partResult.getNodeIdToNeighbors();
for (int i = start; i < end; i++) {
nodeIdToNeighbors.put(nodeIds[i], results[i - start]);
}
}
return new GetNeighborAliasTableResult(nodeIdToNeighbors);
}
Aggregations