Package com.illumon.iris.db.util.config
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 Summary
Fields Modifier and Type Field Description static String
DB_CONFIG_NAMESPACE
static String
DB_CONFIG_TABLES
static String
INTERNAL_PARTITION_PREFIX
static com.fishlib.io.logger.Logger
log
-
Constructor Summary
Constructors Constructor Description InputTable(Database db, String namespace, String tableName)
InputTable(RemoteInputTableDescriptor.ToServer descriptor, ExportedObjectClient client, Database database)
InputTable(RemoteInputTableDescriptor baseDescriptor, RemoteInputTableDescriptor.InputTableFromServer descriptor, QueryProcessorConnection connection)
-
Method Summary
Modifier and Type Method Description void
add(Table newData)
Write newData to this table.void
addAttribute(String columnName, TableInputHandler.ColumnConfigAttribute configAttribute)
void
addColumns(String[] names, Class[] types)
Add a set of new columns to this input table.void
addColumns(Map<String,Class> columns)
Add a set of new columns to this input table.void
addRows(Database db, Map<String,Object>[] valueArray, boolean allowEdits, InputTableStatusListener listener)
Add the specified rows to the table, optionally overwriting existing keys.void
addRows(Map<String,Object>[] valueArray, boolean allowEdits, InputTableStatusListener listener)
Add the specified rows to the table, optionally overwriting existing keys.void
appendCentral(Table tableToAppend)
boolean
canEdit(Database database, com.fishlib.auth.UserContext userContext)
Queries whether the given user may edit this MutableInputTable.void
clearAttributes(String columnName)
static Table
cloneBlankInputTable(Database db, String namespace, String tableName, Table table)
Creates a new input table from the definition of an existing table.void
delete(Table table, Index rowsToDelete)
Delete the rows specified by table, and the set of rows to delete from the input table.void
deleteKeys(Map<String,Object[]> keyValue)
Delete the specified keys from the table.static TableInputHandler
getCurrentInputHandler(Database db, String namespace, String tableName)
Gets the current input table handler.Database
getDatabase()
com.illumon.iris.web.shared.data.InputTableDefinition
getDefinition()
Get the key and value columns names for this table.String
getDescription()
Return a user-readable description of this MutableInputTable.Object[]
getEnumsForColumn(String columnName)
FieldEntry
getFieldEntry(Object defaultValue, boolean isEdit, String columnName)
Create a proper FieldEntry for the specified column in the Deephaven Swing UI.String[]
getKeyNames()
Get the names of the key columnsString
getNamespace()
Table
getTable()
Returns a Deephaven table that contains the current data for this MutableInputTable.TableDefinition
getTableDefinition()
Get the underlying Table definition (which includes the names and types of all of the columns).String
getTableName()
boolean
hasColumn(String columnName)
Returns true if the specified column exists in this MutableInputTable.static Table
inputTable(Database db, String namespace, String tableName)
Returns an input table.boolean
isKey(String columnName)
Returns true if the specified column is a key.static Table
it(Database db, String namespace, String tableName)
Returns an input table.static InputTable
newInputTable(Database db, String namespace, String tableName, TableDefinition tableSchema, String... keys)
Creates a new input table.static InputTable
newInputTable(Database db, String namespace, String tableName, Table initialData, boolean removeExisting, String... keys)
Creates a new input table.static InputTable
newInputTable(Database db, String namespace, String tableName, Table initialData, String... keys)
Creates a new input table.static InputTable
newInputTable(Database db, String namespace, String tableName, TableInputHandler.ColumnConfig... columns)
void
remove()
Remove data, schema, and config entry for this InputTable.static void
remove(Database db, String namespace, String tableName)
Remove data, schema, and config entry for the named InputTablevoid
removeColumns(String... columns)
Remove the specified columns from the table.void
replace(Table newData)
void
setRows(Table table, int[] rowArray, Map<String,Object>[] valueArray, InputTableStatusListener listener)
Set the values of the columns specified by the input, filling in missing data using the parameter 'table' as the previous value source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
log
public static final com.fishlib.io.logger.Logger log -
DB_CONFIG_NAMESPACE
- See Also:
- Constant Field Values
-
DB_CONFIG_TABLES
- See Also:
- Constant Field Values
-
INTERNAL_PARTITION_PREFIX
-
-
Constructor Details
-
InputTable
public InputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOException- Throws:
IOException
-
InputTable
public InputTable(@NotNull RemoteInputTableDescriptor baseDescriptor, @NotNull RemoteInputTableDescriptor.InputTableFromServer descriptor, @NotNull QueryProcessorConnection connection) -
InputTable
public InputTable(@NotNull RemoteInputTableDescriptor.ToServer descriptor, @NotNull ExportedObjectClient client, @NotNull Database database)
-
-
Method Details
-
getCurrentInputHandler
@ScriptApi public static TableInputHandler getCurrentInputHandler(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOExceptionGets the current input table handler.- Parameters:
db
- databasenamespace
- namespacetableName
- 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 IOExceptionCreates a new input table from the definition of an existing table.- Parameters:
db
- databasenamespace
- namespacetableName
- table nametable
- 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 IOExceptionCreates a new input table.- Parameters:
db
- databasenamespace
- namespacetableName
- time tableinitialData
- initial datakeys
- 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 IOExceptionCreates a new input table.- Parameters:
db
- databasenamespace
- namespacetableName
- time tableinitialData
- initial dataremoveExisting
- remove an existing input tablekeys
- 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 IOExceptionCreates a new input table.- Parameters:
db
- databasenamespace
- namespacetableName
- time tabletableSchema
- table schemakeys
- keys- Returns:
- input table
- Throws:
IOException
- exception
-
it
@ScriptApi public static Table it(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOExceptionReturns an input table.- Parameters:
db
- databasenamespace
- namespacetableName
- table name- Returns:
- input table
- Throws:
IOException
- exception
-
inputTable
@ScriptApi public static Table inputTable(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOExceptionReturns an input table.- Parameters:
db
- databasenamespace
- namespacetableName
- table name- Returns:
- input table
- Throws:
IOException
- exception
-
remove
@ScriptApi public static void remove(@NotNull Database db, @NotNull String namespace, @NotNull String tableName) throws IOExceptionRemove data, schema, and config entry for the named InputTable- Parameters:
db
- the database objectnamespace
- namespace of the tabletableName
- name of the table- Throws:
IOException
-
getDatabase
- Specified by:
getDatabase
in interfaceMutableInputTable
-
getTable
Description copied from interface:MutableInputTable
Returns a Deephaven table that contains the current data for this MutableInputTable.- Specified by:
getTable
in interfaceMutableInputTable
- Returns:
- the current data in this MutableInputTable.
-
delete
@ScriptApi public void delete(@NotNull Table table, @NotNull Index rowsToDelete) throws IOExceptionDelete 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 interfaceMutableInputTable
- 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
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 interfaceInputTableRowSetter
- Parameters:
table
- The table to use as the previous value sourcerowArray
- 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 interfaceInputTableRowSetter
- 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 interfaceInputTableRowSetter
- 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 interfaceMutableInputTable
- Parameters:
defaultValue
- the default value of the fieldisEdit
- is this an edit (vs. an addition)columnName
- the name of the column.- Returns:
- a FieldEntry object for use in the swing UI
-
replace
- Throws:
IOException
-
add
Description copied from interface:MutableInputTable
Write newData to this table.- Specified by:
add
in interfaceMutableInputTable
- 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
- Throws:
IOException
-
appendCentral
- Specified by:
appendCentral
in interfaceInputTableAppender
- Throws:
IOException
-
remove
Remove data, schema, and config entry for this InputTable.- Throws:
IOException
- if db.closeAndDeleteCentral has a problem
-
isKey
Description copied from interface:MutableInputTable
Returns true if the specified column is a key.- Specified by:
isKey
in interfaceMutableInputTable
- Parameters:
columnName
- the column to interrogate- Returns:
- true if columnName is a key column, false otherwise
-
hasColumn
Description copied from interface:MutableInputTable
Returns true if the specified column exists in this MutableInputTable.- Specified by:
hasColumn
in interfaceMutableInputTable
- Parameters:
columnName
- the column to interrogate- Returns:
- true if columnName exists in this MutableInputTable
-
getEnumsForColumn
- Specified by:
getEnumsForColumn
in interfaceInputTableEnumGetter
-
getKeyNames
Description copied from interface:MutableInputTable
Get the names of the key columns- Specified by:
getKeyNames
in interfaceMutableInputTable
- Returns:
- an array with the names of our key columns
-
getNamespace
-
getTableName
-
addColumns
@ScriptApi public void addColumns(@NotNull String[] names, @NotNull Class[] types) throws IOExceptionAdd 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
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
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 interfaceMutableInputTable
- 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
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 interfaceMutableInputTable
- Returns:
- the TableDefinition for our user-visible table
-
getDescription
Description copied from interface:MutableInputTable
Return a user-readable description of this MutableInputTable.- Specified by:
getDescription
in interfaceMutableInputTable
- Returns:
- a description of this input table
-
canEdit
public boolean canEdit(@NotNull Database database, @NotNull com.fishlib.auth.UserContext userContext)Description copied from interface:MutableInputTable
Queries whether the given user may edit this MutableInputTable.- Specified by:
canEdit
in interfaceMutableInputTable
- Parameters:
database
- the Database object for this MutableInputTableuserContext
- the UserContext representing the user that would edit the table- Returns:
- true if the specified user may edit this MutableInputTable, false otherwise
-