Class InstantColumn

    • Field Detail

      • data

        protected it.unimi.dsi.fastutil.longs.LongArrayList data
    • Method Detail

      • 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<Instant>
      • 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<Instant>
      • createInternal

        public static InstantColumn createInternal​(String name,
                                                   long[] data)
        For internal Tablesaw use only Returns a new column with the given name and data
        Parameters:
        name - The column name
        data - An array of longs representing Instant values in Tablesaw internal format
      • valueIsMissing

        public static boolean valueIsMissing​(long value)
      • isMissing

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

        public boolean contains​(Instant dateTime)
        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<Instant>
      • setMissing

        public InstantColumn 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<Instant>
      • setPrintFormatter

        public void setPrintFormatter​(InstantColumnFormatter formatter)
        Sets the print formatter to the argument. The print formatter is used in pretty-printing and optionally for writing to text files like CSVs
      • lag

        public InstantColumn 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<Instant>
      • appendCell

        public InstantColumn appendCell​(String stringValue)
        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<Instant>
      • getString

        public String getString​(int row)
        Returns a string representation of the value at the given row.
        Specified by:
        getString in interface Column<Instant>
        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<Instant>
      • emptyCopy

        public InstantColumn 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<Instant>
        Parameters:
        rowSize - the initial row size
        Returns:
        a Column
      • clear

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

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

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

        public Table summary()
        Returns a table containing a ColumnType specific summary of the data in this column
        Specified by:
        summary in interface Column<Instant>
      • countUnique

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

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

        protected long getPackedInstant​(int index)
        Returns the long-encoded version of the instant at the given index
      • rowComparator

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

        public InstantColumn set​(Selection rowSelection,
                                 Instant 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(), Instant.now()); // no more missing values

        Specified by:
        set in interface Column<Instant>
        Overrides:
        set in class AbstractColumn<InstantColumn,​Instant>
      • countMissing

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

        public long[] asEpochSecondArray()
        Returns an array where each entry is the difference, measured in seconds, between the Instant and midnight, January 1, 1970 UTC.

        If a value is missing, InstantColumnType.missingValueIndicator() is used

      • asEpochSecondArray

        public long[] asEpochSecondArray​(ZoneOffset offset)
        Returns the seconds from epoch for each value as an array based on the given offset

        If a value is missing, InstantColumnType.missingValueIndicator() is used

      • asEpochMillisArray

        public long[] asEpochMillisArray()
        Returns an array where each entry is the difference, measured in milliseconds, between the Instant and midnight, January 1, 1970 UTC.

        If a missing value is encountered, InstantColumnType.missingValueIndicator() is inserted in the array

      • asEpochMillisArray

        public long[] asEpochMillisArray​(ZoneOffset offset)
        Returns an array where each entry is the difference, measured in milliseconds, between the Instant and midnight, January 1, 1970 UTC.

        If a missing value is encountered, InstantColumnType.missingValueIndicator() is inserted in the array

      • asLocalDateTimeColumn

        public DateTimeColumn asLocalDateTimeColumn()
        Returns a DateTimeColumn where each element is a representation of the associated Instant translated using UTC as the timezone
      • asLocalDateTimeColumn

        public DateTimeColumn asLocalDateTimeColumn​(ZoneId zone)
        Returns a DateTimeColumn where each element is a representation of the associated Instant translated using the argument as the timezone
      • append

        public InstantColumn append​(Column<Instant> 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<Instant>
      • set

        public InstantColumn set​(int row,
                                 Column<Instant> 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<Instant>
      • max

        public Instant max()
        Returns the largest instant value in the column
      • set

        public InstantColumn set​(int index,
                                 Instant value)
        Sets the value at index row to the given value and return this column
        Specified by:
        set in interface Column<Instant>
      • top

        public List<Instant> 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<Instant> 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
      • longIterator

        public it.unimi.dsi.fastutil.longs.LongIterator longIterator()
        Returns an iterator over the long representations of the instants in this column
      • asSet

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

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

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

        public double getDouble​(int i)
      • asDoubleArray

        public double[] asDoubleArray()
      • asObjectArray

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