use of com.tencent.angel.ps.storage.vector.element.IElement 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.element.IElement in project angel by Tencent.
the class ElementElementMapStorage method deserialize.
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
// Valid element number
int elementNum = buf.readInt();
data = new Object2ObjectOpenHashMap<>(elementNum);
// Deserialize the data
for (int i = 0; i < elementNum; i++) {
IElement elementKey = newElement();
IElement elementValue = newElement();
data.put(elementKey, elementValue);
elementKey.deserialize(buf);
elementValue.deserialize(buf);
}
}
use of com.tencent.angel.ps.storage.vector.element.IElement in project angel by Tencent.
the class StringElementMapStorage method deserialize.
@Override
public void deserialize(DataInputStream input) throws IOException {
super.deserialize(input);
// Valid element number
int elementNum = input.readInt();
data = new Object2ObjectOpenHashMap<>(elementNum);
// Deserialize the data
for (int i = 0; i < elementNum; i++) {
IElement element = newElement();
data.put(input.readUTF(), element);
element.deserialize(input);
}
}
use of com.tencent.angel.ps.storage.vector.element.IElement 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.ps.storage.vector.element.IElement in project angel by Tencent.
the class GetSort method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
RowBasedPartition part = (RowBasedPartition) matrix.getPartition(partParam.getPartKey().getPartitionId());
ServerLongAnyRow row = (ServerLongAnyRow) part.getRow(0);
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.getStorage().iterator();
row.startWrite();
try {
while (it.hasNext()) {
Long2ObjectMap.Entry<IElement> next = it.next();
DynamicNeighborElement ele = (DynamicNeighborElement) next.getValue();
if (ele != null) {
ele.trans();
}
}
} finally {
row.endWrite();
}
}
Aggregations