abstract classcamAxonPlugin::Grid

sys::Obj
  camAxonPlugin::Grid

@Js

Two dimensional tabular data structure composed of Cols and Rows. Grids may be created by factory methods on Etc. See docSkyspark

addCol

Source

Grid addCol(Str name, Obj? meta, |Row,Int->Obj? f)

Return a new grid with an additional column. The cells of the column are created by calling the mapping function for each row. The meta may be any value accepted by Etc.makeDict

addColMeta

Source

Grid addColMeta(Obj col, Obj? meta)

Return a new grid with additional column meta-data. The col parameter may be either a Col or column name. The meta may be any value accepted by Etc.makeDict

addMeta

Source

Grid addMeta(Obj? meta)

Return a new grid with additional grid level meta-data. The meta may be any value accepted by Etc.makeDict

all

Source

Bool all(|Row,Int->Bool f)

Return true if the function returns true for all of the rows in the grid. If the grid is empty, return false.

any

Source

Bool any(|Row,Int->Bool f)

Return true if the function returns true for any of the rows in the grid. If the grid is empty, return false.

col

Source

abstract Col? col(Str name, Bool checked := true)

Get a column by its name. If not resolved then return null or throw UnknownNameErr based on checked flag.

colDisNames

Source

Str[] colDisNames()

Convenience for cols mapped to Col.dis. The resulting list is safe for mutating.

colNames

Source

Str[] colNames()

Convenience for cols mapped to Col.name. The resulting list is safe for mutating.

cols

Source

abstract Col[] cols()

Columns

colsToLocale

Source

Grid colsToLocale()

Return a new Grid wich each col name mapped to its localized tag name if the col does not already have a display string. See Etc.tagToLocale and docSkySpark::Localization#tags.

commit

Source

Grid commit(Grid diffs)

Return a new Grid which is the result of applying the given diffs to this grid. The diffs must have the same number of rows as this grid. Any cells in the diffs with a Remove.val are removed from this grid, otherwise they are updated/added.

each

Source

abstract Void each(|Row,Int f)

Iterate the rows

eachWhile

Source

abstract Obj? eachWhile(|Row,Int->Obj? f)

Iterate every row until the function returns non-null. If function returns non-null, then break the iteration and return the resulting object. Return null if the function returns null for every item

find

Source

Row? find(|Row,Int->Bool f)

Find one matching row or return null if no matches. Also see findIndex and findAll.

findAll

Source

Grid findAll(|Row,Int->Bool f)

Return a new grid which finds matching the rows in this grid. The has the same meta and column definitions. Also see find.

findIndex

Source

Int? findIndex(|Row,Int->Bool f)

Find one matching row index or return null if no matches. Also see find.

first

Source

abstract Row? first()

Get the first row or return null if grid is empty.

get

Source

@Operator
abstract Row get(Int index)

Get a row by its index number. Throw UnsupportedErr is the grid doesn't support indexed based row access.

getRange

Source

@Operator
Grid getRange(Range r)

Return a new grid which is a slice of the rows in this grid. Negative indexes may be used to access from the end of the grid. The has the same meta and column definitions.

has

Source

Bool has(Str name)

Return if this grid contains the given column name.

isEmpty

Source

Bool isEmpty()

Convenience for size equal to zero.

isErr

Source

Bool isErr()

Return if this is an error grid - meta has "err" tag.

join

Source

Grid join(Grid that, Obj joinCol)

Join two grids by column name. The joinCol parameter may be a Col or col name. Current implementation requires:

  • grids cannot have conflicting col names (other than join col)
  • each row in both grids must have a unique value for join col
  • grid level meta is merged
  • join column meta is merged
keepCols

Source

Grid keepCols(Obj[] toKeep)

Return a new grid with all the columns removed except the given columns. The toKeep columns can be Col instances or column names.

last

Source

virtual Row? last()

Get the last row or return null if grid is empty. Throw UnsupportedErr is the grid doesn't support indexed based row access.

map

Source

Grid map(|Row,Int->Dict? f)

Return a new grid which maps the rows to new Dict. The grid meta and existing column meta are maintained. New columns have empty meta. If the mapping function returns null, then the row is removed.

meta

Source

abstract Dict meta()

Meta-data for entire grid

missing

Source

Bool missing(Str name)

Return if this grid does not contains the given column name.

removeCol

Source

Grid removeCol(Obj col)

Return a new grid with the given column removed. The col parameter may be either a Col or column name. If column doesn't exist return this grid.

removeCols

Source

Grid removeCols(Obj[] toRemove)

Return a new grid with all the given columns removed. The toRemove columns can be Col instances or column names.

renameCol

Source

Grid renameCol(Obj oldCol, Str newName)

Return a new grid with the given column renamed. The oldCol parameter may be a Col or col name.

reorderCols

Source

Grid reorderCols(Obj[] cols)

Return a new grid with the columns reordered. The given list of names represents the new order and must contain the same current Col instances or column names.

size

Source

abstract Int size()

Get the number of rows in the grid. Throw UnsupportedErr if the grid doesn't support a size.

sort

Source

Grid sort(|Row,Row->Int f)

Return a new Grid which is a copy of this grid with the rows sorted by the given comparator function.

sortCol

Source

Grid sortCol(Obj col)

Convenience for sort which sorts the given column by value. The col parameter can be a Col or a str name.

sortDis

Source

Grid sortDis()

Sort using Etc.compareDis and Dict.dis.

sortr

Source

Grid sortr(|Row,Row->Int f)

Return a new Grid which is a copy of this grid with the rows reverse sorted by the given comparator function.

unique

Source

Grid unique(Obj[] keyCols)

Return a new grid with only rows that define a unique key by the given key columns. If multiple rows have the same key cells, then the first row is returned and subsequent rows are removed. The keyCols can be Col instances or column names.