Search in sources :

Example 31 with LongDoubleVector

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;
}
Also used : LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector)

Example 32 with LongDoubleVector

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;
}
Also used : LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector) ServerLongDoubleRow(com.tencent.angel.ps.storage.vector.ServerLongDoubleRow)

Example 33 with LongDoubleVector

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;
}
Also used : LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector)

Example 34 with LongDoubleVector

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;
}
Also used : CompLongDoubleVector(com.tencent.angel.ml.math2.vector.CompLongDoubleVector) LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector) CompLongDoubleVector(com.tencent.angel.ml.math2.vector.CompLongDoubleVector) HashMap(java.util.HashMap) PartitionKey(com.tencent.angel.PartitionKey) RowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit) CompLongDoubleRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompLongDoubleRowUpdateSplit) CompLongDoubleRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompLongDoubleRowUpdateSplit)

Example 35 with LongDoubleVector

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;
}
Also used : IntLongVector(com.tencent.angel.ml.math2.vector.IntLongVector) LongIntVector(com.tencent.angel.ml.math2.vector.LongIntVector) LongLongVector(com.tencent.angel.ml.math2.vector.LongLongVector) IntIntVector(com.tencent.angel.ml.math2.vector.IntIntVector) LongFloatVector(com.tencent.angel.ml.math2.vector.LongFloatVector) CompStreamKeyValuePart(com.tencent.angel.psagent.matrix.transport.router.CompStreamKeyValuePart) KeyValuePart(com.tencent.angel.psagent.matrix.transport.router.KeyValuePart) IntFloatVector(com.tencent.angel.ml.math2.vector.IntFloatVector) IntDoubleVector(com.tencent.angel.ml.math2.vector.IntDoubleVector) LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector) KeyHash(com.tencent.angel.psagent.matrix.transport.router.KeyHash) PartitionKey(com.tencent.angel.PartitionKey)

Aggregations

LongDoubleVector (com.tencent.angel.ml.math2.vector.LongDoubleVector)55 LongDoubleVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleVectorStorage)47 LongDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleSparseVectorStorage)37 CompLongDoubleVector (com.tencent.angel.ml.math2.vector.CompLongDoubleVector)34 LongFloatVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatVectorStorage)32 LongIntVectorStorage (com.tencent.angel.ml.math2.storage.LongIntVectorStorage)32 LongLongVectorStorage (com.tencent.angel.ml.math2.storage.LongLongVectorStorage)32 IntDoubleVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage)30 IntFloatVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatVectorStorage)30 IntIntVectorStorage (com.tencent.angel.ml.math2.storage.IntIntVectorStorage)30 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)30 Storage (com.tencent.angel.ml.math2.storage.Storage)30 LongDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleSortedVectorStorage)26 IntDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSortedVectorStorage)20 IntDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSparseVectorStorage)20 IntFloatSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSortedVectorStorage)20 IntFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSparseVectorStorage)20 IntIntSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntIntSortedVectorStorage)20 IntIntSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntIntSparseVectorStorage)20 IntLongSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntLongSortedVectorStorage)20