use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class InitNeighbor method partitionUpdate.
@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
PartInitNeighborParam param = (PartInitNeighborParam) 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<long[]>> iter = param.getNodeIdToNeighborIndices().long2ObjectEntrySet().iterator();
row.startWrite();
try {
while (iter.hasNext()) {
Long2ObjectMap.Entry<long[]> entry = iter.next();
row.set(entry.getLongKey(), new LongArrayElement(entry.getValue()));
}
} finally {
row.endWrite();
}
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class GetEdgeFeats method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
switch(keyPart.getKeyType()) {
case LONG:
{
// Long type node id
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
Long2ObjectOpenHashMap<IntFloatVector[]> nodeIdToFeats = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (long nodeId : nodeIds) {
if (row.get(nodeId) == null) {
// If node not exist, just skip
continue;
}
IntFloatVector[] edgeFeats = ((GraphNode) (row.get(nodeId))).getEdgeFeatures();
if (edgeFeats != null) {
nodeIdToFeats.put(nodeId, edgeFeats);
}
}
return new PartGetEdgeFeatsResult(param.getPartKey().getPartitionId(), nodeIdToFeats);
}
default:
{
// TODO: support String, Int, and Any type node id
throw new InvalidParameterException("Unsupport index type " + keyPart.getKeyType());
}
}
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class GetEdgeTypes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
switch(keyPart.getKeyType()) {
case LONG:
{
// Long type node id
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
Long2ObjectOpenHashMap<int[]> nodeIdToTypes = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (long nodeId : nodeIds) {
if (row.get(nodeId) == null) {
// If node not exist, just skip
continue;
}
int[] types = ((GraphNode) (row.get(nodeId))).getEdgeTypes();
if (types != null) {
nodeIdToTypes.put(nodeId, types);
}
}
return new PartGetIntArrayAttrsResult(param.getPartKey().getPartitionId(), nodeIdToTypes);
}
default:
{
// TODO: support String, Int, and Any type node id
throw new InvalidParameterException("Unsupport index type " + keyPart.getKeyType());
}
}
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class GetEdgeWeights method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
switch(keyPart.getKeyType()) {
case LONG:
{
// Long type node id
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
Long2ObjectOpenHashMap<float[]> nodeIdToWeights = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (long nodeId : nodeIds) {
if (row.get(nodeId) == null) {
// If node not exist, just skip
continue;
}
float[] weights = ((GraphNode) (row.get(nodeId))).getWeights();
if (weights != null) {
nodeIdToWeights.put(nodeId, weights);
}
}
return new PartGetFloatArrayAttrsResult(param.getPartKey().getPartitionId(), nodeIdToWeights);
}
default:
{
// TODO: support String, Int, and Any type node id
throw new InvalidParameterException("Unsupport index type " + keyPart.getKeyType());
}
}
}
use of com.tencent.angel.ps.storage.vector.ServerLongAnyRow in project angel by Tencent.
the class GetNeighbors method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
switch(keyPart.getKeyType()) {
case LONG:
{
// Long type node id
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
Long2ObjectOpenHashMap<long[]> nodeIdToNeighbors = new Long2ObjectOpenHashMap<>(nodeIds.length);
for (long nodeId : nodeIds) {
if (row.get(nodeId) == null) {
// If node not exist, just skip
continue;
}
long[] neighbors = ((GraphNode) (row.get(nodeId))).getNeighbors();
if (neighbors != null) {
nodeIdToNeighbors.put(nodeId, neighbors);
}
}
return new PartGetNeighborsResult(param.getPartKey().getPartitionId(), nodeIdToNeighbors);
}
default:
{
// TODO: support String, Int, and Any type node id
throw new InvalidParameterException("Unsupport index type " + keyPart.getKeyType());
}
}
}
Aggregations