use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult 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.PartitionGetResult 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.PartitionGetResult in project angel by Tencent.
the class SampleNeighbor method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Long2ObjectOpenHashMap<long[]> nodeIdToSampleNeighbors = new Long2ObjectOpenHashMap<>(((SampleNeighborParam) param).getNodeIds().length);
for (PartitionGetResult partResult : partResults) {
// Sample part result
PartSampleNeighborResult partSampleResult = (PartSampleNeighborResult) partResult;
// Neighbors
Long2ObjectOpenHashMap<long[]> partNodeIdToSampleNeighbors = partSampleResult.getNodeIdToSampleNeighbors();
if (partNodeIdToSampleNeighbors != null) {
nodeIdToSampleNeighbors.putAll(partNodeIdToSampleNeighbors);
}
}
return new SampleNeighborResult(nodeIdToSampleNeighbors);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class GetNodes method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
int size = 0;
for (PartitionGetResult result : partResults) {
if (result instanceof IndexPartGetLongResult) {
size += ((IndexPartGetLongResult) result).getValues().length;
}
}
long[] values = new long[size];
int start = 0;
for (PartitionGetResult result : partResults) {
if (result instanceof IndexPartGetLongResult) {
long[] vals = ((IndexPartGetLongResult) result).getValues();
System.arraycopy(vals, 0, values, start, vals.length);
start += vals.length;
}
}
return new GetRowResult(ResponseType.SUCCESS, VFactory.denseLongVector(values));
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult in project angel by Tencent.
the class GetProgress method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
GetProgressResult result = new GetProgressResult(true, 0.0);
boolean isFinished = true;
double percent = 0.0;
for (PartitionGetResult partResult : partResults) {
GetProgressPartitionResult part = (GetProgressPartitionResult) partResult;
isFinished = isFinished && part.isFinished();
percent += part.getPrecent();
}
percent /= partResults.size();
result.setFinished(isFinished);
result.setPrecent(percent);
return result;
}
Aggregations