Sorting and selection (take) operations.
sortIndices returns the indices that would sort an array or table. take selects elements by index. sortBy combines both for convenient table sorting by column name.
Types
SortKey = object handle*: ptr GArrowSortKey
- A column name and sort order pair.
SortOptions = object handle*: ptr GArrowSortOptions
- Options for multi-key sorting.
SortOrder = enum Ascending = 0, Descending = 1
- Sort direction: Ascending or Descending.
TakeOptions = object handle*: ptr GArrowTakeOptions
- Options for the take operation.
Procs
proc `=copy`(dest: var SortOptions; src: SortOptions) {....raises: [], tags: [], forbids: [].}
proc `=copy`(dest: var TakeOptions; src: TakeOptions) {....raises: [], tags: [], forbids: [].}
proc `=destroy`(x: SortKey) {....raises: [], tags: [], forbids: [].}
proc `=destroy`(x: SortOptions) {....raises: [], tags: [], forbids: [].}
proc `=destroy`(x: TakeOptions) {....raises: [], tags: [], forbids: [].}
proc `=dup`(x: SortOptions): SortOptions {....raises: [], tags: [], forbids: [].}
proc `=dup`(x: TakeOptions): TakeOptions {....raises: [], tags: [], forbids: [].}
proc `=wasMoved`(x: var SortKey) {....raises: [], tags: [], forbids: [].}
proc `=wasMoved`(x: var SortOptions) {....raises: [], tags: [], forbids: [].}
proc `=wasMoved`(x: var TakeOptions) {....raises: [], tags: [], forbids: [].}
proc newSortKey(name: string; order: SortOrder = Ascending): SortKey {. ...raises: [OperationError], tags: [], forbids: [].}
- Create a sort key from a column name and optional sort order.
proc newSortOptions(keys: openArray[SortKey]): SortOptions {....raises: [IOError], tags: [], forbids: [].}
proc newTakeOptions(): TakeOptions {....raises: [IOError], tags: [], forbids: [].}
proc sortBy(rb: RecordBatch; keys: openArray[(string, SortOrder)]): RecordBatch {. ...raises: [OperationError, IOError], tags: [], forbids: [].}
- Sort a record batch by the given column names and orders.
proc sortBy(table: ArrowTable; keys: openArray[(string, SortOrder)]): ArrowTable {. ...raises: [OperationError, IOError], tags: [], forbids: [].}
- Sort a table by the given column names and orders.
proc sortIndices(rb: RecordBatch; keys: openArray[SortKey]): Array[uint64] {. ...raises: [OperationError, IOError], tags: [], forbids: [].}
- Return indices that would sort the record batch by the given sort keys.
proc sortIndices(table: ArrowTable; keys: openArray[SortKey]): Array[uint64] {. ...raises: [IOError, OperationError], tags: [], forbids: [].}
-
Return indices that would sort the table by the given sort keys.
Example: .. code-block:: nim let idx = sortIndices(table, @newSortKey("age", Ascending)) let sorted = take(table, idx)
proc sortIndices[T](arr: Array[T]; order: SortOrder = Ascending): Array[uint64]
-
Return indices that would sort the array in the given order.
Example: .. code-block:: nim let arr = newArray(@3'i32, 1, 2) let idx = sortIndices(arr) # 1, 2, 0 let sorted = take(arr, idx) # 1, 2, 3
proc sortToIndices[T](arr: Array[T]): Array[uint64]
- Return indices that would sort the array (Acero sort-to-indices).
proc take(rb: RecordBatch; indices: Array[uint64]): RecordBatch {. ...raises: [OperationError, IOError], tags: [], forbids: [].}
- Return a new record batch with rows selected by the given indices.
proc take(table: ArrowTable; indices: Array[uint64]): ArrowTable {. ...raises: [IOError, OperationError], tags: [], forbids: [].}
- Return a new table with rows selected by the given indices.
proc take[T](arr: Array[T]; indices: Array[uint64]): Array[T]
-
Return a new array with elements selected by the given indices.
Example: .. code-block:: nim let arr = newArray(@10'i32, 20, 30) let result = take(arr, newArray(@2'u64, 0, 1)) # result == 30, 10, 20
proc takeChunkedArray[T](arr: Array[T]; indices: ChunkedArray[uint64]; options: TakeOptions = newTakeOptions()): ChunkedArray[ Untyped]
proc toPtr(x: SortKey): ptr GArrowSortKey {.inline, ...raises: [], tags: [], forbids: [].}
proc toPtr(x: SortOptions): ptr GArrowSortOptions {.inline, ...raises: [], tags: [], forbids: [].}
proc toPtr(x: TakeOptions): ptr GArrowTakeOptions {.inline, ...raises: [], tags: [], forbids: [].}