use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class InitDynamicNbrs method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
GeneralPartUpdateParam initParam = (GeneralPartUpdateParam) partParam;
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, initParam);
// Get nodes and features
ILongKeyAnyValuePartOp split = (ILongKeyAnyValuePartOp) initParam.getKeyValuePart();
long[] nodeIds = split.getKeys();
IElement[] neighbors = split.getValues();
row.startWrite();
try {
for (int i = 0; i < nodeIds.length; i++) {
LongArrayElement data = (LongArrayElement) neighbors[i];
DynamicNeighborElement ele = (DynamicNeighborElement) row.get(nodeIds[i]);
if (ele == null) {
ele = new DynamicNeighborElement();
ele.add(data.getData());
row.set(nodeIds[i], ele);
} else {
ele.add(data.getData());
}
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class Sample method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
PartSampleParam param = (PartSampleParam) partParam;
KeyPart keyPart = param.getIndicesPart();
int sampleType = param.getSampleType();
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
Long2IntOpenHashMap nodeIdToSizes = new Long2IntOpenHashMap(nodeIds.length);
for (int i = 0; i < nodeIds.length; i++) {
nodeIdToSizes.addTo(nodeIds[i], 1);
}
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
Random r = new Random();
long[] distinctNodeIds = new long[nodeIdToSizes.size()];
long[][] samples = new long[nodeIdToSizes.size()][];
ObjectIterator<Entry> iter = nodeIdToSizes.long2IntEntrySet().fastIterator();
int index = 0;
while (iter.hasNext()) {
Entry entry = iter.next();
distinctNodeIds[index] = entry.getLongKey();
TypeNeighborElement element = (TypeNeighborElement) row.get(distinctNodeIds[index]);
samples[index] = element.Sample(sampleType, r, distinctNodeIds[index], entry.getIntValue());
index++;
}
return new PartGetLongsResult(distinctNodeIds, samples);
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class NnzFeature method processRow.
@Override
public double processRow(ServerRow row) {
LongElementStorage storage = ((ServerLongAnyRow) row).getStorage();
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = storage.iterator();
long size = 0;
while (it.hasNext()) {
Node node = (Node) (it.next().getValue());
if (node.getFeats() != null) {
size++;
}
}
return size;
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class GraphMatrixUtils method getPSLongKeyRow.
public static ServerLongAnyRow getPSLongKeyRow(PSContext psContext, PartitionGetParam partParam) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
return (ServerLongAnyRow) (((RowBasedPartition) part).getRow(0));
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class GraphMatrixUtils method getPSLongKeyRow.
public static ServerLongAnyRow getPSLongKeyRow(PSContext psContext, GeneralPartGetParam partParam) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
return (ServerLongAnyRow) (((RowBasedPartition) part).getRow(0));
}
Aggregations