use of com.tencent.angel.graph.client.psf.get.utils.PartGetIntArrayAttrsResult in project angel by Tencent.
the class GetNodeTypes 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))).getTypes();
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.graph.client.psf.get.utils.PartGetIntArrayAttrsResult 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());
}
}
}
Aggregations