use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.
the class RangeRouterUtils method splitLongLongVector.
public static KeyValuePart[] splitLongLongVector(MatrixMeta matrixMeta, LongLongVector vector) {
LongLongVectorStorage storage = vector.getStorage();
if (storage.isSparse()) {
// Get keys and values
LongLongSparseVectorStorage sparseStorage = (LongLongSparseVectorStorage) storage;
long[] keys = sparseStorage.getIndices();
long[] values = sparseStorage.getValues();
return split(matrixMeta, vector.getRowId(), keys, values, false);
} else {
// Key and value array pair
LongLongSortedVectorStorage sortStorage = (LongLongSortedVectorStorage) storage;
long[] keys = sortStorage.getIndices();
long[] values = sortStorage.getValues();
return split(matrixMeta, vector.getRowId(), keys, values, true);
}
}
use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.
the class RangeRouterUtils method splitIntDoubleVector.
public static KeyValuePart[] splitIntDoubleVector(MatrixMeta matrixMeta, IntDoubleVector vector) {
IntDoubleVectorStorage storage = vector.getStorage();
if (storage.isSparse()) {
// Get keys and values
IntDoubleSparseVectorStorage sparseStorage = (IntDoubleSparseVectorStorage) storage;
int[] keys = sparseStorage.getIndices();
double[] values = sparseStorage.getValues();
return split(matrixMeta, vector.getRowId(), keys, values, false);
} else if (storage.isDense()) {
// Get values
IntDoubleDenseVectorStorage denseStorage = (IntDoubleDenseVectorStorage) storage;
double[] values = denseStorage.getValues();
return split(matrixMeta, vector.getRowId(), values);
} else {
// Key and value array pair
IntDoubleSortedVectorStorage sortStorage = (IntDoubleSortedVectorStorage) storage;
int[] keys = sortStorage.getIndices();
double[] values = sortStorage.getValues();
return split(matrixMeta, vector.getRowId(), keys, values, true);
}
}
use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.
the class CompIntDoubleVectorSplitter method split.
@Override
public Map<PartitionKey, RowUpdateSplit> split(Vector vector, List<PartitionKey> parts) {
IntDoubleVector[] vecParts = ((CompIntDoubleVector) vector).getPartitions();
assert vecParts.length == parts.size();
Map<PartitionKey, RowUpdateSplit> updateSplitMap = new HashMap<>(parts.size());
for (int i = 0; i < vecParts.length; i++) {
updateSplitMap.put(parts.get(i), new CompIntDoubleRowUpdateSplit(vector.getRowId(), vecParts[i], (int) (parts.get(i).getEndCol() - parts.get(i).getStartCol())));
}
return updateSplitMap;
}
use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.
the class CompLongDoubleVectorSplitter method split.
@Override
public Map<PartitionKey, RowUpdateSplit> split(Vector vector, List<PartitionKey> parts) {
LongDoubleVector[] vecParts = ((CompLongDoubleVector) vector).getPartitions();
assert vecParts.length == parts.size();
Map<PartitionKey, RowUpdateSplit> updateSplitMap = new HashMap<>(parts.size());
for (int i = 0; i < vecParts.length; i++) {
updateSplitMap.put(parts.get(i), new CompLongDoubleRowUpdateSplit(vector.getRowId(), vecParts[i]));
}
return updateSplitMap;
}
use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.
the class RangeRouterUtils method splitLongIntVector.
public static KeyValuePart[] splitLongIntVector(MatrixMeta matrixMeta, LongIntVector vector) {
LongIntVectorStorage storage = vector.getStorage();
if (storage.isSparse()) {
// Get keys and values
LongIntSparseVectorStorage sparseStorage = (LongIntSparseVectorStorage) storage;
long[] keys = sparseStorage.getIndices();
int[] values = sparseStorage.getValues();
return split(matrixMeta, vector.getRowId(), keys, values, false);
} else {
// Key and value array pair
LongIntSortedVectorStorage sortStorage = (LongIntSortedVectorStorage) storage;
long[] keys = sortStorage.getIndices();
int[] values = sortStorage.getValues();
return split(matrixMeta, vector.getRowId(), keys, values, true);
}
}
Aggregations