use of com.tencent.angel.ml.math2.vector.LongFloatVector in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
ServerRow ranks = psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 2);
FloatVector ranksVector = ServerRowUtils.getVector((ServerLongFloatRow) ranks);
long[] ret;
if (ranksVector instanceof IntFloatVector)
ret = gatherNodes((IntFloatVector) ranksVector, part.getPartitionKey().getStartCol());
else if (ranksVector instanceof LongFloatVector)
ret = gatherNodes((LongFloatVector) ranksVector, part.getPartitionKey().getStartCol());
else {
throw new AngelException("vector should be intfloat or longfloat but is " + ranksVector.getClass().getName());
}
return new IndexPartGetLongResult(part.getPartitionKey(), ret);
}
use of com.tencent.angel.ml.math2.vector.LongFloatVector in project angel by Tencent.
the class ByteBufSerdeUtils method serializeLongFloatVector.
// LongFloatVector
private static void serializeLongFloatVector(ByteBuf out, LongFloatVector vector) {
LongFloatVectorStorage storage = vector.getStorage();
if (storage.isSparse()) {
serializeInt(out, SPARSE_STORAGE_TYPE);
serializeInt(out, storage.size());
ObjectIterator<Long2FloatMap.Entry> iter = storage.entryIterator();
while (iter.hasNext()) {
Long2FloatMap.Entry e = iter.next();
serializeLong(out, e.getLongKey());
serializeFloat(out, e.getFloatValue());
}
} else if (storage.isSorted()) {
serializeInt(out, SORTED_STORAGE_TYPE);
long[] indices = vector.getStorage().getIndices();
float[] values = vector.getStorage().getValues();
serializeLongs(out, indices);
serializeFloats(out, values);
} else {
throw new UnsupportedOperationException("Unsupport storage type " + vector.getStorage().getClass());
}
}
use of com.tencent.angel.ml.math2.vector.LongFloatVector in project angel by Tencent.
the class ByteBufSerdeUtils method serializedLongFloatVectorLen.
public static int serializedLongFloatVectorLen(LongFloatVector vector) {
int len = 0;
LongFloatVectorStorage storage = vector.getStorage();
if (storage.isSparse()) {
len += serializedIntLen(SPARSE_STORAGE_TYPE);
len += serializedIntLen(storage.size());
len += storage.size() * (INT_LENGTH + FLOAT_LENGTH);
} else if (storage.isSorted()) {
len += serializedIntLen(SORTED_STORAGE_TYPE);
len += serializedLongsLen(vector.getStorage().getIndices());
len += serializedFloatsLen(vector.getStorage().getValues());
} else {
throw new UnsupportedOperationException("Unsupport storage type " + vector.getStorage().getClass());
}
return len;
}
use of com.tencent.angel.ml.math2.vector.LongFloatVector in project angel by Tencent.
the class ByteBufSerdeUtils method serializeLongIntVector.
// LongFloatVector
private static void serializeLongIntVector(ByteBuf out, LongIntVector vector) {
LongIntVectorStorage storage = vector.getStorage();
if (storage.isSparse()) {
serializeInt(out, SPARSE_STORAGE_TYPE);
serializeInt(out, storage.size());
ObjectIterator<Long2IntMap.Entry> iter = storage.entryIterator();
while (iter.hasNext()) {
Long2IntMap.Entry e = iter.next();
serializeLong(out, e.getLongKey());
serializeFloat(out, e.getIntValue());
}
} else if (storage.isSorted()) {
serializeInt(out, SORTED_STORAGE_TYPE);
long[] indices = vector.getStorage().getIndices();
int[] values = vector.getStorage().getValues();
serializeLongs(out, indices);
serializeInts(out, values);
} else {
throw new UnsupportedOperationException("Unsupport storage type " + vector.getStorage().getClass());
}
}
use of com.tencent.angel.ml.math2.vector.LongFloatVector in project angel by Tencent.
the class StreamSerdeUtils method serializeLongFloatVector.
// LongFloatVector
private static void serializeLongFloatVector(DataOutputStream out, LongFloatVector vector) throws IOException {
LongFloatVectorStorage storage = vector.getStorage();
if (storage.isSparse()) {
serializeInt(out, SPARSE_STORAGE_TYPE);
serializeInt(out, storage.size());
ObjectIterator<Long2FloatMap.Entry> iter = storage.entryIterator();
while (iter.hasNext()) {
Long2FloatMap.Entry e = iter.next();
serializeLong(out, e.getLongKey());
serializeFloat(out, e.getFloatValue());
}
} else if (storage.isSorted()) {
serializeInt(out, SORTED_STORAGE_TYPE);
long[] indices = vector.getStorage().getIndices();
float[] values = vector.getStorage().getValues();
serializeLongs(out, indices);
serializeFloats(out, values);
} else {
throw new UnsupportedOperationException("Unsupport storage type " + vector.getStorage().getClass());
}
}
Aggregations