SkyPixDimensionRecordStorage¶
-
class
lsst.daf.butler.registry.interfaces.SkyPixDimensionRecordStorage¶ Bases:
lsst.daf.butler.registry.interfaces.DimensionRecordStorageIntermediate interface for
DimensionRecordStorageobjects that provide storage forSkyPixDimensioninstances.Attributes Summary
elementThe element whose records this instance managers ( DimensionElement).Methods Summary
clearCaches()Clear any in-memory caches held by the storage instance. digestTables()Return tables used for schema digest. fetch_one(data_id, context)Retrieve a single record from storage. get_record_cache(context)Return a local cache of all DimensionRecordobjects for this element, fetching it if necessary.insert(*records, replace, skip_existing)Insert one or more records into storage. join(target, join, context)Join this dimension element’s records to a relation. sync(record, update)Synchronize a record with the database, inserting it only if it does not exist and comparing values if it does. Attributes Documentation
-
element¶ The element whose records this instance managers (
DimensionElement).
Methods Documentation
-
clearCaches() → None¶ Clear any in-memory caches held by the storage instance.
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.
-
digestTables() → list¶ Return tables used for schema digest.
Returns: - tables :
list[sqlalchemy.schema.Table] Possibly empty list of tables for schema digest calculations.
- tables :
-
fetch_one(data_id: DataCoordinate, context: queries.SqlQueryContext) → DimensionRecord | None¶ Retrieve a single record from storage.
Parameters: - data_id :
DataCoordinate Data ID of the record to fetch. Implied dimensions do not need to be present.
- context :
queries.SqlQueryContext Context to be used to execute queries when no cached result is available.
Returns: - data_id :
-
get_record_cache(context: queries.SqlQueryContext) → Mapping[DataCoordinate, DimensionRecord] | None¶ Return a local cache of all
DimensionRecordobjects for this element, fetching it if necessary.Implementations that never cache records should return
None.Parameters: - context :
queries.SqlQueryContext Context to be used to execute queries when no cached result is available.
Returns: - context :
-
insert(*records, replace: bool = False, skip_existing: bool = False) → None¶ Insert one or more records into storage.
Parameters: - records
One or more instances of the
DimensionRecordsubclass for the element this storage is associated with.- replace: `bool`, optional
If
True(Falseis default), replace existing records in the database if there is a conflict.- skip_existing :
bool, optional If
True(Falseis default), skip insertion if a record with the same primary key values already exists.
Raises: - TypeError
Raised if the element does not support record insertion.
- sqlalchemy.exc.IntegrityError
Raised if one or more records violate database integrity constraints.
Notes
As
insertis expected to be called only by aRegistry, we rely onRegistryto provide transactionality, both by using a SQLALchemy connection shared with theRegistryand by relying on it to callclearCacheswhen rolling back transactions.
-
join(target: Relation, join: Join, context: queries.SqlQueryContext) → Relation¶ Join this dimension element’s records to a relation.
Parameters: - target :
Relation Existing relation to join to. Implementations may require that this relation already include dimension key columns for this dimension element and assume that dataset or spatial join relations that might provide these will be included in the relation tree first.
- join :
Join Join operation to use when the implementation is an actual join. When a true join is being simulated by other relation operations, this objects
min_columnsandmax_columnsshould still be respected.- context :
queries.SqlQueryContext Object that manages relation engines and database-side state (e.g. temporary tables) for the query.
Returns: - joined :
Relation New relation that includes this relation’s dimension key and record columns, as well as all columns in
target, with rows constrained to those for which this element’s dimension key values exist in the registry and rows already exist intarget.
- target :
-
sync(record: lsst.daf.butler.core.dimensions._records.DimensionRecord, update: bool = False) → bool | dict[str, typing.Any][bool, dict]¶ Synchronize a record with the database, inserting it only if it does not exist and comparing values if it does.
Parameters: Returns: Raises: - DatabaseConflictError
Raised if the record exists in the database (according to primary key lookup) but is inconsistent with the given one.
- TypeError
Raised if the element does not support record synchronization.
- sqlalchemy.exc.IntegrityError
Raised if one or more records violate database integrity constraints.
-