Class SortedColumnsAttribute

java.lang.Object
io.deephaven.engine.table.impl.SortedColumnsAttribute

public class SortedColumnsAttribute extends Object
Helper class for managing the sorted columns attribute.
  • Method Details

    • getOrderForColumn

      public static Optional<SortingOrder> getOrderForColumn(String attribute, String columnName)
      Retrieve the sorting order for a column from an attribute.
      Parameters:
      attribute - the Table's value of Table.SORTED_COLUMNS_ATTRIBUTE.
      columnName - the name of the column
      Returns:
      an optional containing the SortingOrder of the column if defined, empty otherwise
    • getOrderForColumn

      public static Optional<SortingOrder> getOrderForColumn(Table table, String columnName)
      Retrieve the sorting order for a column from a table.
      Parameters:
      table - the table to interrogate
      columnName - the name of the column
      Returns:
      an optional containing the SortingOrder of the column if defined, empty otherwise
    • isSortedBy

      public static boolean isSortedBy(Table table, String columnName, SortingOrder order)
      Determine if a table is sorted by the given column and order.
      Parameters:
      table - the table to interrogate
      columnName - the name of the column
      order - the order to check for
      Returns:
      true if table is sorted by columnName in the specified order
    • setOrderForColumn

      public static String setOrderForColumn(String attribute, String columnName, SortingOrder order)
      Pack the desired sorting order into a String attribute.
      Parameters:
      attribute - an attribute containing sorting order
      columnName - the column to update
      order - the order that the column is sorted in
      Returns:
      a String suitable for use as a Table.SORTED_COLUMNS_ATTRIBUTE value.
    • setOrderForColumn

      public static void setOrderForColumn(BaseTable<?> table, String columnName, SortingOrder order)
      Mark the table as sorted by the given column.
      Parameters:
      table - the table to update
      columnName - the column to update
      order - the order that the column is sorted in
    • withOrderForColumn

      public static Table withOrderForColumn(Table table, String columnName, SortingOrder order)
      Ensure that the result table is marked as sorted by the given column.

      Warning: this method performs no validation. If the column is not actually sorted in the declared order, range and match filters will silently return incorrect (missing or wrong) results with no error or warning. Prefer TableAssertions.assertSorted(io.deephaven.engine.table.Table, java.lang.String, io.deephaven.engine.table.impl.SortingOrder) instead whenever possible — it validates the sort order at call time for static tables and re-validates on every update for refreshing tables. Only use this method when you have an external guarantee that the data is sorted and the validation cost of assertSorted is unacceptable.

      Parameters:
      table - the table to update
      columnName - the column to update
      order - the order that the column is sorted in
      Returns:
      table, or a copy of it with the necessary attribute set
    • withOrderForColumn

      public static Table withOrderForColumn(Table table, String columnName, SortingOrder order, Map<String,?> additionalAttributes)
      Ensure that the result table is marked as sorted by the given column.

      Warning: this method performs no validation. If the column is not actually sorted in the declared order, range and match filters will silently return incorrect (missing or wrong) results with no error or warning. Prefer TableAssertions.assertSorted(io.deephaven.engine.table.Table, java.lang.String, io.deephaven.engine.table.impl.SortingOrder) instead whenever possible — it validates the sort order at call time for static tables and re-validates on every update for refreshing tables. Only use this method when you have an external guarantee that the data is sorted and the validation cost of assertSorted is unacceptable.

      Parameters:
      table - the table to update
      columnName - the column to update
      order - the order that the column is sorted in
      Returns:
      table, or a copy of it with the necessary attribute set
    • getSortedColumns

      public static List<SortColumn> getSortedColumns(Table table)
      Get the columns a Table is sorted by.
      Parameters:
      table - The table to interrogate
      Returns:
      A (possibly-empty) list of SortColumns representing columns the table is sorted on and their associated sort order