Search in sources :

Example 1 with GetRowResult

use of com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult in project angel by Tencent.

the class GetNodes method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int size = 0;
    for (PartitionGetResult result : partResults) {
        if (result instanceof IndexPartGetLongResult) {
            size += ((IndexPartGetLongResult) result).getValues().length;
        }
    }
    long[] values = new long[size];
    int start = 0;
    for (PartitionGetResult result : partResults) {
        if (result instanceof IndexPartGetLongResult) {
            long[] vals = ((IndexPartGetLongResult) result).getValues();
            System.arraycopy(vals, 0, values, start, vals.length);
            start += vals.length;
        }
    }
    return new GetRowResult(ResponseType.SUCCESS, VFactory.denseLongVector(values));
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) GetRowResult(com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Example 2 with GetRowResult

use of com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult 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;
}
Also used : RowType(com.tencent.angel.ml.matrix.RowType) GetRowResult(com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult)

Example 3 with GetRowResult

use of com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult in project angel by Tencent.

the class GetNodes method merge.

@Override
public GetResult merge(List<PartitionGetResult> partResults) {
    int size = 0;
    for (PartitionGetResult result : partResults) {
        if (result instanceof IndexPartGetLongResult) {
            size += ((IndexPartGetLongResult) result).getValues().length;
        }
    }
    long[] values = new long[size];
    int start = 0;
    for (PartitionGetResult result : partResults) {
        if (result instanceof IndexPartGetLongResult) {
            long[] vals = ((IndexPartGetLongResult) result).getValues();
            System.arraycopy(vals, 0, values, start, vals.length);
            start += vals.length;
        }
    }
    return new GetRowResult(ResponseType.SUCCESS, VFactory.denseLongVector(values));
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) GetRowResult(com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult) PartitionGetResult(com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)

Aggregations

GetRowResult (com.tencent.angel.ml.matrix.psf.get.getrow.GetRowResult)3 PartitionGetResult (com.tencent.angel.ml.matrix.psf.get.base.PartitionGetResult)2 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)2 RowType (com.tencent.angel.ml.matrix.RowType)1