Class ColumnVectors

java.lang.Object
io.deephaven.engine.table.vectors.ColumnVectors

public final class ColumnVectors extends Object
Utility methods for constructing Vectors from the columns of a Table, enabling random and bulk access to column data by row position.

Users should note that random access by row position (e.g. get methods) maybe be inefficient due to the need to convert row positions to row keys and acquire implementation-specific resources once per row. Thus, random access should generally be avoided when possible. On the other hand, bulk access methods (e.g. iterator and toArray methods) are generally quite efficient because they can amortize row position to row key conversions via iteration patterns and use bulk data movement operators.

Most usage of these APIs is perfectly safe, because script commands are run using an exclusive lock that inhibits concurrent update processing, and table listeners run during a period when it is always safe to access previous and current data for the table. That said, if the table is refreshing, it's important to note that the returned vectors are only valid for use during the current cycle (or Updating phase, when usePreviousValues = true). See Engine Locking for more information on safe, consistent data access. Direct vectors or copied arrays are always safe to use if they are created while the vector is valid.

  • Method Details

    • of

      public static Vector<?> of(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get a Vector of the data belonging to the specified column.

      See class-level documentation for more details on recommended usage and safety.

      Users should generally prefer one of the typed variants, e.g. ofChar or ofObject, rather than this method.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      A Vector of the data belonging to the specified column
    • of

      public static Vector<?> of(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get a Vector of the data belonging to the specified column.

      See class-level documentation for more details on recommended usage and safety.

      Users should generally prefer one of the typed variants, e.g. ofChar or ofObject, rather than this method.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      A Vector of the data belonging to the specified column
    • ofChar

      public static CharVector ofChar(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get a CharVector of the data belonging to the specified column, which must be of type char.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      A CharVector of the data belonging to the specified column
    • ofChar

      public static CharVector ofChar(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get a CharVector of the data belonging to the specified column, which must be of type char.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      A CharVector of the data belonging to the specified column
    • ofByte

      public static ByteVector ofByte(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get a ByteVector of the data belonging to the specified column, which must be of type byte.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      A ByteVector of the data belonging to the specified column
    • ofByte

      public static ByteVector ofByte(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get a ByteVector of the data belonging to the specified column, which must be of type byte.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      A ByteVector of the data belonging to the specified column
    • ofShort

      public static ShortVector ofShort(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get a ShortVector of the data belonging to the specified column, which must be of type short.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      A ShortVector of the data belonging to the specified column
    • ofShort

      public static ShortVector ofShort(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get a ShortVector of the data belonging to the specified column, which must be of type short.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      A ShortVector of the data belonging to the specified column
    • ofInt

      public static IntVector ofInt(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get an IntVector of the data belonging to the specified column, which must be of type int.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      An IntVector of the data belonging to the specified column
    • ofInt

      public static IntVector ofInt(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get an IntVector of the data belonging to the specified column, which must be of type int.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      An IntVector of the data belonging to the specified column
    • ofLong

      public static LongVector ofLong(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get a LongVector of the data belonging to the specified column, which must be of type long.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      A LongVector of the data belonging to the specified column
    • ofLong

      public static LongVector ofLong(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get a LongVector of the data belonging to the specified column, which must be of type long.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      A LongVector of the data belonging to the specified column
    • ofFloat

      public static FloatVector ofFloat(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get a FloatVector of the data belonging to the specified column, which must be of type float.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      A FloatVector of the data belonging to the specified column
    • ofFloat

      public static FloatVector ofFloat(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get a FloatVector of the data belonging to the specified column, which must be of type float.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      A FloatVector of the data belonging to the specified column
    • ofDouble

      public static DoubleVector ofDouble(@NotNull @NotNull Table table, @NotNull @NotNull String columnName)
      Get a DoubleVector of the data belonging to the specified column, which must be of type double.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      Returns:
      A DoubleVector of the data belonging to the specified column
    • ofDouble

      public static DoubleVector ofDouble(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, boolean usePreviousValues)
      Get a DoubleVector of the data belonging to the specified column, which must be of type double.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      A DoubleVector of the data belonging to the specified column
    • ofObject

      public static <DATA_TYPE> ObjectVector<DATA_TYPE> ofObject(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, @NotNull @NotNull Class<DATA_TYPE> type)
      Get an ObjectVector of the data belonging to the specified column, which must be of type DATA_TYPE.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      type - The data type of the column
      Returns:
      An ObjectVector of the data belonging to the specified column
    • ofObject

      public static <DATA_TYPE> ObjectVector<DATA_TYPE> ofObject(@NotNull @NotNull Table table, @NotNull @NotNull String columnName, @NotNull @NotNull Class<DATA_TYPE> type, boolean usePreviousValues)
      Get an ObjectVector of the data belonging to the specified column, which must be of type DATA_TYPE.

      See class-level documentation for more details on recommended usage and safety.

      Parameters:
      table - The Table to access column data from
      columnName - The name of the column to access
      type - The data type of the column
      usePreviousValues - Whether the resulting vector should contain the previous values of the column. This is only meaningful if table is refreshing, and only defined during the Updating phase of a cycle that isn't the instantiation cycle of table.
      Returns:
      An ObjectVector of the data belonging to the specified column