Coverage for python/lsst/daf/butler/registry/interfaces/_opaque.py : 59%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of daf_butler. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """Interfaces for the objects that manage opaque (logical) tables within a `Registry`. """
Any, Iterator, Optional, )
"""An interface that manages the records associated with a particular opaque table in a `Registry`.
Parameters ---------- name : `str` Name of the opaque table. """ self.name = name
def insert(self, *data: dict): """Insert records into the table
Parameters ---------- *data Each additional positional argument is a dictionary that represents a single row to be added. """ raise NotImplementedError()
def fetch(self, **where: Any) -> Iterator[dict]: """Retrieve records from an opaque table.
Parameters ---------- **where Additional keyword arguments are interpreted as equality constraints that restrict the returned rows (combined with AND); keyword arguments are column names and values are the values they must have.
Yields ------ row : `dict` A dictionary representing a single result row. """ raise NotImplementedError()
def delete(self, **where: Any): """Remove records from an opaque table.
Parameters ---------- **where Additional keyword arguments are interpreted as equality constraints that restrict the deleted rows (combined with AND); keyword arguments are column names and values are the values they must have. """ raise NotImplementedError()
"""
"""An interface that manages the opaque tables in a `Registry`.
`OpaqueTableStorageManager` primarily serves as a container and factory for `OpaqueTableStorage` instances, which each provide access to the records for a different (logical) opaque table.
Notes ----- Opaque tables are primarily used by `Datastore` instances to manage their internal data in the same database that hold the `Registry`, but are not limited to this.
While an opaque table in a multi-layer `Registry` may in fact be the union of multiple tables in different layers, we expect this to be rare, as `Registry` layers will typically correspond to different leaf `Datastore` instances (each with their own opaque table) in a `ChainedDatastore`. """
def initialize(cls, db: Database, context: StaticTablesContext) -> OpaqueTableStorageManager: """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.
Returns ------- manager : `OpaqueTableStorageManager` An instance of a concrete `OpaqueTableStorageManager` subclass. """ raise NotImplementedError()
"""Interface to `get` that raises `LookupError` instead of returning `None` on failure. """ r = self.get(name) if r is None: raise LookupError(f"No logical table with name '{name}' found.") return r
def get(self, name: str) -> Optional[OpaqueTableStorage]: """Return an object that provides access to the records associated with an opaque logical table.
Parameters ---------- name : `str` Name of the logical table.
Returns ------- records : `OpaqueTableStorage` or `None` The object representing the records for the given table in this layer, or `None` if there are no records for that table in this layer.
Notes ----- Opaque tables must be registered with the layer (see `register`) by the same client before they can safely be retrieved with `get`. Unlike most other manager classes, the set of opaque tables cannot be obtained from an existing data repository. """ raise NotImplementedError()
def register(self, name: str, spec: TableSpec) -> OpaqueTableStorage: """Ensure that this layer can hold records for the given opaque logical table, creating new tables as necessary.
Parameters ---------- name : `str` Name of the logical table. spec : `TableSpec` Schema specification for the table to be created.
Returns ------- records : `OpaqueTableStorage` The object representing the records for the given element in this layer.
Notes ----- This operation may not be invoked within a transaction context block. """ raise NotImplementedError() |