Interface ColumnCategorical<T>

Type Parameters:
T - the runtime value type stored in the column
All Superinterfaces:
Column, ColumnObject<T>

public interface ColumnCategorical<T> extends ColumnObject<T>
An object column optimised for repeated values by storing dictionary-encoded categories.
  • Method Details

    • constant

      static <T> ColumnCategorical<T> constant(ColumnName name, T value, int size, Class<T> valueClass)
      Creates a constant categorical column with a type inferred from the value class.
      Type Parameters:
      T - the value type
      Parameters:
      name - the column name
      value - the repeated value, or null
      size - the number of rows
      valueClass - the runtime value class
      Returns:
      a constant categorical column
    • constant

      static <T> ColumnCategorical<T> constant(ColumnName name, T value, int size, Column.Type type)
      Creates a constant categorical column using an explicit column type.
      Type Parameters:
      T - the value type
      Parameters:
      name - the column name
      value - the repeated value, or null
      size - the number of rows
      type - the column type
      Returns:
      a constant categorical column
    • builder

      static <T> ColumnCategorical.Builder<T> builder(ColumnName name, Class<T> clazz)
      Creates a categorical column builder for the supplied value class.
      Type Parameters:
      T - the value type
      Parameters:
      name - the column name
      clazz - the runtime value class
      Returns:
      a categorical column builder
    • get

      T get(int i)
      Description copied from interface: ColumnObject
      Returns the value at the supplied row.
      Specified by:
      get in interface ColumnObject<T>
      Parameters:
      i - the zero-based row index
      Returns:
      the row value, or null when unset
    • getCategoryCode

      int getCategoryCode(int i)
      Returns the dictionary code stored at the supplied row.
      Parameters:
      i - the zero-based row index
      Returns:
      the category code for the row
    • getCategoryValue

      T getCategoryValue(int categoryCode)
      Resolves a dictionary code to its categorical value.
      Parameters:
      categoryCode - the dictionary code
      Returns:
      the value for that code, or null for the null category
    • getCategoryCodes

      int[] getCategoryCodes(int[] x)
      Returns the distinct category codes used by the column.
      Parameters:
      x - the destination array, or null
      Returns:
      an array of category codes
    • getCategoricalValues

      Collection<T> getCategoricalValues(Collection<T> x)
      Appends the distinct categorical values to the supplied collection.
      Parameters:
      x - the destination collection, or null
      Returns:
      a collection containing the categorical values
    • getUniques

      default Set<T> getUniques(Set<T> x)
      Description copied from interface: ColumnObject
      Collects the distinct set values from the column.
      Specified by:
      getUniques in interface ColumnObject<T>
      Parameters:
      x - the destination set, or null
      Returns:
      a set containing the unique values
    • view

      ColumnCategorical<T> view(ViewIndex rowIndex)
      Description copied from interface: Column
      Returns a projected view of this column using the supplied row mapping.
      Specified by:
      view in interface Column
      Specified by:
      view in interface ColumnObject<T>
      Parameters:
      rowIndex - the row mapping to apply
      Returns:
      a column view over the selected rows
    • toString

      default String toString(int i)
      Description copied from interface: Column
      Formats the value at the supplied row for display.
      Specified by:
      toString in interface Column
      Parameters:
      i - the zero-based row index
      Returns:
      the formatted row value, or an empty string when unset
    • getAsColumn

      default Column getAsColumn(int i)
      Description copied from interface: Column
      Returns a single-row column containing the value from the supplied row.
      Specified by:
      getAsColumn in interface Column
      Parameters:
      i - the row to extract
      Returns:
      a single-row column with the same column name
    • copy

      default ColumnCategorical<T> copy(ColumnName x)
      Description copied from interface: Column
      Creates a copy of this column with the supplied column name.
      Specified by:
      copy in interface Column
      Parameters:
      x - the name to assign to the copy
      Returns:
      a column containing the same values under the new name
    • compare

      default int compare(int i, int j)
      Description copied from interface: Column
      Compares two row values from this column using the column's ordering semantics.
      Specified by:
      compare in interface Column
      Parameters:
      i - the first row index
      j - the second row index
      Returns:
      a negative number, zero, or a positive number as the first row is less than, equal to, or greater than the second
    • select

      default Selection select(Predicate<T> f)
      Description copied from interface: ColumnObject
      Selects rows whose values satisfy the supplied predicate.
      Specified by:
      select in interface ColumnObject<T>
      Parameters:
      f - the predicate to test against each set value
      Returns:
      a selection containing the predicate result for each row
    • transform

      <S> ColumnCategorical<S> transform(Transformer<T,S> transformer)
      Transforms this categorical column into another categorical column.
      Specified by:
      transform in interface ColumnObject<T>
      Type Parameters:
      S - the transformed value type
      Parameters:
      transformer - the transformation to apply
      Returns:
      the transformed categorical column