use of com.tencent.angel.ps.storage.vector.storage.StorageMethod in project angel by Tencent.
the class NodeUtils method deserialize.
public static IntFloatVector deserialize(ByteBuf input) {
IntFloatVector feats;
int dim = input.readInt();
int len = input.readInt();
StorageMethod storageMethod = StorageMethod.valuesOf(input.readInt());
switch(storageMethod) {
case DENSE:
{
float[] values = new float[len];
for (int i = 0; i < len; i++) {
values[i] = input.readFloat();
}
feats = VFactory.denseFloatVector(values);
break;
}
case SPARSE:
{
feats = VFactory.sparseFloatVector(dim, len);
for (int i = 0; i < len; i++) {
feats.set(input.readInt(), input.readFloat());
}
break;
}
case SORTED:
{
int[] keys = new int[len];
float[] values = new float[len];
for (int i = 0; i < len; i++) {
keys[i] = input.readInt();
values[i] = input.readFloat();
}
feats = VFactory.sortedFloatVector(dim, keys, values);
break;
}
default:
throw new UnsupportedOperationException("Unsupport storage type " + storageMethod);
}
return feats;
}
use of com.tencent.angel.ps.storage.vector.storage.StorageMethod in project angel by Tencent.
the class NodeUtils method deserialize.
public static IntFloatVector deserialize(DataInputStream input) throws IOException {
IntFloatVector feats;
int dim = input.readInt();
int len = input.readInt();
StorageMethod storageMethod = StorageMethod.valuesOf(input.readInt());
switch(storageMethod) {
case DENSE:
{
float[] values = new float[len];
for (int i = 0; i < len; i++) {
values[i] = input.readFloat();
}
feats = VFactory.denseFloatVector(values);
break;
}
case SPARSE:
{
feats = VFactory.sparseFloatVector(dim, len);
for (int i = 0; i < len; i++) {
feats.set(input.readInt(), input.readFloat());
}
break;
}
case SORTED:
{
int[] keys = new int[len];
float[] values = new float[len];
for (int i = 0; i < len; i++) {
keys[i] = input.readInt();
values[i] = input.readFloat();
}
feats = VFactory.sortedFloatVector(dim, keys, values);
break;
}
default:
throw new UnsupportedOperationException("Unsupport storage type " + storageMethod);
}
return feats;
}
use of com.tencent.angel.ps.storage.vector.storage.StorageMethod in project angel by Tencent.
the class NodeUtils method deserialize.
public static IntFloatVector deserialize(DataInputStream input) throws IOException {
IntFloatVector feats;
int dim = input.readInt();
int len = input.readInt();
StorageMethod storageMethod = StorageMethod.valuesOf(input.readInt());
switch(storageMethod) {
case DENSE:
{
float[] values = new float[len];
for (int i = 0; i < len; i++) {
values[i] = input.readFloat();
}
feats = VFactory.denseFloatVector(values);
break;
}
case SPARSE:
{
feats = VFactory.sparseFloatVector(dim, len);
for (int i = 0; i < len; i++) {
feats.set(input.readInt(), input.readFloat());
}
break;
}
case SORTED:
{
int[] keys = new int[len];
float[] values = new float[len];
for (int i = 0; i < len; i++) {
keys[i] = input.readInt();
values[i] = input.readFloat();
}
feats = VFactory.sortedFloatVector(dim, keys, values);
break;
}
default:
throw new UnsupportedOperationException("Unsupport storage type " + storageMethod);
}
return feats;
}
use of com.tencent.angel.ps.storage.vector.storage.StorageMethod in project angel by Tencent.
the class NodeUtils method deserialize.
public static IntFloatVector deserialize(ByteBuf input) {
IntFloatVector feats;
int dim = input.readInt();
int len = input.readInt();
StorageMethod storageMethod = StorageMethod.valuesOf(input.readInt());
switch(storageMethod) {
case DENSE:
{
float[] values = new float[len];
for (int i = 0; i < len; i++) {
values[i] = input.readFloat();
}
feats = VFactory.denseFloatVector(values);
break;
}
case SPARSE:
{
feats = VFactory.sparseFloatVector(dim, len);
for (int i = 0; i < len; i++) {
feats.set(input.readInt(), input.readFloat());
}
break;
}
case SORTED:
{
int[] keys = new int[len];
float[] values = new float[len];
for (int i = 0; i < len; i++) {
keys[i] = input.readInt();
values[i] = input.readFloat();
}
feats = VFactory.sortedFloatVector(dim, keys, values);
break;
}
default:
throw new UnsupportedOperationException("Unsupport storage type " + storageMethod);
}
return feats;
}
Aggregations