Class DateColumn

All Implemented Interfaces:
Iterable<LocalDate>, Comparator<LocalDate>, CategoricalColumn<LocalDate>, Column<LocalDate>, DateFillers<DateColumn>, DateFilters, DateMapFunctions, DateAndDateTimeFilterSpec<Selection>, FilterSpec<Selection>

A column that contains int-encoded local date values
  • Field Details

    • data

      protected it.unimi.dsi.fastutil.ints.IntArrayList data
      The data held in this column in its integer encoding form. See PackedLocalDate
  • Method Details

    • create

      public static DateColumn create(String name)
      Creates a new DateColumn with the given name. The column is completely empty.
    • createInternal

      public static DateColumn createInternal(String name, int[] data)
      Creates a new DateColumn with the given name and integer-encoded data. See PackedLocalDate for details of the encoding
    • create

      public static DateColumn create(String name, int initialSize)
      Creates a new DateColumn with the given name. The column contains initialSize missing values.
    • create

      public static DateColumn create(String name, Collection<LocalDate> data)
      Creates a new DateColumn with the given name and data
    • create

      public static DateColumn create(String name, LocalDate... data)
      Creates a new DateColumn with the given name and data
    • create

      public static DateColumn create(String name, Stream<LocalDate> stream)
      Creates a new DateColumn with the given name and data
    • size

      public int size()
      Returns the number of elements in this column, including missing values
      Specified by:
      size in interface Column<LocalDate>
    • subset

      public DateColumn subset(int[] rows)
      Return a column of the same type containing just those elements whose indexes are included in the given array
      Specified by:
      subset in interface Column<LocalDate>
      Overrides:
      subset in class AbstractColumn<DateColumn,LocalDate>
    • appendInternal

      public DateColumn appendInternal(int f)
    • set

      public DateColumn set(int index, int value)
    • set

      public DateColumn set(int index, LocalDate value)
      Sets the value at index row to the given value and return this column
      Specified by:
      set in interface Column<LocalDate>
    • setPrintFormatter

      public void setPrintFormatter(DateTimeFormatter dateTimeFormatter, String missingValueString)
      Creates and sets a printFormatter based-on the given DateTimeFormatter. Missing values will be printed as the given missingValueString. Non missing values will be handled by the dateTimeFormatter
    • setPrintFormatter

      public void setPrintFormatter(DateTimeFormatter dateTimeFormatter)
      Creates and sets a printFormatter based-on the given DateTimeFormatter. Missing values will be printed as empty strings. Non missing values will be handled by the dateTimeFormatter
    • setPrintFormatter

      public void setPrintFormatter(@Nonnull DateColumnFormatter dateColumnFormatter)
      Sets the print formatter to the argument
    • getString

      public String getString(int row)
      Returns a string representation of the value at the given row.
      Specified by:
      getString in interface Column<LocalDate>
      Parameters:
      row - The index of the row.
      Returns:
      value as String
    • getUnformattedString

      public String getUnformattedString(int row)
      Returns a String representation of the value at index r, without any formatting applied
      Specified by:
      getUnformattedString in interface Column<LocalDate>
    • emptyCopy

      public DateColumn emptyCopy()
      Returns a copy of the receiver with no data. The column name and type are the same.
      Specified by:
      emptyCopy in interface Column<LocalDate>
      Returns:
      a empty copy of Column
    • emptyCopy

      public DateColumn emptyCopy(int rowSize)
      Returns an empty copy of the receiver, with its internal storage initialized to the given row size.
      Specified by:
      emptyCopy in interface Column<LocalDate>
      Parameters:
      rowSize - the initial row size
      Returns:
      a Column
    • copy

      public DateColumn copy()
      Returns a deep copy of the receiver
      Specified by:
      copy in interface Column<LocalDate>
      Returns:
      a Column
    • clear

      public void clear()
      Removes all elements TODO: Make this return this column
      Specified by:
      clear in interface Column<LocalDate>
    • lead

      public DateColumn lead(int n)
      Returns a column of the same type as the receiver, containing the receivers values offset -n For example if you lead a column containing 2, 3, 4 by 1, you get a column containing 3, 4, NA.
      Specified by:
      lead in interface Column<LocalDate>
    • lag

      public DateColumn lag(int n)
      Returns a column of the same type and size as the receiver, containing the receivers values offset by n.

      For example if you lag a column containing 2, 3, 4 by 1, you get a column containing NA, 2, 3

      Specified by:
      lag in interface Column<LocalDate>
    • sortAscending

      public void sortAscending()
      Sorts my values in ascending order
      Specified by:
      sortAscending in interface Column<LocalDate>
    • sortDescending

      public void sortDescending()
      Sorts my values in descending order
      Specified by:
      sortDescending in interface Column<LocalDate>
    • countUnique

      public int countUnique()
      Returns the count of unique values in this column.
      Specified by:
      countUnique in interface Column<LocalDate>
      Returns:
      unique values as int
    • unique

      public DateColumn unique()
      Returns a column of the same type containing only the unique values
      Specified by:
      unique in interface Column<LocalDate>
      Returns:
      a Column
    • append

      public DateColumn append(Column<LocalDate> column)
      Appends all the values in the argument to the bottom of this column and return this column
      Specified by:
      append in interface Column<LocalDate>
    • append

      public DateColumn append(Column<LocalDate> column, int row)
      Appends the value at the given row in the given column to the bottom of this column and return this column
      Specified by:
      append in interface Column<LocalDate>
    • set

      public DateColumn set(int row, Column<LocalDate> column, int sourceRow)
      Sets the value at row to the value at sourceRow in the given column and return this column
      Specified by:
      set in interface Column<LocalDate>
    • max

      public LocalDate max()
      Specified by:
      max in interface DateMapFunctions
    • min

      public LocalDate min()
      Specified by:
      min in interface DateMapFunctions
    • set

      public DateColumn set(Selection rowSelection, LocalDate newValue)
      Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteria

      Example: myColumn.set(myColumn.valueIsMissing(), LocalDate.now()); // no more missing values

      Specified by:
      set in interface Column<LocalDate>
      Overrides:
      set in class AbstractColumn<DateColumn,LocalDate>
    • appendMissing

      public DateColumn appendMissing()
      Appends a missing value appropriate to the column
      Specified by:
      appendMissing in interface Column<LocalDate>
    • get

      public LocalDate get(int index)
      Returns the value at the given zero-based index
      Specified by:
      get in interface Column<LocalDate>
      Specified by:
      get in interface DateMapFunctions
    • isEmpty

      public boolean isEmpty()
      Returns true if the column has no data
      Specified by:
      isEmpty in interface Column<LocalDate>
      Returns:
      true if empty, false if not
    • rowComparator

      public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
      Returns an IntComparator for sorting my rows
      Specified by:
      rowComparator in interface Column<LocalDate>
    • append

      public DateColumn append(LocalDate value)
      Appends value to the bottom of this column and return this column
      Specified by:
      append in interface Column<LocalDate>
    • appendObj

      public DateColumn appendObj(Object obj)
      Appends the given value to the bottom of this column and return this column
      Specified by:
      appendObj in interface Column<LocalDate>
    • appendCell

      public DateColumn appendCell(String string)
      Add one element to the bottom of this column and set its value to the parsed value of the given String. Parsing is type-specific
      Specified by:
      appendCell in interface Column<LocalDate>
    • appendCell

      public DateColumn appendCell(String string, AbstractColumnParser<?> parser)
      Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parser
      Specified by:
      appendCell in interface Column<LocalDate>
    • getIntInternal

      public int getIntInternal(int index)
      Specified by:
      getIntInternal in interface DateFilters
      Specified by:
      getIntInternal in interface DateMapFunctions
    • getPackedDate

      protected int getPackedDate(int index)
    • summary

      public Table summary()
      Returns a table of dates and the number of observations of those dates
      Specified by:
      summary in interface Column<LocalDate>
      Returns:
      the summary table
    • valueIsMissing

      public static boolean valueIsMissing(int i)
    • countMissing

      public int countMissing()
      Returns the count of missing values in this column
      Specified by:
      countMissing in interface Column<LocalDate>
      Returns:
      missing values as int
    • top

      public List<LocalDate> top(int n)
      Returns the largest ("top") n values in the column
      Parameters:
      n - The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column
      Returns:
      A list, possibly empty, of the largest observations
    • bottom

      public List<LocalDate> bottom(int n)
      Returns the smallest ("bottom") n values in the column
      Parameters:
      n - The maximum number of records to return. The actual number will be smaller if n is greater than the number of observations in the column
      Returns:
      A list, possibly empty, of the smallest n observations
    • intIterator

      public it.unimi.dsi.fastutil.ints.IntIterator intIterator()
      Specified by:
      intIterator in interface DateFilters
    • removeMissing

      public DateColumn removeMissing()
      Returns a copy of this column with the missing values removed
      Specified by:
      removeMissing in interface Column<LocalDate>
    • asList

      public List<LocalDate> asList()
      Returns a list of all the elements in this column

      Note, if a value in the column is missing, a null is added in it's place

      Specified by:
      asList in interface Column<LocalDate>
    • where

      public DateColumn where(Selection selection)
      Returns a new column containing the subset referenced by the Selection
      Specified by:
      where in interface Column<LocalDate>
      Specified by:
      where in interface DateFilters
    • asSet

      public Set<LocalDate> asSet()
      Returns a Set containing all the unique values in this column
      Specified by:
      asSet in interface Column<LocalDate>
    • contains

      public boolean contains(LocalDate localDate)
      Returns true if the given object appears in this column, and false otherwise

      TODO override in column subtypes for performance

      Specified by:
      contains in interface Column<LocalDate>
    • setMissing

      public DateColumn setMissing(int i)
      Sets the value at index i to the missing-value indicator for this column type, and return this column
      Specified by:
      setMissing in interface Column<LocalDate>
    • asDoubleArray

      public double[] asDoubleArray()
    • asDoubleColumn

      public DoubleColumn asDoubleColumn()
    • isMissing

      public boolean isMissing(int rowNumber)
      Returns true if the value at rowNumber is missing
      Specified by:
      isMissing in interface Column<LocalDate>
    • getDouble

      public double getDouble(int i)
    • byteSize

      public int byteSize()
      Returns the width of a cell in this column, in bytes.
      Specified by:
      byteSize in interface Column<LocalDate>
      Returns:
      width in bytes
    • valueHash

      public int valueHash(int rowNumber)
      Returns an int suitable as a hash for the value in this column at the given index
      Specified by:
      valueHash in interface Column<LocalDate>
    • equals

      public boolean equals(int rowNumber1, int rowNumber2)
      Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2
      Specified by:
      equals in interface Column<LocalDate>
    • asBytes

      public byte[] asBytes(int rowNumber)
      Returns the contents of the cell at rowNumber as a byte[]
      Specified by:
      asBytes in interface Column<LocalDate>
      Parameters:
      rowNumber - the number of the row as int
      Returns:
      content as byte[]
    • iterator

      public Iterator<LocalDate> iterator()
      Returns an iterator over elements of type T.
      Specified by:
      iterator in interface Iterable<LocalDate>
      Returns:
      an Iterator.
    • fillWith

      public DateColumn fillWith(Iterator<LocalDate> iterator)
      Specified by:
      fillWith in interface DateFillers<DateColumn>
    • fillWith

      public DateColumn fillWith(Iterable<LocalDate> iterable)
      Specified by:
      fillWith in interface DateFillers<DateColumn>
    • fillWith

      public DateColumn fillWith(Supplier<LocalDate> supplier)
      Specified by:
      fillWith in interface DateFillers<DateColumn>
    • asObjectArray

      public LocalDate[] asObjectArray()
      Returns an array of objects as appropriate for my type of column
      Specified by:
      asObjectArray in interface Column<LocalDate>
    • compare

      public int compare(LocalDate o1, LocalDate o2)
      Specified by:
      compare in interface Comparator<LocalDate>