lsst.dax.apdb g9290983e33+ffdc83c6f7
 
Loading...
Searching...
No Matches
lsst.dax.apdb.cassandra.partitioner.Partitioner Class Reference

Public Member Functions

 __init__ (self, ApdbCassandraConfig config)
 
int pixel (self, sphgeom.UnitVector3d direction)
 
int time_partition (self, float|astropy.time.Time time)
 
tuple[astropy.time.Time, astropy.time.Time] partition_period (self, int time_partition)
 
tuple[list[tuple[str, tuple]], int] spatial_where (self, sphgeom.Region|None region, *, bool use_ranges=False, bool for_prepare=False)
 
tuple[list[str], list[tuple[str, tuple]]] temporal_where (self, ApdbTables table, float|astropy.time.Time start_time, float|astropy.time.Time end_time, *, bool|None query_per_time_part=None, bool for_prepare=False, ApdbCassandraTimePartitionRange|None partitons_range=None)
 

Public Attributes

 pixelization
 

Static Public Attributes

 partition_zero_epoch = astropy.time.Time(0, format="unix_tai")
 

Protected Attributes

 _config = config
 
 _epoch = float(self.partition_zero_epoch.mjd)
 

Detailed Description

Logic for temporal and spacial partitiong of APDB tables.

Parameters
----------
config : `ApdbCassandraConfig`
    Configuration object.

Member Function Documentation

◆ partition_period()

tuple[astropy.time.Time, astropy.time.Time] lsst.dax.apdb.cassandra.partitioner.Partitioner.partition_period ( self,
int time_partition )
Return time period for specified taime partition.

Parameters
----------
time_partition : `int`
    Time partition.

Returns
-------
start : `astropy.time.Time`
    Start of the period, inclusive boundary.
end : `astropy.time.Time`
    Start of the period, exclusive boundary.

◆ pixel()

int lsst.dax.apdb.cassandra.partitioner.Partitioner.pixel ( self,
sphgeom.UnitVector3d direction )
Compute the index of the pixel for given direction.

Parameters
----------
direction : `lsst.sphgeom.UnitVector3d`
    Spatial position.

Returns
-------
pixel : `int`
    Pixel index.

◆ spatial_where()

tuple[list[tuple[str, tuple]], int] lsst.dax.apdb.cassandra.partitioner.Partitioner.spatial_where ( self,
sphgeom.Region | None region,
* ,
bool use_ranges = False,
bool for_prepare = False )
Generate expressions for spatial part of WHERE clause.

Parameters
----------
region : `sphgeom.Region`
    Spatial region for query results.
use_ranges : `bool`, optional
    If True then use pixel ranges ("apdb_part >= p1 AND apdb_part <=
    p2") instead of exact list of pixels. Should be set to True for
    large regions covering very many pixels.
for_prepare : `bool`, optional
    If True then use placeholders for prepared statement (?), otherwise
    produce regulr statement placeholders (%s).

Returns
-------
expressions : `list` [ `tuple` ]
    Empty list is returned if ``region`` is `None`, otherwise a list
    of one or more ``(expression: str, parameters: tuple)`` tuples.
partition_count : `int`
    Number of spatial partitions in the result.

◆ temporal_where()

tuple[list[str], list[tuple[str, tuple]]] lsst.dax.apdb.cassandra.partitioner.Partitioner.temporal_where ( self,
ApdbTables table,
float | astropy.time.Time start_time,
float | astropy.time.Time end_time,
* ,
bool | None query_per_time_part = None,
bool for_prepare = False,
ApdbCassandraTimePartitionRange | None partitons_range = None )
Generate table names and expressions for temporal part of WHERE
clauses.

Parameters
----------
table : `ApdbTables`
    Table to select from.
start_time : `astropy.time.Time` or `float`
    Starting Datetime of MJD value of the time range.
end_time : `astropy.time.Time` or `float`
    Starting Datetime of MJD value of the time range.
query_per_time_part : `bool`, optional
    If None then use ``query_per_time_part`` from configuration.
for_prepare : `bool`, optional
    If True then use placeholders for prepared statement (?), otherwise
    produce regulr statement placeholders (%s).
partitons_range : `ApdbCassandraTimePartitionRange` or `None`
    Partitions range to further restrict time range.

Returns
-------
tables : `list` [ `str` ]
    List of the table names to query. Empty list is returned when time
    range does not overlap ``partitons_range``.
expressions : `list` [ `tuple` ]
    A list of zero or more ``(expression: str, parameters: tuple)``
    tuples.

◆ time_partition()

int lsst.dax.apdb.cassandra.partitioner.Partitioner.time_partition ( self,
float | astropy.time.Time time )
Calculate time partition number for a given time.

Parameters
----------
time : `float` or `astropy.time.Time`
    Time for which to calculate partition number. Can be float to mean
    MJD or `astropy.time.Time`

Returns
-------
partition : `int`
    Partition number for a given time.

Member Data Documentation

◆ pixelization

lsst.dax.apdb.cassandra.partitioner.Partitioner.pixelization
Initial value:
= Pixelization(
config.partitioning.part_pixelization,
config.partitioning.part_pix_level,
config.partitioning.part_pix_max_ranges,
)

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