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);
}
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;
}
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);
}
}
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);
}
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);
}
}
}
Aggregations