lsst.dax.apdb g011c388f00+f3f791b2c2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema Class Reference
Inheritance diagram for lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema:
lsst.dax.apdb.apdbSchema.ApdbSchema

Public Member Functions

 __init__ (self, cassandra.cluster.Session session, str keyspace, str schema_file, str schema_name="ApdbSchema", str prefix="", bool time_partition_tables=False, bool use_insert_id=False)
 
bool has_insert_id (self)
 
bool empty (self)
 
str tableName (self, ApdbTables|ExtraTables table_name)
 
str keyspace (self)
 
Mapping[str, simple.Column] getColumnMap (self, ApdbTables|ExtraTables table_name)
 
list[str] apdbColumnNames (self, ApdbTables|ExtraTables table_name)
 
list[str] partitionColumns (self, ApdbTables|ExtraTables table_name)
 
list[str] clusteringColumns (self, ApdbTables|ExtraTables table_name)
 
None makeSchema (self, bool drop=False, tuple[int, int]|None part_range=None)
 
- Public Member Functions inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
type|str column_dtype (self, type[felis.types.FelisType] felis_type)
 
VersionTuple schemaVersion (self)
 

Protected Member Functions

Mapping[ApdbTables, simple.Table] _apdb_tables_schema (self, bool time_partition_tables)
 
Mapping[ExtraTables, simple.Table] _extra_tables_schema (self)
 
bool _check_insert_id (self)
 
None _makeTableSchema (self, ApdbTables|ExtraTables table, bool drop=False, tuple[int, int]|None part_range=None)
 
list[str] _tableColumns (self, ApdbTables|ExtraTables table_name)
 
simple.Table _table_schema (self, ApdbTables|ExtraTables table)
 
- Protected Member Functions inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
tuple[Mapping[ApdbTables, Table], VersionTuple|None] _buildSchemas (self, str schema_file, str schema_name="ApdbSchema")
 

Protected Attributes

 _session
 
 _keyspace
 
 _prefix
 
 _time_partition_tables
 
 _use_insert_id
 
 _apdb_tables
 
 _extra_tables
 
 _has_insert_id
 
- Protected Attributes inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
 _schemaVersion
 

Static Protected Attributes

dict _type_map
 
list _time_partitioned_tables
 
list _spatially_partitioned_tables = [ApdbTables.DiaObjectLast]
 

Additional Inherited Members

- Public Attributes inherited from lsst.dax.apdb.apdbSchema.ApdbSchema
 tableSchemas
 

Detailed Description

Class for management of APDB schema.

Parameters
----------
session : `cassandra.cluster.Session`
    Cassandra session object
schema_file : `str`
    Name of the YAML schema file.
schema_name : `str`, optional
    Name of the schema in YAML files.
prefix : `str`, optional
    Prefix to add to all schema elements.
time_partition_tables : `bool`
    If True then schema will have a separate table for each time partition.

Constructor & Destructor Documentation

◆ __init__()

lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.__init__ ( self,
cassandra.cluster.Session session,
str keyspace,
str schema_file,
str schema_name = "ApdbSchema",
str prefix = "",
bool time_partition_tables = False,
bool use_insert_id = False )

Member Function Documentation

◆ _apdb_tables_schema()

Mapping[ApdbTables, simple.Table] lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema._apdb_tables_schema ( self,
bool time_partition_tables )
protected
Generate schema for regular APDB tables.

◆ _check_insert_id()

bool lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema._check_insert_id ( self)
protected
Check whether database has tables for tracking insert IDs.

◆ _extra_tables_schema()

Mapping[ExtraTables, simple.Table] lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema._extra_tables_schema ( self)
protected
Generate schema for extra tables.

◆ _table_schema()

simple.Table lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema._table_schema ( self,
ApdbTables | ExtraTables table )
protected
Return schema definition for a table.

◆ _tableColumns()

list[str] lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema._tableColumns ( self,
ApdbTables | ExtraTables table_name )
protected
Return set of columns in a table

Parameters
----------
table_name : `ApdbTables`
    Name of the table.

Returns
-------
column_defs : `list`
    List of strings in the format "column_name type".

◆ apdbColumnNames()

list[str] lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.apdbColumnNames ( self,
ApdbTables | ExtraTables table_name )
Return a list of columns names for a table as defined in APDB
schema.

Parameters
----------
table_name : `ApdbTables` or `ExtraTables`
    Enum for a table in APDB schema.

Returns
-------
columns : `list` of `str`
    Names of regular columns in the table.

◆ clusteringColumns()

list[str] lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.clusteringColumns ( self,
ApdbTables | ExtraTables table_name )
Return a list of columns used for clustering.

Parameters
----------
table_name : `ApdbTables`
    Table name in APDB schema

Returns
-------
columns : `list` of `str`
    Names of columns for used for clustering.

◆ empty()

bool lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.empty ( self)
Return True if database schema is empty.

Returns
-------
empty : `bool`
    `True` if none of the required APDB tables exist in the database,
    `False` if all required tables exist.

Raises
------
InconsistentSchemaError
    Raised when some of the required tables exist but not all.

◆ getColumnMap()

Mapping[str, simple.Column] lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.getColumnMap ( self,
ApdbTables | ExtraTables table_name )
Return mapping of column names to Column definitions.

Parameters
----------
table_name : `ApdbTables`
    One of known APDB table names.

Returns
-------
column_map : `dict`
    Mapping of column names to `ColumnDef` instances.

◆ has_insert_id()

bool lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.has_insert_id ( self)
Whether insert ID tables are to be used (`bool`).

◆ keyspace()

str lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.keyspace ( self)
Return Cassandra keyspace for APDB tables.

◆ makeSchema()

None lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.makeSchema ( self,
bool drop = False,
tuple[int, int] | None part_range = None )
Create or re-create all tables.

Parameters
----------
drop : `bool`
    If True then drop tables before creating new ones.
part_range : `tuple` [ `int` ] or `None`
    Start and end partition number for time partitions, end is not
    inclusive. Used to create per-partition DiaObject, DiaSource, and
    DiaForcedSource tables. If `None` then per-partition tables are
    not created.

◆ partitionColumns()

list[str] lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.partitionColumns ( self,
ApdbTables | ExtraTables table_name )
Return a list of columns used for table partitioning.

Parameters
----------
table_name : `ApdbTables`
    Table name in APDB schema

Returns
-------
columns : `list` of `str`
    Names of columns used for partitioning.

◆ tableName()

str lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema.tableName ( self,
ApdbTables | ExtraTables table_name )
Return Cassandra table name for APDB table.

Member Data Documentation

◆ _time_partitioned_tables

list lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema._time_partitioned_tables
staticprotected
Initial value:
= [
ApdbTables.DiaObject,
ApdbTables.DiaSource,
ApdbTables.DiaForcedSource,
]

◆ _type_map

dict lsst.dax.apdb.apdbCassandraSchema.ApdbCassandraSchema._type_map
staticprotected
Initial value:
= {
felis.types.Double: "DOUBLE",
felis.types.Float: "FLOAT",
felis.types.Timestamp: "TIMESTAMP",
felis.types.Long: "BIGINT",
felis.types.Int: "INT",
felis.types.Short: "INT",
felis.types.Byte: "TINYINT",
felis.types.Binary: "BLOB",
felis.types.Char: "TEXT",
felis.types.String: "TEXT",
felis.types.Unicode: "TEXT",
felis.types.Text: "TEXT",
felis.types.Boolean: "BOOLEAN",
_FelisUUID: "UUID",
}

The documentation for this class was generated from the following file: