Package org.apache.sysds.runtime.compress.lib

# Class CLALibSort

java.lang.Object
org.apache.sysds.runtime.compress.lib.CLALibSort

public final class CLALibSort extends Object

## Method Summary

Modifier and Type
Method
Description
`static MatrixBlock`
`sort(CompressedMatrixBlock mb, SortIndex fn)`
Sort (order) a compressed matrix in place of the `order` built-in, while keeping the result compressed.
`static MatrixBlock`
`sort(CompressedMatrixBlock mb, MatrixValue weights, MatrixBlock result, int k)`
Compute the sorted value/weight table used by the quantile/median/IQM operations (the `sort` / qsort lop), exploiting compression to sort the few distinct values instead of all rows.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### sort

public static MatrixBlock sort(CompressedMatrixBlock mb, SortIndex fn)
Sort (order) a compressed matrix in place of the `order` built-in, while keeping the result compressed. The compressed fast-path only supports the case the user can benefit from: a single column held in a single column group, sorted ascending and returning the sorted values (not the index permutation). For everything else (multiple columns, multiple column groups, descending order, index return, or a column-group encoding without a sort implementation) this returns `null` so the caller can fall back to a decompressed reorg.

Parameters:
  `mb` - the compressed matrix to sort
  `fn` - the sort specification carried by the reorg operator
Returns:
  the sorted compressed matrix, or `null` if the compressed fast-path does not apply

### sort

public static MatrixBlock sort(CompressedMatrixBlock mb, MatrixValue weights, MatrixBlock result, int k)
Compute the sorted value/weight table used by the quantile/median/IQM operations (the `sort` / qsort lop), exploiting compression to sort the few distinct values instead of all rows. The compressed fast-path applies to an unweighted sort of a single column held in a single column group. The produced table is bit-for-bit identical to `MatrixBlock.sortOperations(MatrixValue, MatrixBlock, int)`: a `(1 + nnz) x 2` matrix holding one row per non-zero value (weight 1) plus a single collapsed row for the zeros (weight = number of zeros), sorted ascending by value. For every other case (weights present, multiple columns or groups, or an encoding without a sort implementation) it falls back to a decompressed sort.

Parameters:
  `mb` - the compressed matrix to sort
  `weights` - optional per-row weights, or `null`
  `result` - the result matrix (reused by the fallback)
  `k` - the parallelization degree
Returns:
  the sorted value/weight table