DimensionRecordStorageManager¶
-
class
lsst.daf.butler.registry.interfaces.DimensionRecordStorageManager(*, universe: DimensionUniverse)¶ Bases:
lsst.daf.butler.registry.interfaces.VersionedExtensionAn interface for managing the dimension records in a
Registry.DimensionRecordStorageManagerprimarily serves as a container and factory forDimensionRecordStorageinstances, which each provide access to the records for a differentDimensionElement.- Parameters
- universe
DimensionUniverse Universe of all dimensions and dimension elements known to the
Registry.
- universe
Notes
In a multi-layer
Registry, many dimension elements will only have records in one layer (often the base layer). The union of the records across all layers forms the logical table for the fullRegistry.Methods Summary
Clear any in-memory caches held by nested
DimensionRecordStorageinstances.Return extension version as defined by current implementation.
Return full name of the extension.
get(element)Return an object that provides access to the records associated with the given element, if one exists in this layer.
initialize(db, context, *, universe)Construct an instance of the manager.
loadDimensionGraph(key)Retrieve a
DimensionGraphthat was previously saved in the database.refresh()Ensure all other operations on this manager are aware of any changes made by other clients since it was initialized or last refreshed.
register(element)Ensure that this layer can hold records for the given element, creating new tables as necessary.
saveDimensionGraph(graph)Save a
DimensionGraphdefinition to the database, allowing it to be retrieved later via the returned key.Return digest for schema piece managed by this extension.
Methods Documentation
-
abstract
clearCaches() → None¶ Clear any in-memory caches held by nested
DimensionRecordStorageinstances.This is called by
Registrywhen transactions are rolled back, to avoid in-memory caches from ever containing records that are not present in persistent storage.
-
abstract classmethod
currentVersion() → Optional[lsst.daf.butler.registry.interfaces.VersionTuple]¶ Return extension version as defined by current implementation.
This method can return
Noneif an extension does not require its version to be saved or checked.- Returns
- version
VersionTuple Current extension version or
None.
- version
-
classmethod
extensionName() → str¶ Return full name of the extension.
This name should match the name defined in registry configuration. It is also stored in registry attributes. Default implementation returns full class name.
- Returns
- name
str Full extension name.
- name
-
abstract
get(element: DimensionElement) → Optional[DimensionRecordStorage]¶ Return an object that provides access to the records associated with the given element, if one exists in this layer.
- Parameters
- element
DimensionElement Element for which records should be returned.
- element
- Returns
- records
DimensionRecordStorageorNone The object representing the records for the given element in this layer, or
Noneif there are no records for that element in this layer.
- records
Notes
Dimension elements registered by another client of the same layer since the last call to
initializeorrefreshmay not be found.
-
abstract classmethod
initialize(db: Database, context: StaticTablesContext, *, universe: DimensionUniverse) → DimensionRecordStorageManager¶ Construct an instance of the manager.
- Parameters
- db
Database Interface to the underlying database engine and namespace.
- context
StaticTablesContext Context object obtained from
Database.declareStaticTables; used to declare any tables that should always be present in a layer implemented with this manager.- universe
DimensionUniverse Universe graph containing dimensions known to this
Registry.
- db
- Returns
- manager
DimensionRecordStorageManager An instance of a concrete
DimensionRecordStorageManagersubclass.
- manager
-
abstract
loadDimensionGraph(key: int) →lsst.daf.butler.DimensionGraph¶ Retrieve a
DimensionGraphthat was previously saved in the database.- Parameters
- key
int Integer used as the unique key for this
DimensionGraphin the database.
- key
- Returns
- graph
DimensionGraph Retrieved graph.
- graph
- Raises
- KeyError
Raised if the given key cannot be found in the database.
-
abstract
refresh() → None¶ Ensure all other operations on this manager are aware of any changes made by other clients since it was initialized or last refreshed.
-
abstract
register(element: DimensionElement) → DimensionRecordStorage¶ Ensure that this layer can hold records for the given element, creating new tables as necessary.
- Parameters
- element
DimensionElement Element for which a table should created (as necessary) and an associated
DimensionRecordStoragereturned.
- element
- Returns
- records
DimensionRecordStorage The object representing the records for the given element in this layer.
- records
- Raises
- TransactionInterruption
Raised if this operation is invoked within a
Database.transactioncontext.
-
abstract
saveDimensionGraph(graph:lsst.daf.butler.DimensionGraph) → int¶ Save a
DimensionGraphdefinition to the database, allowing it to be retrieved later via the returned key.- Parameters
- graph
DimensionGraph Set of dimensions to save.
- graph
- Returns
- key
int Integer used as the unique key for this
DimensionGraphin the database.
- key
- Raises
- TransactionInterruption
Raised if this operation is invoked within a
Database.transactioncontext.
-
abstract
schemaDigest() → Optional[str]¶ Return digest for schema piece managed by this extension.
- Returns
Notes
There is no exact definition of digest format, any string should work. The only requirement for string contents is that it has to remain stable over time if schema does not change but it should produce different string for any change in the schema. In many cases default implementation in
_defaultSchemaDigestcan be used as a reasonable choice.