use of it.unimi.dsi.fastutil.floats.FloatArrayList in project angel by Tencent.
the class GetLabels 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();
ServerLongFloatRow row = (ServerLongFloatRow) psContext.getMatrixStorageManager().getRow(param.getPartKey(), 0);
LongArrayList keys = new LongArrayList();
FloatArrayList vals = new FloatArrayList();
for (int i = 0; i < nodeIds.length; i++) {
if (row.exist(nodeIds[i])) {
keys.add(nodeIds[i]);
vals.add(row.get(nodeIds[i]));
}
}
return new GetLabelsPartResult(keys.toLongArray(), vals.toFloatArray());
}
default:
{
// TODO: support String, Int, and Any type node id
throw new InvalidParameterException("Unsupport index type " + keyPart.getKeyType());
}
}
}
use of it.unimi.dsi.fastutil.floats.FloatArrayList in project angel by Tencent.
the class CooIntFloatMatrix method getRow.
@Override
public Vector getRow(int idx) {
IntArrayList cols = new IntArrayList();
FloatArrayList data = new FloatArrayList();
for (int i = 0; i < rowIndices.length; i++) {
if (rowIndices[i] == idx) {
cols.add(colIndices[i]);
data.add(values[i]);
}
}
IntFloatSparseVectorStorage storage = new IntFloatSparseVectorStorage(shape[1], cols.toIntArray(), data.toFloatArray());
return new IntFloatVector(getMatrixId(), idx, getClock(), shape[1], storage);
}
use of it.unimi.dsi.fastutil.floats.FloatArrayList in project angel by Tencent.
the class CsrFloatMatrix method getRow.
@Override
public Vector getRow(int idx) {
IntArrayList cols = new IntArrayList();
FloatArrayList data = new FloatArrayList();
int rowNum = indptr.length - 1;
assert (idx < rowNum);
for (int i = indptr[idx]; i < indptr[idx + 1]; i++) {
cols.add(indices[i]);
data.add(values[i]);
}
IntFloatSparseVectorStorage storage = new IntFloatSparseVectorStorage(shape[1], cols.toIntArray(), data.toFloatArray());
return new IntFloatVector(getMatrixId(), idx, getClock(), shape[1], storage);
}
use of it.unimi.dsi.fastutil.floats.FloatArrayList in project angel by Tencent.
the class CooIntFloatMatrix method getCol.
@Override
public Vector getCol(int idx) {
IntArrayList cols = new IntArrayList();
FloatArrayList data = new FloatArrayList();
for (int i = 0; i < colIndices.length; i++) {
if (colIndices[i] == idx) {
cols.add(rowIndices[i]);
data.add(values[i]);
}
}
IntFloatSparseVectorStorage storage = new IntFloatSparseVectorStorage(shape[0], cols.toIntArray(), data.toFloatArray());
return new IntFloatVector(getMatrixId(), 0, getClock(), shape[0], storage);
}
use of it.unimi.dsi.fastutil.floats.FloatArrayList in project angel by Tencent.
the class CooLongFloatMatrix method getRow.
@Override
public Vector getRow(int idx) {
LongArrayList cols = new LongArrayList();
FloatArrayList data = new FloatArrayList();
for (int i = 0; i < rowIndices.length; i++) {
if (rowIndices[i] == idx) {
cols.add(colIndices[i]);
data.add(values[i]);
}
}
LongFloatSparseVectorStorage storage = new LongFloatSparseVectorStorage(shape[1], cols.toLongArray(), data.toFloatArray());
return new LongFloatVector(getMatrixId(), idx, getClock(), shape[1], storage);
}
Aggregations