Storage#

class silvimetric.resources.storage.Storage(config: StorageConfig, ctx: Ctx = None)#

Handles storage of shattered data in a TileDB Database.

consolidate_shatter(proc_num: int, retries=0) None#

Consolidate the fragments from a shatter process into one fragment. This makes the database perform better, but reduces the granularity of time traveling.

Parameters:

proc_num – Time slot associated with shatter process.

static create(config: StorageConfig, ctx: Ctx = None)#

Creates TileDB storage.

Parameters#

configStorageConfig

Storage StorageConfig

ctxtiledb.Ctx, optional

TileDB Context, by default is None

Returns#

Storage

Returns newly created Storage class

Raises#

Exception

Raises bounding box errors if not of lengths 4 or 6

delete(proc_num: int) ShatterConfig#

Delete Shatter process and all associated data from database.

Parameters:

proc_num – Shatter process time slot

Returns:

Config of deleted Shatter process

static from_db(tdb_dir: str)#

Create Storage object from information stored in a database.

Parameters:

tdb_dir – TileDB database directory.

Returns:

Returns the derived storage.

getAttributes() list[Attribute]#

Find list of attribute names from storage config.

Returns:

List of attribute names.

getConfig() StorageConfig#

Get the StorageConfig currently in use by the Storage.

Returns:

StorageConfig representing this object.

getDerivedNames() list[str]#
getMetadata(key: str, timestamp: int) str#

Return metadata at given key.

Parameters:
  • key – Key to look for in metadata.

  • timestamp – Time stamp for querying database.

Returns:

Metadata value found in storage.

getMetrics() list[Metric]#

Find List of metric names from storage config

Returns:

List of metric names.

get_fragments_by_time(proc_num: int) list[FragmentInfo]#

Get TileDB array fragments from the time slot specified.

Parameters:

proc_num – Requested time slot.

Returns:

Array fragments from time slot.

get_history(start_time: datetime, end_time: datetime, bounds: Bounds, name: str = None, concise: bool = False)#

Retrieve history of the database at current point in time.

Parameters:
  • start_time – Query parameter, starting datetime of process.

  • end_time – Query parameter, ending datetime of process.

  • bounds – Query parameter, bounds to query by.

  • name – Query paramter, shatter process uuid., by default None

  • concise – Whether or not to give shortened version of history.

Returns:

Returns list of array fragments that meet query parameters.

mbrs(proc_num: int)#

Get minimum bounding rectangle of a given shatter process. If this process has been finished and consolidated the mbr will be much less granulated than if the fragments are still intact. Mbrs are represented as tuples in the form of ((minx, maxx), (miny, maxy))

Parameters:

proc_num – Process number or time slot of the shatter process.

Returns:

Returns mbrs that match the given process number.

open(mode: str = 'r', timestamp=None) Generator[SparseArray, None, None]#

Open stream for TileDB database in given mode and at given timestamp.

Parameters:
  • mode – Mode to open TileDB stream in. Valid options are ‘w’, ‘r’, ‘m’, ‘d’., defaults to ‘r’.

  • timestamp – Timestamp to open database at., defaults to None.

Raises:
  • Exception – Incorrect Mode was given, only valid modes are ‘w’ and ‘r’.

  • Exception – Path exists and is not a TileDB array.

  • Exception – Path does not exist.

Yield:

TileDB array context manager.

reserve_time_slot() int#

Increment time slot in database and reserve that spot for a new shatter process.

Parameters:

config – Shatter config will be written as metadata to reserve time slot.

Returns:

Time slot.

saveConfig() None#

Save StorageConfig to the Database

saveMetadata(key: str, data: str, timestamp: int) None#

Save metadata to storage.

Parameters:
  • key – Metadata key to save to.

  • data – Data to save to metadata.