use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam param) {
ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0);
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.iterator();
LongArrayList nodes = new LongArrayList();
long start = param.getPartKey().getStartCol();
while (it.hasNext()) {
Long2ObjectMap.Entry entry = it.next();
Node node = (Node) entry.getValue();
if (node.getFeats() != null && node.getNeighbors() == null) {
nodes.add(entry.getLongKey() + start);
}
}
return new IndexPartGetLongResult(param.getPartKey(), nodes.toLongArray());
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam param) {
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
ObjectIterator<Entry<IElement>> it = row.iterator();
LongArrayList nodes = new LongArrayList();
Boolean isHash = ((PartGetNodesParam) param).getHash();
long start = isHash ? 0 : param.getPartKey().getStartCol();
while (it.hasNext()) {
Long2ObjectMap.Entry entry = it.next();
GraphNode node = (GraphNode) entry.getValue();
if (node.getFeats() != null && node.getNeighbors() == null) {
nodes.add(entry.getLongKey() + start);
}
}
return new IndexPartGetLongResult(param.getPartKey(), nodes.toLongArray());
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 0);
LongArrayList ret = new LongArrayList();
row.startRead();
try {
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.iterator();
while (it.hasNext()) {
Long2ObjectMap.Entry<IElement> entry = it.next();
ret.add(entry.getLongKey() + partParam.getPartKey().getStartCol());
}
} finally {
row.endRead();
}
return new IndexPartGetLongResult(part.getPartitionKey(), ret.toLongArray());
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
ServerRow ranks = psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 2);
FloatVector ranksVector = ServerRowUtils.getVector((ServerLongFloatRow) ranks);
long[] ret;
if (ranksVector instanceof IntFloatVector)
ret = gatherNodes((IntFloatVector) ranksVector, part.getPartitionKey().getStartCol());
else if (ranksVector instanceof LongFloatVector)
ret = gatherNodes((LongFloatVector) ranksVector, part.getPartitionKey().getStartCol());
else {
throw new AngelException("vector should be intfloat or longfloat but is " + ranksVector.getClass().getName());
}
return new IndexPartGetLongResult(part.getPartitionKey(), ret);
}
use of com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult 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));
}
Aggregations