Package tech.tablesaw.table
Class TableSlice
java.lang.Object
tech.tablesaw.table.Relation
tech.tablesaw.table.TableSlice
A TableSlice is a facade around a Relation that acts as a filter. Requests for data are forwarded
to the underlying table. A TableSlice can be sorted independently of the underlying table.
A TableSlice is only good until the structure of the underlying table changes.
-
Constructor Summary
ConstructorsConstructorDescriptionTableSlice
(Table table) Returns a new view constructed from the given table.TableSlice
(Table table, Selection rowSelection) Returns a new View constructed from the given table, containing only the rows represented by the bitmap -
Method Summary
Modifier and TypeMethodDescriptionaddColumns
(Column<?>... column) Adds the given columns to this Relation and returns the same relation.asTable()
Returns the data in this slice as a new Tablevoid
clear()
Clears all rows from this View, leaving the structure in placeColumn<?>
column
(int columnIndex) Returns the column at columnIndex (0-based)Column<?>
Returns the column with the given columnName, ignoring caseint
Returns the number of columns in the relationint
columnIndex
(Column<?> column) Returns the index of the given columnReturns a list containing the names of all the columns in this relationcolumns()
Returns a list of all the columns in the relationfirst
(int nRows) Returns a new table containing the first n rows in this Relationget
(int r, int c) Returns the value at the given row and column indexesgetTable()
Returns the backing table for this sliceiterator()
Iterate over the underlying rows in the source table.int
mappedRowNumber
(int rowNumber) Maps the view row number to the row number on the underlying source table.name()
Returns the name of this relationdouble
reduce
(String numberColumnName, NumericAggregateFunction function) Returns the result of applying the given function to the specified columnremoveColumns
(Column<?>... columns) Removes the given columns from this Relation and returns the same relation.void
Removes the selection from this view, leaving it with the same number of rows as the underlying source table.void
Removes the sort from this View.int
rowCount()
Returns the number of rows in the relationSets the name of this Relation and returns the same relation.void
Sort this view in place without modifying or copying the underlying source table.protected PrimitiveIterator.OfInt
IntIterator of source table row numbers that are present in this view.Methods inherited from class tech.tablesaw.table.Relation
as, booleanColumn, booleanColumn, booleanColumns, categoricalColumn, categoricalColumn, categoricalColumns, columnIndex, columns, columns, columnsOfType, colWidths, containsColumn, containsColumn, dateColumn, dateColumn, dateColumns, dateTimeColumn, dateTimeColumn, dateTimeColumns, doubleColumn, doubleColumn, floatColumn, floatColumn, getString, getString, getUnformatted, instantColumn, instantColumn, instantColumns, intColumn, intColumn, isEmpty, longColumn, longColumn, nCol, nCol, numberColumn, numberColumn, numberColumns, numericColumns, numericColumns, numericColumns, print, print, printAll, removeColumns, removeColumns, shape, shortColumn, shortColumn, smile, stringColumn, stringColumn, stringColumns, structure, summary, textColumn, textColumn, timeColumn, timeColumn, timeColumns, toString, typeArray, types
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TableSlice
Returns a new View constructed from the given table, containing only the rows represented by the bitmap -
TableSlice
Returns a new view constructed from the given table. The view can be sorted independently of the table.
-
-
Method Details
-
column
Returns the column at columnIndex (0-based) -
column
Returns the column with the given columnName, ignoring case -
columnCount
public int columnCount()Returns the number of columns in the relation- Specified by:
columnCount
in classRelation
-
rowCount
public int rowCount()Returns the number of rows in the relation -
columns
Returns a list of all the columns in the relation -
columnIndex
Returns the index of the given column- Specified by:
columnIndex
in classRelation
-
get
Returns the value at the given row and column indexes -
name
Returns the name of this relation -
getTable
Returns the backing table for this slice -
clear
public void clear()Clears all rows from this View, leaving the structure in place -
removeSort
public void removeSort()Removes the sort from this View. -
removeSelection
public void removeSelection()Removes the selection from this view, leaving it with the same number of rows as the underlying source table. -
columnNames
Returns a list containing the names of all the columns in this relation- Specified by:
columnNames
in classRelation
-
addColumns
Adds the given columns to this Relation and returns the same relation.- Specified by:
addColumns
in classRelation
- Returns:
- This Relation
-
removeColumns
Removes the given columns from this Relation and returns the same relation.- Specified by:
removeColumns
in classRelation
- Returns:
- This Relation
-
first
Returns a new table containing the first n rows in this Relation -
setName
Sets the name of this Relation and returns the same relation. -
asTable
Returns the data in this slice as a new Table -
sourceRowNumberIterator
IntIterator of source table row numbers that are present in this view. This can be used to in combination with the source table to iterate over the cells of a column in a sorted order without copying the column.- Returns:
- an int iterator of row numbers in the source table that are present in this view.
-
reduce
Returns the result of applying the given function to the specified column- Parameters:
numberColumnName
- The name of a numeric column in this tablefunction
- A numeric reduce function- Returns:
- the function result
- Throws:
IllegalArgumentException
- if numberColumnName doesn't name a numeric column in this table
-
iterator
Iterate over the underlying rows in the source table. If you set one of the rows while iterating it will change the row in the source table. -
mappedRowNumber
public int mappedRowNumber(int rowNumber) Maps the view row number to the row number on the underlying source table.- Parameters:
rowNumber
- the row number in the view.- Returns:
- the matching row number in the underlying table.
-
sortOn
Sort this view in place without modifying or copying the underlying source table. UnlikeTable.sortOn(Sort)
which returns a copy of the table, this method sorts the view in place.- Parameters:
key
- to sort on.
-