use of com.tencent.angel.ps.storage.partition.ServerPartition in project angel by Tencent.
the class GraphMatrixUtils method getPSLongKeyRow.
public static ServerLongAnyRow getPSLongKeyRow(PSContext psContext, GeneralPartUpdateParam 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.partition.ServerPartition in project angel by Tencent.
the class GraphMatrixUtils method getPSIntKeyRow.
public static ServerIntAnyRow getPSIntKeyRow(PSContext psContext, GeneralPartUpdateParam partParam) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
return (ServerIntAnyRow) (((RowBasedPartition) part).getRow(0));
}
use of com.tencent.angel.ps.storage.partition.ServerPartition in project angel by Tencent.
the class GraphMatrixUtils method getPSIntKeyRow.
public static ServerIntAnyRow getPSIntKeyRow(PSContext psContext, PartitionGetParam partParam) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
return (ServerIntAnyRow) (((RowBasedPartition) part).getRow(0));
}
use of com.tencent.angel.ps.storage.partition.ServerPartition in project angel by Tencent.
the class GraphMatrixUtils method getPSLongKeyIntRow.
public static ServerLongIntRow getPSLongKeyIntRow(PSContext psContext, PartitionGetParam partParam, int rowId) {
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
return (ServerLongIntRow) (((RowBasedPartition) part).getRow(rowId));
}
use of com.tencent.angel.ps.storage.partition.ServerPartition in project angel by Tencent.
the class GetNeighborAliasTable method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
PartGetNeighborAliasTableParam param = (PartGetNeighborAliasTableParam) partParam;
ServerMatrix matrix = psContext.getMatrixStorageManager().getMatrix(partParam.getMatrixId());
ServerPartition part = matrix.getPartition(partParam.getPartKey().getPartitionId());
ServerLongAnyRow row = (ServerLongAnyRow) (((RowBasedPartition) part).getRow(0));
long[] nodeIds = param.getNodeIds();
long[][] neighbors = new long[nodeIds.length][];
int[] count = param.getCount();
Random r = new Random();
for (int i = 0; i < nodeIds.length; i++) {
long nodeId = nodeIds[i];
// Get node neighbor number
NeighborsAliasTableElement element = (NeighborsAliasTableElement) (row.get(nodeId));
if (element == null) {
neighbors[i] = null;
} else {
long[] nodeNeighbors = element.getNeighborIds();
if (nodeNeighbors == null || nodeNeighbors.length == 0 || count[i] <= 0) {
neighbors[i] = null;
} else {
neighbors[i] = new long[count[i]];
// start sampling by alias table for count times
float[] accept = element.getAccept();
int[] alias = element.getAlias();
for (int j = 0; j < count[i]; j++) {
int index = r.nextInt(nodeNeighbors.length);
float ac = r.nextFloat();
if (ac < accept[index]) {
neighbors[i][j] = nodeNeighbors[index];
} else {
neighbors[i][j] = nodeNeighbors[alias[index]];
}
}
}
}
}
return new PartGetNeighborAliasTableResult(part.getPartitionKey().getPartitionId(), neighbors);
}
Aggregations