Class OnDiskDatabase
- All Implemented Interfaces:
Database
- Direct Known Subclasses:
OnDiskQueryDatabase
public abstract class OnDiskDatabase extends AbstractDatabase
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OnDiskDatabase.AuditEventLogDetails
Nested classes/interfaces inherited from interface com.illumon.iris.db.tables.databases.Database
Database.LogHandle, Database.StorageFormat
-
Field Summary
Fields Modifier and Type Field Description static File
DEFAULT_ROOT_DIRECTORY
protected LocalTablePathManager
locationManager
protected com.fishlib.io.logger.Logger
log
static String
ON_DISK_DATABASE_ROOT_DIRECTORY_PROP
protected PermissionFilterProvider
permissionFilterProvider
The PermissionFilterProvider that we'll use for this database.static TableDefinition
TABLE_DEFINITIONS_TABLE_DEFINITION
protected com.fishlib.auth.UserContext
userContext
The context for the user that we are operating as. -
Constructor Summary
Constructors Modifier Constructor Description OnDiskDatabase(com.fishlib.io.logger.Logger log, com.fishlib.configuration.Configuration configuration, NamespaceSet newNamespaceSet)
Create a Database that uses a well-known directory layout to configure itself and store its metadata.protected
OnDiskDatabase(com.fishlib.io.logger.Logger log, com.fishlib.configuration.Configuration configuration, File rootDirectory, NamespaceSet newNamespaceSet, SchemaService schemaService)
Delegate toOnDiskDatabase(Logger, File, SchemaService, NamespaceSet, boolean, boolean)
, ensuring that log is valid, and determining namespaceAclFilterEnabled and tableNamesAclFilterEnabled from configuration properties.OnDiskDatabase(com.fishlib.io.logger.Logger log, File rootDirectory, com.fishlib.configuration.Configuration configuration, NamespaceSet newNamespaceSet)
Create a Database that uses a well-known directory layout, at the given root, to configure itself and store its metadata.protected
OnDiskDatabase(com.fishlib.io.logger.Logger log, File rootDirectory, SchemaService schemaService, NamespaceSet newNamespaceSet, boolean namespaceAclFilterEnabled, boolean tableNamesAclFilterEnabled)
Create a Database that uses a well-known directory layout, at the given root, to configure itself and store its metadata. -
Method Summary
Modifier and Type Method Description void
addTable(String namespace, String tableName, Table table, Database.StorageFormat storageFormat)
Adds a non-partitioned table by name to the specified namespace.void
addTableDefinition(String namespace, String tableName, TableDefinition tableDefinition)
Adds a table definition to the specified namespace.void
addTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat)
Adds a single table partition (e.g.void
appendCentral(String namespace, String tableName, String columnPartitionValue, Table table, boolean flush)
Append to a table via a centralized table appender.protected abstract void
appendColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue, Table data)
protected abstract void
appendTable(TableDefinitionSchema schema, Table table)
void
appendTable(String namespace, String tableName, Table table)
Appends to a non-partitioned table, or adds the table if it is not present.void
appendTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue, Table data)
Adds or appends to a single table location (e.g.protected void
checkAllowAddColumnPartition(TableDefinitionSchema schema, Table newTable)
protected void
checkAllowAddNamespace(NamespaceSet namespaceSet, String namespace)
protected void
checkAllowAddSchema(TableDefinitionSchema schema)
protected void
checkAllowAddTable(TableDefinitionSchema schema, Table table)
protected void
checkAllowAddTableCentral(TableDefinitionSchema schema, Table table)
protected void
checkAllowCleanupNamespace(String namespace)
protected void
checkAllowDeleteColumnPartition(TableDefinitionSchema schema)
protected void
checkAllowIntradayOperation(TableDefinitionSchema schema)
protected void
checkAllowRemoveNamespace(String namespace)
protected void
checkAllowRemoveTable(TableDefinitionSchema schema)
protected void
checkAllowRemoveTableCentral(TableDefinitionSchema schema)
protected void
checkAllowRemoveTableDefinition(TableDefinitionSchema schema)
protected void
checkAllowRemoveTableDefinition(String namespace, String tableName)
protected void
checkAllowReplaceColumnPartition(TableDefinitionSchema schema, Table newTable)
protected void
checkAllowReplaceTable(TableDefinitionSchema schema, Table newTable)
protected void
checkAllowReplaceTableDefinition(TableDefinitionSchema schema)
protected abstract void
deleteBackupTable(TableDefinitionSchema schema)
protected abstract void
deleteColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue)
void
deleteMatchingTables(String namespace, String tableNameRegex)
Delete all files related to the set of tables whose names match the supplied regular expression.void
deleteNamespace(String namespace)
Delete all files related to the specified namespace.protected abstract void
deleteTable(TableDefinitionSchema schema)
void
deleteTables(String namespace, String... tableNames)
Delete all files related to a set of tables.AuditEventLogFormat2Logger
getAuditEventLogLogger()
Get the audit event logger associated with this database.Table
getCatalog()
Gets a table containing information on all tables in the DB.Table
getColumnDefinitionsTable()
TableWriter
getColumnPartitionTableWriter(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, TableDefinition prototypeTableDefinition, boolean append)
Gets a table writer for a partitioned table.protected abstract List<String>
getIntradayPartitions(TableDefinitionSchema schema)
List<String>
getIntradayPartitions(String namespace, String tableName)
Get a list of all internal partition values available for the specified intraday table.Table
getIntradayPartitionsAsTable(String namespace, String tableName)
Get all internal partition values available for the specified intraday table, returned as table.protected abstract Table
getIntradayTableV2(TableDefinitionSchema schema, boolean live)
protected Table
getIntradayTableV2(TableDefinitionSchema schema, String partitionName, boolean live)
protected abstract Table
getIntradayTableV2(TableDefinitionSchema schema, Set<String> partitionNames, boolean live)
Table
getIntradayTableV2(String namespace, String tableName, boolean live)
Retrieves an intraday table by namespace and name.Table
getIntradayTableV2(String namespace, String tableName, Set<String> internalPartitionValues, boolean live)
Retrieves the specified internal partitions of the specified intraday table.List<String>
getNamespaces()
Retrieves all namespace names from the database.PermissionFilterProvider
getPermissionFilterProvider()
File
getRootDirectory()
SchemaService
getSchemaService()
List<String>
getSystemNamespaces()
Retrieves system namespace names from the database.TableDefinition
getTableDefinition(String namespace, String tableName)
Retrieves a table definition by namespace and name, generally from the schema service.Table
getTableDefinitionsTable()
List<String>
getTableNames(String namespace)
Gets all table names from the specified namespace.Table
getTableV2(String namespace, String tableName)
Retrieves a table by namespace and name.TableWriter
getTableWriter(String namespace, String tableName, TableDefinition tableDefinition, boolean append)
Gets a table writer for an unpartitioned table.com.fishlib.auth.UserContext
getUserContext()
Gets the user authentication context.List<String>
getUserNamespaces()
Retrieves user namespace names from the database.protected abstract boolean
hasData(NamespaceSet set, TableDefinition tDef, String columnPartitionValue, boolean intraday)
boolean
hasImportedData(String namespace, String tableName, String columnPartitionValue)
Determines if the historical table's column partition is present in the DB.boolean
hasIntradayData(String namespace, String tableName, String columnPartitionValue)
Determines if the intraday table's column partition is present in the DB.boolean
hasIntradayTable(String namespace, String tableName)
Determines if the table is present in the DB and currently has intraday data.boolean
hasNamespace(String namespace)
Determines if the namespace is present in the DB.boolean
hasTable(String namespace, String tableName)
Determines if the table is defined in the DB.protected abstract void
installShadowTable(TableDefinitionSchema schema)
Database.LogHandle
logPartitionTableIncremental(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, boolean append)
Writes all changes in a table to a centrally managed table.Database.LogHandle
logPartitionTableIncremental(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, ReplayerInterface replayer, boolean append)
Writes all changes in a table to a centrally managed table.Database.LogHandle
logPartitionTableSnapshot(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, long logIntervalMillis, boolean append)
Snapshots a table at a regular interval and writes the snapshot to a centrally managed table.Database.LogHandle
logPartitionTableSnapshot(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, long logIntervalMillis, ReplayerInterface replayer, boolean append)
Snapshots a table at a regular interval and writes the snapshot to a centrally managed table.protected abstract void
moveTableToBackup(TableDefinitionSchema schema)
protected abstract void
overwriteColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat)
void
removeTable(String namespace, String tableName)
Removes a table.void
removeTableDefinition(String namespace, String tableName)
Deprecated.void
removeTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue)
Removes a single table location (e.g.void
repairMetadata(NamespaceSet namespaceSet, boolean fix)
Report on (and optionally fix) all table location metadata for the specified set of namespaces.void
repairMetadata(String namespace, boolean fix)
Report on (and optionally fix) all table location metadata for the specified namespace.void
repairMetadata(String namespace, String tableName, boolean fix)
Report on (and optionally fix) table location metadata issues for the specified namespace and table name.void
replaceTable(String namespace, String tableName, Table table, Database.StorageFormat storageFormat)
Replaces a non-partitioned table with a new table, or adds the table, if it is not already present.void
replaceTableDefinition(String namespace, String tableName, TableDefinition tableDefinition)
Replaces a user table definition.void
replaceTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat)
Replaces a single table location (e.g.protected abstract Table
restoreTable(TableDefinitionSchema schema, boolean isLive)
protected abstract void
rollbackTable(TableDefinitionSchema schema)
void
setAuditEventLogger(AuditEventLogFormat2Logger auditEventLogger, OnDiskDatabase.AuditEventLogDetails auditEventLogDetails)
PermissionFilterProvider
setUserContext(com.fishlib.io.logger.Logger log, com.fishlib.auth.UserContext userContext)
Set the user context for this database connection.void
setUserContextAndFilterProvider(com.fishlib.auth.UserContext userContext, PermissionFilterProvider permissionFilterProvider)
Set the user context and permission filter provider for this database connection.protected abstract void
storeColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat)
protected abstract void
storeShadowTable(TableDefinitionSchema schema, Table table, Database.StorageFormat storageFormat)
protected abstract void
storeTable(TableDefinitionSchema schema, Table table, Database.StorageFormat storageFormat)
protected abstract void
verifyNamespace(String namespace, String tableName)
Ensure the namespace exists.Methods inherited from class com.illumon.iris.db.tables.databases.AbstractDatabase
executeQuery, gc, getClientHost, getErrorLog, getProcessInfoId, getReplayer, getReplayer, getServerHost, getWorkerName, importClass, importStatic, logPartitionTableSnapshot, logPartitionTableSnapshot, makeRemote, mr, shutdown, startup
Methods inherited from class com.illumon.iris.db.tables.databases.BaseDatabase
addPartitionedTableDefinition, addPartitionedTableDefinition, addPartitionedTableDefinitionIfAbsent, addPartitionedTableDefinitionIfAbsent, addTablePartition, addTablePartitionAndDefinition, addTablePartitionAndDefinition, appendCentral, appendTablePartition, removeTablePartition, replaceTablePartition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.tables.databases.Database
addColumnPartitionAndDefinition, addColumnPartitionAndDefinition, addTable, addTablePartition, addTablePartition, closeAndDeleteCentral, closeAndDeleteCentral, getIntradayTable, getIntradayTable, getIntradayTable, getIntradayTable, getIntradayTable, getIntradayTable, getIntradayTableV2, getIntradayTableV2, getIntradayTableV2, getIntradayTableV2, getLastByTable, getReplayer, getReplayer, getReplayer, getTable, i, i, i, i, i, i, i2, i2, i2, i2, i2, i2, reloadData, replaceTable, replaceTablePartition, replaceTablePartition, rm, setWatchdogMillis, setWatchdogTimeoutProcedure, t, t2, timeTable, timeTable, timeTable, timeTable, timeTable, timeTable, timeTable, timeTable, timeTable, timeTable, timeTable, timeTable
-
Field Details
-
ON_DISK_DATABASE_ROOT_DIRECTORY_PROP
- See Also:
- Constant Field Values
-
DEFAULT_ROOT_DIRECTORY
-
locationManager
-
log
@NotNull protected final com.fishlib.io.logger.Logger log -
userContext
protected com.fishlib.auth.UserContext userContextThe context for the user that we are operating as. -
permissionFilterProvider
The PermissionFilterProvider that we'll use for this database. -
TABLE_DEFINITIONS_TABLE_DEFINITION
-
-
Constructor Details
-
OnDiskDatabase
public OnDiskDatabase(@Nullable com.fishlib.io.logger.Logger log, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull NamespaceSet newNamespaceSet)Create a Database that uses a well-known directory layout to configure itself and store its metadata.- Parameters:
log
- The logconfiguration
- use this ConfigurationnewNamespaceSet
- Which namespace set (directory) to add new namespaces to (e.g. Systems or Users)
-
OnDiskDatabase
public OnDiskDatabase(@Nullable com.fishlib.io.logger.Logger log, @NotNull File rootDirectory, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull NamespaceSet newNamespaceSet)Create a Database that uses a well-known directory layout, at the given root, to configure itself and store its metadata.- Parameters:
log
- The logrootDirectory
- The root for the well-known layout. If null, a default location is used.configuration
- use this Configuration to get the filtering properties to pass onnewNamespaceSet
- Which namespace set (directory) to add new namespaces to (e.g. Systems or Users)
-
OnDiskDatabase
protected OnDiskDatabase(@Nullable com.fishlib.io.logger.Logger log, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull File rootDirectory, @NotNull NamespaceSet newNamespaceSet, @NotNull SchemaService schemaService)Delegate toOnDiskDatabase(Logger, File, SchemaService, NamespaceSet, boolean, boolean)
, ensuring that log is valid, and determining namespaceAclFilterEnabled and tableNamesAclFilterEnabled from configuration properties.- Parameters:
log
- The logconfiguration
- use this Configuration to get the filtering properties to pass onrootDirectory
- The root for the well-known layout. If null, a default location is used.newNamespaceSet
- Which namespace set (directory) to add new namespaces to (e.g. Systems or Users)schemaService
- initialize with this schema service
-
OnDiskDatabase
protected OnDiskDatabase(@NotNull com.fishlib.io.logger.Logger log, @NotNull File rootDirectory, @NotNull SchemaService schemaService, @NotNull NamespaceSet newNamespaceSet, boolean namespaceAclFilterEnabled, boolean tableNamesAclFilterEnabled)Create a Database that uses a well-known directory layout, at the given root, to configure itself and store its metadata.- Parameters:
log
- The logrootDirectory
- The root for the well-known layout. If null, a default location is used.schemaService
- initialize with this schema servicenewNamespaceSet
- Which namespace set (directory) to add new namespaces to (e.g. Systems or Users)namespaceAclFilterEnabled
- should getNamespaces() only return namespaces with at least one visible table.tableNamesAclFilterEnabled
- should getTableNames() only return visible tables
-
-
Method Details
-
getSchemaService
Description copied from interface:Database
- Returns:
- The
SchemaService
that thisDatabase
was created with.
-
getRootDirectory
-
setAuditEventLogger
public void setAuditEventLogger(AuditEventLogFormat2Logger auditEventLogger, OnDiskDatabase.AuditEventLogDetails auditEventLogDetails) -
getAuditEventLogLogger
Get the audit event logger associated with this database.- Returns:
- the audit event logger, or null if one hasn't been associated with this database
-
setUserContext
public PermissionFilterProvider setUserContext(@Nullable com.fishlib.io.logger.Logger log, @Nullable com.fishlib.auth.UserContext userContext)Set the user context for this database connection.- Parameters:
log
- The logger to use for this database connectionuserContext
- The user context for this database connection- Returns:
- The PermissionFilterProvider that retrieves the filters given the user context.
-
setUserContextAndFilterProvider
public void setUserContextAndFilterProvider(com.fishlib.auth.UserContext userContext, PermissionFilterProvider permissionFilterProvider)Set the user context and permission filter provider for this database connection.- Parameters:
userContext
- the user context for this database connectionpermissionFilterProvider
- the PermissionFilterProvider that retrieves the filters
-
getUserContext
public com.fishlib.auth.UserContext getUserContext()Description copied from interface:Database
Gets the user authentication context.- Returns:
- user authentication context
-
getNamespaces
Description copied from interface:Database
Retrieves all namespace names from the database.- Returns:
- The list of namespace names
-
getSystemNamespaces
Description copied from interface:Database
Retrieves system namespace names from the database.- Returns:
- The list of namespace names
-
getUserNamespaces
Description copied from interface:Database
Retrieves user namespace names from the database.- Returns:
- The list of namespace names
-
getTableNames
Description copied from interface:Database
Gets all table names from the specified namespace.- Parameters:
namespace
- The namespace to list the contents of- Returns:
- The list of table names
-
getTableV2
Description copied from interface:Database
Retrieves a table by namespace and name. Throws exceptions for unknown tables.- Parameters:
namespace
- namespace of the tabletableName
- name of the table- Returns:
- table in "v2" format
-
getPermissionFilterProvider
-
getIntradayTableV2
Description copied from interface:Database
Retrieves an intraday table by namespace and name. Throws exceptions for unknown tables.- Parameters:
namespace
- namespace of the tabletableName
- name of the tablelive
- true if the table should be live/updating; false otherwise- Returns:
- intraday table
-
getIntradayTableV2
public Table getIntradayTableV2(String namespace, String tableName, Set<String> internalPartitionValues, boolean live)Description copied from interface:Database
Retrieves the specified internal partitions of the specified intraday table. The result may contain locations for multiple column partition values, and so a subsequent filter (e.g. on "Date") will often be desired.Throws exceptions for unknown tables.
- Parameters:
namespace
- namespace of the tabletableName
- name of the tableinternalPartitionValues
- locations will be restricted to these internal partition valueslive
- true if the table should be live/updating; false otherwise- Returns:
- single partition intraday table
-
getIntradayPartitions
Description copied from interface:Database
Get a list of all internal partition values available for the specified intraday table.- Parameters:
namespace
- The namespace of the tabletableName
- The table name to examine in the intraday data space- Returns:
- A list of internal partition values for top-level partitioning of the intraday table. Typically represents one partition per source.
-
getIntradayPartitionsAsTable
Description copied from interface:Database
Get all internal partition values available for the specified intraday table, returned as table.- Parameters:
namespace
- The namespace of the tabletableName
- The table name to examine in the intraday data space- Returns:
- A table containing the internal partition values for top-level partitioning of the intraday table. Typically represents one partition per source.
-
getTableDefinition
Description copied from interface:Database
Retrieves a table definition by namespace and name, generally from the schema service.- Parameters:
namespace
- The namespace of the definition to retrievetableName
- The table name of the definition to retrieve- Returns:
- The table definition retrieved, null if not found
-
checkAllowAddSchema
-
checkAllowAddNamespace
-
checkAllowRemoveNamespace
-
checkAllowAddTable
-
checkAllowAddTableCentral
-
getTableWriter
public TableWriter getTableWriter(String namespace, String tableName, TableDefinition tableDefinition, boolean append)Description copied from interface:Database
Gets a table writer for an unpartitioned table.- Parameters:
namespace
- table namespacetableName
- table nametableDefinition
- table definitionappend
- true to append to an existing partition; false to overwrite an existing partition.- Returns:
- table writer
- ImplNote:
- If the schema for this table exists, it must match the given tableDefinition.
OnDiskQueryDatabase will restrict this to User tables.
-
addTable
public void addTable(String namespace, String tableName, Table table, Database.StorageFormat storageFormat)Description copied from interface:Database
Adds a non-partitioned table by name to the specified namespace.- Parameters:
namespace
- table namespacetableName
- table nametable
- table to addstorageFormat
- the storage format to use (ex DeephavenV1 or Parquet)
-
appendTable
Description copied from interface:Database
Appends to a non-partitioned table, or adds the table if it is not present. Adds a TableDefinition if necessary.- Parameters:
namespace
- table namespacetableName
- table nametable
- data to add or append
-
addTableDefinition
public void addTableDefinition(String namespace, String tableName, TableDefinition tableDefinition)Description copied from interface:Database
Adds a table definition to the specified namespace. Throws an exception if the table definition already exists.- Parameters:
namespace
- table namespacetableName
- table nametableDefinition
- table definition to add
-
checkAllowRemoveTableDefinition
-
checkAllowRemoveTableDefinition
-
checkAllowRemoveTable
-
checkAllowRemoveTableCentral
-
removeTable
Description copied from interface:Database
Removes a table. This method is a better choice thanDatabase.deleteTables(String, String...)
, unless the underlying table no longer has consistent metadata. Throws an exception for tables that don't exist.- Parameters:
namespace
- table namespacetableName
- table name
-
repairMetadata
Report on (and optionally fix) table location metadata issues for the specified namespace and table name. Specifically, this will validate that locations are non-empty directories (and optionally try to remove them if not), report on location size conflicts implied by the column files, and report on (and optionally repair if possible) missing or incorrect location size metadata.
Note: This tool skips the usual namespace permission tests - the only requirement is that the process runs with sufficient filesystem permissions.- Parameters:
namespace
- The namespace to operate ontableName
- The table name to operate onfix
- Whether to fix the metadata or simply log issues
-
repairMetadata
Report on (and optionally fix) all table location metadata for the specified namespace. Specifically, this will validate that locations are non-empty directories (and optionally try to remove them if not), report on location size conflicts implied by the column files, and report on (and optionally repair if possible) missing or incorrect location size metadata.
Note: This tool skips the usual namespace permission tests - the only requirement is that the process runs with sufficient filesystem permissions.- Parameters:
namespace
- The namespace to operate onfix
- Whether to fix the metadata or simply log issues
-
repairMetadata
Report on (and optionally fix) all table location metadata for the specified set of namespaces. Specifically, this will validate that locations are non-empty directories (and optionally try to remove them if not), report on location size conflicts implied by the column files, and report on (and optionally repair if possible) missing or incorrect location size metadata.
Note: This tool skips the usual namespace permission tests - the only requirement is that the process runs with sufficient filesystem permissions.- Parameters:
namespaceSet
- The namespace set to operate onfix
- Whether to fix the metadata or simply log issues
-
deleteTables
Description copied from interface:Database
Delete all files related to a set of tables.Database.removeTable(String, String)
is a better option, unless the underlying table is damaged.- Parameters:
namespace
- table namespacetableNames
- table names to delete
-
deleteMatchingTables
Description copied from interface:Database
Delete all files related to the set of tables whose names match the supplied regular expression.Note: This only works for tables that still have a definition file, although it need not be readable.
Note: This is a dangerous API - don't use it if you don't fully understand the implications.
- Parameters:
namespace
- table namespacetableNameRegex
- table names in the given namespace that match this regular expression will be cleaned up.
-
deleteNamespace
Description copied from interface:Database
Delete all files related to the specified namespace.Note: This is a dangerous API - don't use it if you don't fully understand the implications.
- Parameters:
namespace
- namespace to be deleted.
-
checkAllowCleanupNamespace
-
removeTableDefinition
Deprecated.Description copied from interface:Database
Removes a table definition.- Parameters:
namespace
- table namespacetableName
- table name
-
checkAllowReplaceTableDefinition
-
checkAllowReplaceTable
-
checkAllowIntradayOperation
-
verifyNamespace
Ensure the namespace exists.- Parameters:
namespace
- name of the namespace to checktableName
- optional table name for logging context
-
replaceTable
public void replaceTable(String namespace, String tableName, Table table, Database.StorageFormat storageFormat)Description copied from interface:Database
Replaces a non-partitioned table with a new table, or adds the table, if it is not already present. Not guaranteed to be atomic in the case of failures.- Parameters:
namespace
- table namespacetableName
- table nametable
- data for the replacement tablestorageFormat
- the storage format to use (ex DeephavenV1 or Parquet)
-
replaceTableDefinition
public void replaceTableDefinition(String namespace, String tableName, TableDefinition tableDefinition)Description copied from interface:Database
Replaces a user table definition.Not guaranteed to be atomic in the case of failures.
Does not throw an exception for tables that don't exist.
- Parameters:
namespace
- table namespacetableName
- table nametableDefinition
- table definition for the replacement
-
checkAllowAddColumnPartition
-
checkAllowDeleteColumnPartition
-
checkAllowReplaceColumnPartition
-
logPartitionTableSnapshot
public Database.LogHandle logPartitionTableSnapshot(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, long logIntervalMillis, boolean append)Description copied from interface:Database
Snapshots a table at a regular interval and writes the snapshot to a centrally managed table.- Parameters:
namespace
- table namespacetableName
- table namepartitioningColumnName
- name of the partitioning columncolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).table
- table to snapshot and log (does not contain the partition column)logIntervalMillis
- interval in milliseconds to log snapshots atappend
- true to append to an existing partition; false to replace the existing partition.- Returns:
- log handle
-
logPartitionTableSnapshot
public Database.LogHandle logPartitionTableSnapshot(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, long logIntervalMillis, ReplayerInterface replayer, boolean append)Description copied from interface:Database
Snapshots a table at a regular interval and writes the snapshot to a centrally managed table.- Parameters:
namespace
- table namespacetableName
- table namepartitioningColumnName
- name of the partitioning columncolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).table
- table to snapshot and log (does not contain the partition column)logIntervalMillis
- interval in milliseconds to log snapshots atreplayer
- data replayerappend
- true to append to an existing partition; false to replace the existing partition.- Returns:
- log handle
-
logPartitionTableIncremental
public Database.LogHandle logPartitionTableIncremental(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, boolean append)Description copied from interface:Database
Writes all changes in a table to a centrally managed table.- Parameters:
namespace
- table namespacetableName
- table namepartitioningColumnName
- name of the partitioning columncolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).table
- table to log (does not contain the partition column)append
- true to append to an existing partition; false to replace the existing partition.- Returns:
- log handle
-
logPartitionTableIncremental
public Database.LogHandle logPartitionTableIncremental(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, Table table, ReplayerInterface replayer, boolean append)Description copied from interface:Database
Writes all changes in a table to a centrally managed table.- Parameters:
namespace
- table namespacetableName
- table namepartitioningColumnName
- name of the partitioning columncolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).table
- table to log (does not contain the partition column)replayer
- data replayerappend
- true to append to an existing partition; false to replace the existing partition.- Returns:
- log handle
-
getColumnPartitionTableWriter
public TableWriter getColumnPartitionTableWriter(String namespace, String tableName, String partitioningColumnName, String columnPartitionValue, TableDefinition prototypeTableDefinition, boolean append)Description copied from interface:Database
Gets a table writer for a partitioned table.- Parameters:
namespace
- table namespacetableName
- table namepartitioningColumnName
- name of the partitioning columncolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).prototypeTableDefinition
- table definitionappend
- true to append to an existing partition; false to overwrite an existing partition.- Returns:
- table writer
-
addTablePartition
public void addTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat)Description copied from interface:Database
Adds a single table partition (e.g. one date) to a partitioned table.Requires that a suitable TableDefinition has already been added.
Throws an exception if the partition already exists.
- Parameters:
namespace
- table namespacetableName
- table nameinternalPartitionValue
- internal (not user-visible) partition value.columnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).data
- data for this partition. Must *not* contain the partitioning column.storageFormat
- the format used for storage
-
appendTablePartition
public void appendTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue, Table data)Description copied from interface:Database
Adds or appends to a single table location (e.g. one date) to a partitioned table.Requires that a suitable TableDefinition has already been added.
- Parameters:
namespace
- table namespacetableName
- table nameinternalPartitionValue
- internal (not user-visible) partition value.columnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).data
- data to append to this partition. Must *not* contain the partitioning column.
-
removeTablePartition
public void removeTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue)Description copied from interface:Database
Removes a single table location (e.g. one date) from a partitioned table. Requires that a suitable TableDefinition still exists.- Parameters:
namespace
- table namespacetableName
- table nameinternalPartitionValue
- internal (not user-visible) partition value.columnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).
-
replaceTablePartition
public void replaceTablePartition(String namespace, String tableName, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat)Description copied from interface:Database
Replaces a single table location (e.g. one date) from/to a partitioned table.Requires that a suitable TableDefinition has already been added.
Not guaranteed to be atomic in the case of failures.
- Parameters:
namespace
- table namespacetableName
- table nameinternalPartitionValue
- internal (not user-visible) partition value.columnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).data
- data to replace this partition. Must *not* contain the partitioning column.storageFormat
- the storage format to use (ex DeephavenV1 or Parquet)
-
storeTable
protected abstract void storeTable(TableDefinitionSchema schema, Table table, Database.StorageFormat storageFormat) -
appendTable
-
deleteTable
-
restoreTable
-
storeShadowTable
protected abstract void storeShadowTable(TableDefinitionSchema schema, Table table, Database.StorageFormat storageFormat) -
moveTableToBackup
-
installShadowTable
-
rollbackTable
-
deleteBackupTable
-
storeColumnPartition
protected abstract void storeColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat) -
appendColumnPartition
protected abstract void appendColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue, Table data) -
deleteColumnPartition
protected abstract void deleteColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue) -
overwriteColumnPartition
protected abstract void overwriteColumnPartition(TableDefinitionSchema schema, String internalPartitionValue, String columnPartitionValue, Table data, Database.StorageFormat storageFormat) -
getIntradayPartitions
-
getIntradayTableV2
-
getIntradayTableV2
protected Table getIntradayTableV2(TableDefinitionSchema schema, String partitionName, boolean live) -
getIntradayTableV2
protected abstract Table getIntradayTableV2(TableDefinitionSchema schema, Set<String> partitionNames, boolean live) -
getTableDefinitionsTable
-
getColumnDefinitionsTable
-
appendCentral
public void appendCentral(String namespace, String tableName, String columnPartitionValue, Table table, boolean flush)Description copied from interface:Database
Append to a table via a centralized table appender.Note: The table data is appended to a system-defined internal partition, and the specified column partition value.
- Parameters:
namespace
- table namespacetableName
- table namecolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).table
- new dataflush
- true to flush the table to disk; false to wait for flushing (if the implementation supports waiting)
-
hasNamespace
Description copied from interface:Database
Determines if the namespace is present in the DB.- Parameters:
namespace
- namespace- Returns:
- true if the namespace exists; false otherwise.
-
getCatalog
Description copied from interface:Database
Gets a table containing information on all tables in the DB.- Returns:
- table containing information on all tables in the DB
-
hasTable
Description copied from interface:Database
Determines if the table is defined in the DB.- Parameters:
namespace
- namespacetableName
- table name- Returns:
- true if the table definition exists; false otherwise.
-
hasIntradayTable
Description copied from interface:Database
Determines if the table is present in the DB and currently has intraday data.- Parameters:
namespace
- namespacetableName
- table name- Returns:
- true if the table exists and has intraday data; false otherwise.
-
hasImportedData
Description copied from interface:Database
Determines if the historical table's column partition is present in the DB.- Parameters:
namespace
- namespacetableName
- table namecolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).- Returns:
- true if the table's column partition exists; false otherwise.
-
hasIntradayData
Description copied from interface:Database
Determines if the intraday table's column partition is present in the DB.- Parameters:
namespace
- namespacetableName
- table namecolumnPartitionValue
- column partition value (e.g. "2015-09-25" for a Date partitioning column).- Returns:
- true if the intraday table's column partition exists; false otherwise.
-
hasData
protected abstract boolean hasData(NamespaceSet set, TableDefinition tDef, @Nullable String columnPartitionValue, boolean intraday)- Parameters:
tDef
- the definition of the tablecolumnPartitionValue
- partitioning column value to check. Null indicates "any" value.intraday
- if false, only historical partitions are checked.- Returns:
- True if the specified table location has data.
-