use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.
the class GeneralGetUtils method partitionGet.
public static PartitionGetResult partitionGet(PSContext psContext, PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
// Long type node id
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
// Get data
IElement[] data = new IElement[nodeIds.length];
for (int i = 0; i < nodeIds.length; i++) {
data[i] = row.get(nodeIds[i]);
}
MatrixMeta meta = psContext.getMatrixMetaManager().getMatrixMeta(param.getMatrixId());
try {
return new PartGeneralGetResult(meta.getValueClass(), nodeIds, data);
} catch (ClassNotFoundException e) {
throw new AngelException("Can not get value class ");
}
}
use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.
the class SampleNeighbor method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
PartSampleNeighborParam sampleParam = (PartSampleNeighborParam) partParam;
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, partParam);
ILongKeyPartOp split = (ILongKeyPartOp) sampleParam.getIndicesPart();
long[] nodeIds = split.getKeys();
Long2ObjectOpenHashMap<long[]> nodeId2SampleNeighbors = SampleUtils.sampleByCount(row, sampleParam.getCount(), nodeIds, System.currentTimeMillis());
return new PartSampleNeighborResult(sampleParam.getPartKey().getPartitionId(), nodeId2SampleNeighbors);
}
use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.
the class SampleEdgeFeat method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
PartSampleEdgeFeatParam sampleParam = (PartSampleEdgeFeatParam) partParam;
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, partParam);
ILongKeyPartOp split = (ILongKeyPartOp) sampleParam.getIndicesPart();
long[] nodeIds = split.getKeys();
Tuple2<Long2ObjectOpenHashMap<long[]>, Long2ObjectOpenHashMap<IntFloatVector[]>> nodeId2SampleNeighbors = SampleUtils.sampleEdgeFeat(row, sampleParam.getCount(), nodeIds, System.currentTimeMillis());
return new PartSampleEdgeFeatResult(sampleParam.getPartKey().getPartitionId(), nodeId2SampleNeighbors._1, nodeId2SampleNeighbors._2);
}
use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.
the class ReadTag method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
GeneralPartGetParam param = (GeneralPartGetParam) partParam;
KeyPart keyPart = param.getIndicesPart();
long[] nodeIds = ((ILongKeyPartOp) keyPart).getKeys();
ServerLongIntRow row = GraphMatrixUtils.getPSLongKeyIntRow(psContext, param, param.getRowId());
DynamicLongArray nodes = new DynamicLongArray(nodeIds.length);
for (int i = 0; i < nodeIds.length; i++) {
long nodeId = nodeIds[i];
if (row.get(nodeId) > 0) {
nodes.add(nodeId);
}
}
return new PartReadTagResult(nodes.getData());
}
use of com.tencent.angel.psagent.matrix.transport.router.operator.ILongKeyPartOp in project angel by Tencent.
the class GetCloseness method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
GetHyperLogLogPartParam param = (GetHyperLogLogPartParam) partParam;
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
ILongKeyPartOp keyPart = (ILongKeyPartOp) param.getNodes();
long[] nodes = keyPart.getKeys();
long n = param.getN();
Long2DoubleOpenHashMap closenesses = new Long2DoubleOpenHashMap();
for (int i = 0; i < nodes.length; i++) {
HyperLogLogPlusElement hllElem = (HyperLogLogPlusElement) row.get(nodes[i]);
if (hllElem.getCloseness() < n - 1) {
closenesses.put(nodes[i], 0);
} else {
closenesses.put(nodes[i], (double) n / (double) hllElem.getCloseness());
}
}
return new GetClosenessPartResult(closenesses);
}
Aggregations