Class InputTable

java.lang.Object
com.illumon.iris.db.util.config.InputTable
All Implemented Interfaces:
InputTableAppender, InputTableEnumGetter, InputTableRowSetter, MutableInputTable

public class InputTable extends Object implements InputTableAppender, MutableInputTable
A pseudo-table implementation that provides rudimentary CRUD-like operations on a user table.
  • Field Details

    • log

      public static final com.fishlib.io.logger.Logger log
    • DB_CONFIG_NAMESPACE

      public static final String DB_CONFIG_NAMESPACE
      See Also:
    • DB_CONFIG_TABLES

      public static final String DB_CONFIG_TABLES
      See Also:
    • INTERNAL_PARTITION_PREFIX

      public static final String INTERNAL_PARTITION_PREFIX
  • Constructor Details

  • Method Details

    • getCurrentInputHandler

      @ScriptApi public static TableInputHandler getCurrentInputHandler(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOException
      Gets the current input table handler.
      Parameters:
      db - database
      namespace - namespace
      tableName - table name
      Returns:
      current input table handler
      Throws:
      IOException - exception
    • newInputTable

      @ScriptApi public static InputTable newInputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName, @NotNull TableInputHandler.ColumnConfig... columns) throws IOException
      Throws:
      IOException
    • cloneBlankInputTable

      @ScriptApi public static Table cloneBlankInputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName, @NotNull Table table) throws IOException
      Creates a new input table from the definition of an existing table.
      Parameters:
      db - database
      namespace - namespace
      tableName - table name
      table - input table to clone
      Returns:
      new, cloned, empty input table
      Throws:
      IOException - exception
    • newInputTable

      @ScriptApi public static InputTable newInputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName, @NotNull Table initialData, @NotNull String... keys) throws IOException
      Creates a new input table.
      Parameters:
      db - database
      namespace - namespace
      tableName - time table
      initialData - initial data
      keys - keys
      Returns:
      input table
      Throws:
      IOException - exception
    • newInputTable

      @ScriptApi public static InputTable newInputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName, @NotNull Table initialData, boolean removeExisting, @NotNull String... keys) throws IOException
      Creates a new input table.
      Parameters:
      db - database
      namespace - namespace
      tableName - time table
      initialData - initial data
      removeExisting - remove an existing input table
      keys - keys
      Returns:
      input table
      Throws:
      IOException - exception
    • newInputTable

      @ScriptApi public static InputTable newInputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName, @NotNull TableDefinition tableSchema, @NotNull String... keys) throws IOException
      Creates a new input table.
      Parameters:
      db - database
      namespace - namespace
      tableName - time table
      tableSchema - table schema
      keys - keys
      Returns:
      input table
      Throws:
      IOException - exception
    • it

      @ScriptApi public static Table it(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOException
      Returns an input table.
      Parameters:
      db - database
      namespace - namespace
      tableName - table name
      Returns:
      input table
      Throws:
      IOException - exception
    • inputTable

      @ScriptApi public static Table inputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOException
      Returns an input table.
      Parameters:
      db - database
      namespace - namespace
      tableName - table name
      Returns:
      input table
      Throws:
      IOException - exception
    • remove

      @ScriptApi public static void remove(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOException
      Remove data, schema, and config entry for the named InputTable
      Parameters:
      db - the database object
      namespace - namespace of the table
      tableName - name of the table
      Throws:
      IOException
    • getDatabase

      public Database getDatabase()
      Specified by:
      getDatabase in interface MutableInputTable
    • getTable

      public Table getTable()
      Description copied from interface: MutableInputTable
      Returns a Deephaven table that contains the current data for this MutableInputTable.
      Specified by:
      getTable in interface MutableInputTable
      Returns:
      the current data in this MutableInputTable.
    • delete

      @ScriptApi public void delete(@NotNull Table table, @NotNull Index rowsToDelete) throws IOException
      Delete the rows specified by table, and the set of rows to delete from the input table. This method will block until the rows are deleted.
      Specified by:
      delete in interface MutableInputTable
      Parameters:
      table - The table containing the rows to delete.
      rowsToDelete - The index specifying which rows to delete.
      Throws:
      IOException - If a problem occurred during the deletion.
    • deleteKeys

      @ScriptApi public void deleteKeys(@NotNull Map<String,Object[]> keyValue) throws IOException
      Delete the specified keys from the table.
      Parameters:
      keyValue - the keys to delete.
      Throws:
      IOException - if the deletion fails
    • setRows

      public void setRows(@NotNull Table table, @NotNull int[] rowArray, @NotNull Map<String,Object>[] valueArray, @NotNull InputTableStatusListener listener)
      Description copied from interface: InputTableRowSetter
      Set the values of the columns specified by the input, filling in missing data using the parameter 'table' as the previous value source. This method will be invoked asynchronously. The input listener will be notified on success/failure
      Specified by:
      setRows in interface InputTableRowSetter
      Parameters:
      table - The table to use as the previous value source
      rowArray - The row indices to update.
      valueArray - The new values.
      listener - The listener to notify on asynchronous results.
    • addRows

      public void addRows(@NotNull Map<String,Object>[] valueArray, boolean allowEdits, @NotNull InputTableStatusListener listener)
      Description copied from interface: InputTableRowSetter
      Add the specified rows to the table, optionally overwriting existing keys. This method will execute asynchronously, the input listener will be notified on success/failure.
      Specified by:
      addRows in interface InputTableRowSetter
      Parameters:
      valueArray - The values to write.
      allowEdits - Should pre-existing keys be overwritten?
      listener - The listener to report asynchronous results to.
    • addRows

      public void addRows(@NotNull Database db, @NotNull Map<String,Object>[] valueArray, boolean allowEdits, @NotNull InputTableStatusListener listener)
      Description copied from interface: InputTableRowSetter
      Add the specified rows to the table, optionally overwriting existing keys. This method will execute asynchronously, the input listener will be notified on success/failure.
      Specified by:
      addRows in interface InputTableRowSetter
      Parameters:
      db - A db instance.
      valueArray - The values to write.
      allowEdits - Should pre-existing keys be overwritten?
      listener - The listener to report asynchronous results to.
    • getFieldEntry

      public FieldEntry getFieldEntry(@Nullable Object defaultValue, boolean isEdit, @NotNull String columnName)
      Description copied from interface: MutableInputTable
      Create a proper FieldEntry for the specified column in the Deephaven Swing UI.
      Specified by:
      getFieldEntry in interface MutableInputTable
      Parameters:
      defaultValue - the default value of the field
      isEdit - is this an edit (vs. an addition)
      columnName - the name of the column.
      Returns:
      a FieldEntry object for use in the swing UI
    • replace

      @ScriptApi public void replace(@NotNull Table newData) throws IOException
      Throws:
      IOException
    • add

      @ScriptApi public void add(@NotNull Table newData) throws IOException
      Description copied from interface: MutableInputTable
      Write newData to this table.
      Specified by:
      add in interface MutableInputTable
      Parameters:
      newData - the data to write to this table
      Throws:
      IOException - if there is an error writing the data
    • addAttribute

      @ScriptApi public void addAttribute(@NotNull String columnName, @NotNull TableInputHandler.ColumnConfigAttribute configAttribute) throws IOException
      Throws:
      IOException
    • clearAttributes

      @ScriptApi public void clearAttributes(@NotNull String columnName) throws IOException
      Throws:
      IOException
    • appendCentral

      public void appendCentral(@NotNull Table tableToAppend) throws IOException
      Specified by:
      appendCentral in interface InputTableAppender
      Throws:
      IOException
    • remove

      @ScriptApi public void remove() throws IOException
      Remove data, schema, and config entry for this InputTable.
      Throws:
      IOException - if db.closeAndDeleteCentral has a problem
    • isKey

      public boolean isKey(String columnName)
      Description copied from interface: MutableInputTable
      Returns true if the specified column is a key.
      Specified by:
      isKey in interface MutableInputTable
      Parameters:
      columnName - the column to interrogate
      Returns:
      true if columnName is a key column, false otherwise
    • hasColumn

      public boolean hasColumn(String columnName)
      Description copied from interface: MutableInputTable
      Returns true if the specified column exists in this MutableInputTable.
      Specified by:
      hasColumn in interface MutableInputTable
      Parameters:
      columnName - the column to interrogate
      Returns:
      true if columnName exists in this MutableInputTable
    • getEnumsForColumn

      public Object[] getEnumsForColumn(String columnName)
      Specified by:
      getEnumsForColumn in interface InputTableEnumGetter
    • getKeyNames

      public String[] getKeyNames()
      Description copied from interface: MutableInputTable
      Get the names of the key columns
      Specified by:
      getKeyNames in interface MutableInputTable
      Returns:
      an array with the names of our key columns
    • getNamespace

      public String getNamespace()
    • getTableName

      public String getTableName()
    • addColumns

      @ScriptApi public void addColumns(@NotNull String[] names, @NotNull Class[] types) throws IOException

      Add a set of new columns to this input table.

      Note that the new columns must not overwrite an existing column, or one of the internal config columns. see TableInputHandler.getRestrictedColumnNames()

      Parameters:
      names - The names of the new columns.
      types - The types of the new columns.
      Throws:
      IOException
      ImplNote:
      This method simply translates the inputs into a parameter for use by addColumns(Map).
    • addColumns

      @ScriptApi public void addColumns(@NotNull Map<String,Class> columns) throws IOException

      Add a set of new columns to this input table.

      Note that the new columns must not overwrite an existing column, or one of the internal config columns. see TableInputHandler.getRestrictedColumnNames()

      Parameters:
      columns - A map of new column names to their types.
      Throws:
      IOException - If an error occurs while adding the new columns.
    • removeColumns

      @ScriptApi public void removeColumns(@NotNull String... columns) throws IOException

      Remove the specified columns from the table.

      Note that key columns and internal config columns may not be removed see TableInputHandler.getRestrictedColumnNames()

      Parameters:
      columns - The columns to remove.
      Throws:
      IOException
    • getDefinition

      public com.illumon.iris.web.shared.data.InputTableDefinition getDefinition()
      Description copied from interface: MutableInputTable
      Get the key and value columns names for this table.
      Specified by:
      getDefinition in interface MutableInputTable
      Returns:
      abbreviated metadata for the input table; currently this is just the list of which columns are keys vs. values, but we'll want to stuff custom actions in there as well. We (currently) only want to send information that a client with a Table definition doesn't already know, but we may want to repeat table column definitions here in case they are mutated...
    • getTableDefinition

      public TableDefinition getTableDefinition()
      Description copied from interface: MutableInputTable
      Get the underlying Table definition (which includes the names and types of all of the columns).
      Specified by:
      getTableDefinition in interface MutableInputTable
      Returns:
      the TableDefinition for our user-visible table
    • getDescription

      public String getDescription()
      Description copied from interface: MutableInputTable
      Return a user-readable description of this MutableInputTable.
      Specified by:
      getDescription in interface MutableInputTable
      Returns:
      a description of this input table
    • canEdit

      public boolean canEdit(@NotNull Database database, @NotNull io.deephaven.enterprise.auth.UserContext userContext)
      Description copied from interface: MutableInputTable
      Queries whether the given user may edit this MutableInputTable.
      Specified by:
      canEdit in interface MutableInputTable
      Parameters:
      database - the Database object for this MutableInputTable
      userContext - the UserContext representing the user that would edit the table
      Returns:
      true if the specified user may edit this MutableInputTable, false otherwise