use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ByteBufSerdeUtils method deserializeVector.
public static Vector deserializeVector(ByteBuf in) {
int rowId = deserializeInt(in);
long dim = deserializeLong(in);
RowType type = RowType.valueOf(deserializeInt(in));
Vector vector;
switch(type) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
vector = deserializeIntDoubleVector(in, dim);
break;
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
vector = deserializeIntFloatVector(in, dim);
break;
case T_FLOAT_SPARSE_LONGKEY:
vector = deserializeLongFloatVector(in, dim);
break;
case T_INT_SPARSE_LONGKEY:
vector = deserializeLongIntVector(in, dim);
break;
// TODO: other vector type
default:
throw new UnsupportedOperationException("Unsupport vector type " + type);
}
vector.setRowId(rowId);
return vector;
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ByteBufSerdeUtils method deserializeKeyValuePart.
public static KeyValuePart deserializeKeyValuePart(ByteBuf in) {
boolean isComp = ByteBufSerdeUtils.deserializeBoolean(in);
KeyValuePart keyValuePart;
if (isComp) {
keyValuePart = new CompStreamKeyValuePart();
} else {
RouterType routerType = RouterType.valueOf(deserializeInt(in));
RowType keyValueType = RowType.valueOf(deserializeInt(in));
keyValuePart = DataPartFactory.createKeyValuePart(keyValueType, routerType);
}
keyValuePart.deserialize(in);
return keyValuePart;
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class RowSplitCombineUtils method combineIndexRowSplits.
/**
* Combine the row splits.
*
* @param matrixId Matrix id
* @param rowId row id
* @param resultSize keys number
* @param keyParts keys partitions
* @param valueParts values partitions
* @return merged vector
*/
public static Vector combineIndexRowSplits(int matrixId, int rowId, int resultSize, KeyPart[] keyParts, ValuePart[] valueParts) {
// Get matrix meta
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
RowType rowType = matrixMeta.getRowType();
switch(rowType) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
return combineIntDoubleIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
return combineIntFloatIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_INT_DENSE:
case T_INT_SPARSE:
return combineIntIntIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_LONG_DENSE:
case T_LONG_SPARSE:
return combineIntLongIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_DOUBLE_SPARSE_LONGKEY:
return combineLongDoubleIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_FLOAT_SPARSE_LONGKEY:
return combineLongFloatIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_INT_SPARSE_LONGKEY:
return combineLongIntIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_LONG_SPARSE_LONGKEY:
return combineLongLongIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
default:
throw new UnsupportedOperationException("unsupport row type " + rowType);
}
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class MergeUtils method combineIndexRowSplits.
/**
* Combine the row splits.
*
* @param matrixId Matrix id
* @param rowId row id
* @param resultSize keys number
* @param keyParts keys partitions
* @param valueParts values partitions
* @return merged vector
*/
public static Vector combineIndexRowSplits(int matrixId, int rowId, int resultSize, KeyPart[] keyParts, ValuePart[] valueParts) {
// Get matrix meta
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
RowType rowType = matrixMeta.getRowType();
switch(rowType) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
return combineIntDoubleIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
return combineIntFloatIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_INT_DENSE:
case T_INT_SPARSE:
return combineIntIntIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_LONG_DENSE:
case T_LONG_SPARSE:
return combineIntLongIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_DOUBLE_SPARSE_LONGKEY:
return combineLongDoubleIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_FLOAT_SPARSE_LONGKEY:
return combineLongFloatIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_INT_SPARSE_LONGKEY:
return combineLongIntIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
case T_LONG_SPARSE_LONGKEY:
return combineLongLongIndexRowSplits(matrixId, rowId, resultSize, keyParts, valueParts, matrixMeta);
default:
throw new UnsupportedOperationException("unsupport row type " + rowType);
}
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class IndexGet method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
long startTs = System.currentTimeMillis();
RowType rowType = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(param.getMatrixId()).getRowType();
GetRowResult result;
switch(rowType) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseDoubleVector((IndexGetParam) param, partResults));
break;
case T_DOUBLE_SPARSE_COMPONENT:
case T_DOUBLE_DENSE_COMPONENT:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseDoubleCompVector((IndexGetParam) param, partResults));
break;
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseFloatVector((IndexGetParam) param, partResults));
break;
case T_FLOAT_SPARSE_COMPONENT:
case T_FLOAT_DENSE_COMPONENT:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseFloatCompVector((IndexGetParam) param, partResults));
break;
case T_INT_DENSE:
case T_INT_SPARSE:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseIntVector((IndexGetParam) param, partResults));
break;
case T_INT_DENSE_COMPONENT:
case T_INT_SPARSE_COMPONENT:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseIntCompVector((IndexGetParam) param, partResults));
break;
case T_LONG_DENSE:
case T_LONG_SPARSE:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseLongVector((IndexGetParam) param, partResults));
break;
case T_LONG_DENSE_COMPONENT:
case T_LONG_SPARSE_COMPONENT:
result = new GetRowResult(ResponseType.SUCCESS, ValuesCombineUtils.mergeSparseLongCompVector((IndexGetParam) param, partResults));
break;
default:
throw new UnsupportedOperationException("Unsupport operation: update " + rowType + " to " + this.getClass().getName());
}
return result;
}
Aggregations