use of com.tencent.angel.ml.math2.vector.LongDoubleVector in project angel by Tencent.
the class MergeUtils method combineLongDoubleIndexRowSplits.
// //////////////////////////////////////////////////////////////////////////////
// Combine Long key Double value vector
// //////////////////////////////////////////////////////////////////////////////
public static Vector combineLongDoubleIndexRowSplits(int matrixId, int rowId, int resultSize, KeyPart[] keyParts, ValuePart[] valueParts, MatrixMeta matrixMeta) {
LongDoubleVector vector = VFactory.sparseLongKeyDoubleVector(matrixMeta.getColNum(), resultSize);
for (int i = 0; i < keyParts.length; i++) {
mergeTo(vector, keyParts[i], (DoubleValuesPart) valueParts[i]);
}
vector.setRowId(rowId);
vector.setMatrixId(matrixId);
return vector;
}
use of com.tencent.angel.ml.math2.vector.LongDoubleVector in project angel by Tencent.
the class MergeUtils method combineServerLongDoubleRowSplits.
private static Vector combineServerLongDoubleRowSplits(List<ServerRow> rowSplits, MatrixMeta matrixMeta, int rowIndex) {
long colNum = matrixMeta.getColNum();
int elemNum = 0;
int size = rowSplits.size();
for (int i = 0; i < size; i++) {
elemNum += rowSplits.get(i).size();
}
LongDoubleVector row = VFactory.sparseLongKeyDoubleVector(colNum, elemNum);
row.setMatrixId(matrixMeta.getId());
row.setRowId(rowIndex);
Collections.sort(rowSplits, serverRowComp);
for (int i = 0; i < size; i++) {
if (rowSplits.get(i) == null) {
continue;
}
((ServerLongDoubleRow) rowSplits.get(i)).mergeTo(row);
}
return row;
}
use of com.tencent.angel.ml.math2.vector.LongDoubleVector in project angel by Tencent.
the class RowSplitCombineUtils method combineLongDoubleIndexRowSplits.
// //////////////////////////////////////////////////////////////////////////////
// Combine Long key Double value vector
// //////////////////////////////////////////////////////////////////////////////
public static Vector combineLongDoubleIndexRowSplits(int matrixId, int rowId, int resultSize, KeyPart[] keyParts, ValuePart[] valueParts, MatrixMeta matrixMeta) {
LongDoubleVector vector = VFactory.sparseLongKeyDoubleVector(matrixMeta.getColNum(), resultSize);
for (int i = 0; i < keyParts.length; i++) {
mergeTo(vector, keyParts[i], (DoubleValuesPart) valueParts[i]);
}
vector.setRowId(rowId);
vector.setMatrixId(matrixId);
return vector;
}
use of com.tencent.angel.ml.math2.vector.LongDoubleVector 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.LongDoubleVector in project angel by Tencent.
the class HashRouterUtils method split.
/**
* Split keys by matrix partition
*
* @param matrixMeta matrix meta data
* @param vector Matrix vector
* @return partition key to key partition map
*/
public static KeyValuePart[] split(MatrixMeta matrixMeta, Vector vector) {
KeyHash hasher = HasherFactory.getHasher(matrixMeta.getRouterHash());
PartitionKey[] matrixParts = matrixMeta.getPartitionKeys();
KeyValuePart[] dataParts = new KeyValuePart[matrixParts.length];
int estSize = (int) (vector.getSize() / matrixMeta.getPartitionNum());
for (int i = 0; i < dataParts.length; i++) {
dataParts[i] = generateDataPart(vector.getRowId(), vector.getType(), estSize);
}
switch(vector.getType()) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
{
splitIntDoubleVector(hasher, matrixMeta, (IntDoubleVector) vector, dataParts);
break;
}
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
{
splitIntFloatVector(hasher, matrixMeta, (IntFloatVector) vector, dataParts);
break;
}
case T_INT_DENSE:
case T_INT_SPARSE:
{
splitIntIntVector(hasher, matrixMeta, (IntIntVector) vector, dataParts);
break;
}
case T_LONG_DENSE:
case T_LONG_SPARSE:
{
splitIntLongVector(hasher, matrixMeta, (IntLongVector) vector, dataParts);
break;
}
case T_DOUBLE_SPARSE_LONGKEY:
{
splitLongDoubleVector(hasher, matrixMeta, (LongDoubleVector) vector, dataParts);
break;
}
case T_FLOAT_SPARSE_LONGKEY:
{
splitLongFloatVector(hasher, matrixMeta, (LongFloatVector) vector, dataParts);
break;
}
case T_INT_SPARSE_LONGKEY:
{
splitLongIntVector(hasher, matrixMeta, (LongIntVector) vector, dataParts);
break;
}
case T_LONG_SPARSE_LONGKEY:
{
splitLongLongVector(hasher, matrixMeta, (LongLongVector) vector, dataParts);
break;
}
default:
{
throw new UnsupportedOperationException("Unsupport vector type " + vector.getType());
}
}
for (int i = 0; i < dataParts.length; i++) {
if (dataParts[i] != null) {
dataParts[i].setRowId(vector.getRowId());
}
}
return dataParts;
}
Aggregations