use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class SampleNodeFeatParam method split.
@Override
public List<PartitionGetParam> split() {
// Get matrix meta
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] partitions = meta.getPartitionKeys();
// sample (count / partNum + 1) in every partition randomly
int eachSize = count / partitions.length + 1;
// Generate rpc params
List<PartitionGetParam> partParams = new ArrayList<>(partitions.length);
for (int i = 0; i < partitions.length; i++) {
partParams.add(new PartSampleNodeFeatParam(matrixId, partitions[i], eachSize));
}
return partParams;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class GetNodesParam method split.
@Override
public List<PartitionGetParam> split() {
// Get matrix meta
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] partitions = meta.getPartitionKeys();
isHash = meta.isHash();
List<PartitionGetParam> params = new ArrayList<>();
Map<Integer, PartitionKey> pkeys = new HashMap<>();
for (PartitionKey pkey : partitions) {
pkeys.put(pkey.getPartitionId(), pkey);
}
for (int i = 0; i < partitionIds.length; i++) {
params.add(new PartGetNodesParam(matrixId, pkeys.get(partitionIds[i]), isHash));
}
return params;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class SampleNeighbor method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartSampleNeighborResult) result).getPartId(), result);
}
SampleNeighborParam param = (SampleNeighborParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartSampleNeighborParam) partParam).getStartIndex();
int end = ((PartSampleNeighborParam) partParam).getEndIndex();
PartSampleNeighborResult partResult = (PartSampleNeighborResult) (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 SampleNeighborResult(nodeIdToNeighbors);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class SampleNodeFeatsParam method split.
@Override
public List<PartitionGetParam> split() {
List<PartitionGetParam> params = new ArrayList<>();
List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
int eachSize = size / parts.size() + 1;
for (PartitionKey key : parts) {
params.add(new SampleNodeFeatsPartParam(matrixId, key, eachSize));
}
return params;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class SampleNeighbor method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartSampleNeighborResult) result).getPartId(), result);
}
SampleNeighborParam param = (SampleNeighborParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (PartitionGetParam partParam : partParams) {
int start = ((PartSampleNeighborParam) partParam).getStartIndex();
int end = ((PartSampleNeighborParam) partParam).getEndIndex();
PartSampleNeighborResult partResult = (PartSampleNeighborResult) (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 SampleNeighborResult(nodeIdToNeighbors);
}
Aggregations