Search in sources :

Example 1 with RowType

use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.

the class MatrixOpLogCache method createMatrixOpLog.

private MatrixOpLog createMatrixOpLog(MatrixMeta matrixMeta) {
    int matrixId = matrixMeta.getId();
    String type = matrixMeta.getAttribute(MatrixConf.MATRIX_OPLOG_TYPE);
    boolean enableFilter = matrixMeta.getAttribute(MatrixConf.MATRIX_OPLOG_ENABLEFILTER, MatrixConf.DEFAULT_MATRIX_OPLOG_ENABLEFILTER).equalsIgnoreCase("true");
    if (type == null) {
        RowType rowType = matrixMeta.getRowType();
        switch(rowType) {
            case T_DOUBLE_DENSE:
                return new DenseDoubleMatrixOpLog(matrixId, enableFilter);
            case T_DOUBLE_SPARSE:
                return new SparseDoubleMatrixOplog(matrixId, enableFilter);
            case T_INT_DENSE:
                return new DenseIntMatrixOpLog(matrixId, enableFilter);
            case T_INT_SPARSE:
                return new SparseIntMatrixOpLog(matrixId, enableFilter);
            case T_FLOAT_DENSE:
                return new DenseFloatMatrixOplog(matrixId, enableFilter);
            case T_FLOAT_SPARSE:
                return new SparseFloatMatrixOpLog(matrixId, enableFilter);
            case T_DOUBLE_SPARSE_LONGKEY:
                return new SparseDoubleLongKeyMatrixOpLog(matrixId, enableFilter);
            case T_DOUBLE_SPARSE_LONGKEY_COMPONENT:
                return new CompSparseDoubleLongKeyMatrixOpLog(matrixId, enableFilter);
            case T_DOUBLE_SPARSE_COMPONENT:
                return new CompSparseDoubleMatrixOpLog(matrixId, enableFilter);
            case T_FLOAT_SPARSE_COMPONENT:
                return new CompSparseFloatMatrixOpLog(matrixId, enableFilter);
            case T_INT_SPARSE_COMPONENT:
                return new CompSparseIntMatrixOpLog(matrixId, enableFilter);
        }
    } else {
        MatrixOpLogType opLogType = MatrixOpLogType.valueOf(type);
        switch(opLogType) {
            case DENSE_DOUBLE:
                return new DenseDoubleMatrixOpLog(matrixId, enableFilter);
            case SPARSE_DOUBLE:
                return new SparseDoubleMatrixOplog(matrixId, enableFilter);
            case DENSE_INT:
                return new DenseIntMatrixOpLog(matrixId, enableFilter);
            case SPARSE_INT:
                return new SparseIntMatrixOpLog(matrixId, enableFilter);
            case DENSE_FLOAT:
                return new DenseFloatMatrixOplog(matrixId, enableFilter);
            case SPARSE_FLOAT:
                return new SparseFloatMatrixOpLog(matrixId, enableFilter);
            case SPARSE_DOUBLE_LONGKEY:
                return new SparseDoubleLongKeyMatrixOpLog(matrixId, enableFilter);
            case COMPONENT_SPARSE_DOUBLE:
                return new CompSparseDoubleMatrixOpLog(matrixId, enableFilter);
            case COMPONENT_SPARSE_FLOAT:
                return new CompSparseFloatMatrixOpLog(matrixId, enableFilter);
            case COMPONENT_SPARSE_INT:
                return new CompSparseIntMatrixOpLog(matrixId, enableFilter);
            case COMPONENT_SPARSE_DOUBLE_LONGKEY:
                return new CompSparseDoubleLongKeyMatrixOpLog(matrixId, enableFilter);
        }
    }
    return new DenseDoubleMatrixOpLog(matrixId, enableFilter);
}
Also used : RowType(com.tencent.angel.ml.matrix.RowType) MatrixOpLogType(com.tencent.angel.ml.matrix.MatrixOpLogType)

Example 2 with RowType

use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.

the class LongIndexGetFunc method partitionGet.

/**
 * Each server partition execute this function and return values of specified index.
 * @param partParam the partition parameter
 * @return values of specified index
 */
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
    ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
    if (part != null) {
        int rowId = ((LongIndexPartGetParam) partParam).getRowId();
        PartitionKey partKey = partParam.getPartKey();
        ServerRow row = part.getRow(rowId);
        RowType rowType = row.getRowType();
        switch(rowType) {
            case T_DOUBLE_SPARSE_LONGKEY:
            case T_DOUBLE_SPARSE_LONGKEY_COMPONENT:
                {
                    return new LongIndexGetResult(partKey, ((ServerSparseDoubleLongKeyRow) row).getValues(((LongIndexPartGetParam) partParam).getIndex()));
                }
            default:
                throw new UnsupportedOperationException("Unsupport operation: update " + rowType + " to " + this.getClass().getName());
        }
    }
    return null;
}
Also used : PartitionKey(com.tencent.angel.PartitionKey) RowType(com.tencent.angel.ml.matrix.RowType)

Example 3 with RowType

use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.

the class PartitionGetRowsResult method deserialize.

@Override
public void deserialize(ByteBuf buf) {
    int size = buf.readInt();
    rowSplits = new ArrayList<ServerRow>(size);
    for (int i = 0; i < size; i++) {
        RowType type = RowType.valueOf(buf.readInt());
        ServerRow rowSplit = null;
        switch(type) {
            case T_DOUBLE_DENSE:
                {
                    rowSplit = new ServerDenseDoubleRow();
                    break;
                }
            case T_DOUBLE_SPARSE:
                {
                    rowSplit = new ServerSparseDoubleRow();
                    break;
                }
            case T_INT_DENSE:
                {
                    rowSplit = new ServerDenseIntRow();
                    break;
                }
            case T_INT_SPARSE:
                {
                    rowSplit = new ServerSparseIntRow();
                    break;
                }
            case T_FLOAT_DENSE:
                {
                    rowSplit = new ServerDenseFloatRow();
                    break;
                }
            default:
                break;
        }
        rowSplit.deserialize(buf);
        rowSplits.add(rowSplit);
    }
}
Also used : RowType(com.tencent.angel.ml.matrix.RowType)

Example 4 with RowType

use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.

the class PartitionGetRowResult method deserialize.

@Override
public void deserialize(ByteBuf buf) {
    if (buf.readableBytes() == 0) {
        rowSplit = null;
        return;
    }
    RowType type = RowType.valueOf(buf.readInt());
    if (rowSplit == null) {
        switch(type) {
            case T_DOUBLE_DENSE:
                {
                    rowSplit = new ServerDenseDoubleRow();
                    break;
                }
            case T_DOUBLE_SPARSE:
                {
                    rowSplit = new ServerSparseDoubleRow();
                    break;
                }
            case T_DOUBLE_SPARSE_LONGKEY:
                {
                    rowSplit = new ServerSparseDoubleLongKeyRow();
                    break;
                }
            case T_INT_DENSE:
                {
                    rowSplit = new ServerDenseIntRow();
                    break;
                }
            case T_INT_SPARSE:
                {
                    rowSplit = new ServerSparseIntRow();
                    break;
                }
            case T_FLOAT_DENSE:
                {
                    rowSplit = new ServerDenseFloatRow();
                    break;
                }
            default:
                break;
        }
    }
    rowSplit.deserialize(buf);
}
Also used : RowType(com.tencent.angel.ml.matrix.RowType)

Example 5 with RowType

use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.

the class GetRowsSplitResponse method deserialize.

@Override
public void deserialize(ByteBuf buf) {
    super.deserialize(buf);
    if (buf.readableBytes() == 0) {
        rowsSplit = null;
        return;
    }
    int size = buf.readInt();
    rowsSplit = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        RowType type = RowType.valueOf(buf.readInt());
        ServerRow rowSplit = null;
        switch(type) {
            case T_DOUBLE_DENSE:
                {
                    rowSplit = new ServerDenseDoubleRow();
                    break;
                }
            case T_DOUBLE_SPARSE:
                {
                    rowSplit = new ServerSparseDoubleRow();
                    break;
                }
            case T_INT_DENSE:
                {
                    rowSplit = new ServerDenseIntRow();
                    break;
                }
            case T_FLOAT_DENSE:
                {
                    rowSplit = new ServerDenseFloatRow();
                    break;
                }
            case T_INT_SPARSE:
                {
                    rowSplit = new ServerSparseIntRow();
                    break;
                }
            default:
                break;
        }
        if (rowSplit != null) {
            rowSplit.deserialize(buf);
            rowsSplit.add(rowSplit);
        }
    }
}
Also used : RowType(com.tencent.angel.ml.matrix.RowType)

Aggregations

RowType (com.tencent.angel.ml.matrix.RowType)38 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)7 MatrixFilesMeta (com.tencent.angel.model.output.format.MatrixFilesMeta)7 IOException (java.io.IOException)7 Vector (com.tencent.angel.ml.math2.vector.Vector)5 IntDoubleVector (com.tencent.angel.ml.math2.vector.IntDoubleVector)4 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)4 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)4 LongIntVector (com.tencent.angel.ml.math2.vector.LongIntVector)3 PartitionKey (com.tencent.angel.PartitionKey)2 AngelException (com.tencent.angel.exception.AngelException)2 RowBasedMatrix (com.tencent.angel.ml.math2.matrix.RowBasedMatrix)2 IntIntVector (com.tencent.angel.ml.math2.vector.IntIntVector)2 IntLongVector (com.tencent.angel.ml.math2.vector.IntLongVector)2 LongDoubleVector (com.tencent.angel.ml.math2.vector.LongDoubleVector)2 ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)2 BlasDoubleMatrix (com.tencent.angel.ml.math2.matrix.BlasDoubleMatrix)1 BlasFloatMatrix (com.tencent.angel.ml.math2.matrix.BlasFloatMatrix)1 RBIntDoubleMatrix (com.tencent.angel.ml.math2.matrix.RBIntDoubleMatrix)1 RBIntFloatMatrix (com.tencent.angel.ml.math2.matrix.RBIntFloatMatrix)1