use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class UnaryAggrParam 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 UnaryPartitionAggrParam(matrixId, part, rowId));
}
return partParams;
}
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) {
SampleNeighborParam param = (SampleNeighborParam) getParam();
long[] keys = param.getKeys();
Int2ObjectArrayMap<PartitionGetResult> partIdToResult = new Int2ObjectArrayMap<>();
for (PartitionGetResult result : partResults) {
partIdToResult.put(((SampleNeighborPartResult) result).getPartId(), result);
}
for (PartitionGetParam partParam : param.getParams()) {
SampleNeighborPartParam param0 = (SampleNeighborPartParam) partParam;
int start = param0.getStartIndex();
int end = param0.getEndIndex();
SampleNeighborPartResult result = (SampleNeighborPartResult) partIdToResult.get(param0.getPartKey().getPartitionId());
int[] indptr = result.getIndptr();
long[] neighbors = result.getNeighbors();
int[] sampleTypes = result.getTypes();
assert indptr.length == (end - start) + 1;
for (int i = start; i < end; i++) {
int keyIndex = index.get(keys[i]);
for (int j = indptr[i - start]; j < indptr[i - start + 1]; j++) {
long n = neighbors[j];
if (!index.containsKey(n)) {
index.put(n, index.size());
}
srcs.add(keyIndex);
dsts.add(index.get(n));
}
if (param.getSampleTypes()) {
for (int j = indptr[i - start]; j < indptr[i - start + 1]; j++) {
types.add(sampleTypes[j]);
}
}
}
}
return new ScalarAggrResult(0);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class GetColsParam method split.
@Override
public List<PartitionGetParam> split() {
List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
List<PartitionGetParam> params = new ArrayList<>();
int start = 0, end = 0;
for (PartitionKey pkey : pkeys) {
long startCol = pkey.getStartCol();
long endCol = pkey.getEndCol();
if (start < cols.length && cols[start] >= startCol) {
while (end < cols.length && cols[end] < endCol) end++;
long[] part = new long[end - start];
System.arraycopy(cols, start, part, 0, end - start);
params.add(new PartitionGetColsParam(matrixId, pkey, rows, part, func));
start = end;
}
}
return params;
}
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() {
List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
List<PartitionGetParam> partParams = new ArrayList<>(partitionIds.length);
Map<Integer, PartitionKey> partsMap = new HashMap<>();
for (PartitionKey pkey : parts) {
partsMap.put(pkey.getPartitionId(), pkey);
}
for (int i = 0; i < partitionIds.length; i++) {
partParams.add(new PartitionGetParam(matrixId, partsMap.get(partitionIds[i])));
}
return partParams;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class ReadTagParam method split.
@Override
public List<PartitionGetParam> split() {
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
KeyPart[] nodeIdsParts = RouterUtils.split(meta, rowId, nodeIds, false);
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;
}
Aggregations