mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Data Fields | Private Member Functions | Private Attributes | Friends
m::Database Struct Reference

A Database is a set of Tables, Functions, and Statistics. More...

#include <Schema.hpp>

Collaboration diagram for m::Database:
[legend]

Data Structures

struct  index_entry_type
 

Public Member Functions

 ~Database ()
 
std::size_t size () const
 Returns the number of tables in this Database.
 
auto begin_tables () const
 
auto end_tables () const
 
Tableget_table (const ThreadSafePooledString &name) const
 Returns a reference to the Table with the given name.
 
Tableadd_table (ThreadSafePooledString name)
 Adds a new Table to this Database.
 
Tableadd (std::unique_ptr< Table > table)
 Adds a new Table to this Database.
 
bool has_table (const ThreadSafePooledString &name) const
 Returns true iff a Table with the given name exists.
 
void drop_table (const ThreadSafePooledString &name)
 Drops the Table with the given name.
 
const Functionget_function (const ThreadSafePooledString &name) const
 Returns a reference to the Function with the given name.
 
std::unique_ptr< CardinalityEstimatorcardinality_estimator (std::unique_ptr< CardinalityEstimator > CE)
 Sets the CardinalityEstimator of this Database.
 
const CardinalityEstimatorcardinality_estimator () const
 
void add_index (std::unique_ptr< idx::IndexBase > index, const ThreadSafePooledString &table_name, const ThreadSafePooledString &attribute_name, ThreadSafePooledString index_name)
 Adds an index with index_name on attribute_name from table_name.
 
void drop_index (const ThreadSafePooledString &index_name)
 Drops the index with the given index_name.
 
void drop_indexes (const ThreadSafePooledString &table_name)
 Drops all indexes from the table with the given table_name.
 
bool has_index (const ThreadSafePooledString &index_name) const
 Returns true iff there is an index with the given index_name.
 
bool has_index (const ThreadSafePooledString &table_name, const ThreadSafePooledString &attribute_name, idx::IndexMethod method) const
 Returns true iff there is a valid index using method on attribute_name of table_name.
 
const idx::IndexBaseget_index (const ThreadSafePooledString &index_name) const
 Returns the index with the given index_name.
 
const idx::IndexBaseget_index (const ThreadSafePooledString &table_name, const ThreadSafePooledString &attribute_name, idx::IndexMethod method) const
 Returns a valid index using method on attribute_name of table_name iff one exists.
 
void invalidate_indexes (const ThreadSafePooledString &table_name)
 Invalidates all indexes on attributes of Table table_name s.t.
 

Data Fields

ThreadSafePooledString name
 the name of the database
 

Private Member Functions

 Database (ThreadSafePooledString name)
 

Private Attributes

std::unordered_map< ThreadSafePooledString, std::unique_ptr< Table > > tables_
 the tables of this database
 
std::unordered_map< ThreadSafePooledString, Function * > functions_
 functions defined in this database
 
std::unique_ptr< CardinalityEstimatorcardinality_estimator_
 the CardinalityEstimator of this Database
 
std::list< index_entry_typeindexes_
 the indexes of this database
 

Friends

struct Catalog
 

Detailed Description

A Database is a set of Tables, Functions, and Statistics.

Definition at line 869 of file Schema.hpp.

Constructor & Destructor Documentation

◆ Database()

M_LCOV_EXCL_STOP Database::Database ( ThreadSafePooledString  name)
private

◆ ~Database()

Database::~Database ( )

Definition at line 310 of file Schema.cpp.

References functions_.

Member Function Documentation

◆ add()

Table & m::Database::add ( std::unique_ptr< Table table)
inline

Adds a new Table to this Database.

Definition at line 918 of file Schema.hpp.

◆ add_index()

void m::Database::add_index ( std::unique_ptr< idx::IndexBase index,
const ThreadSafePooledString table_name,
const ThreadSafePooledString attribute_name,
ThreadSafePooledString  index_name 
)
inline

Adds an index with index_name on attribute_name from table_name.

Throws std::out_of_range if a Table with the given table_name does not exist. Throws std::out_of_range if an Attribute with the given attribute_name does not exist. Throws m::invalid_argument if an index with the given index_name already exists.

Definition at line 956 of file Schema.hpp.

◆ add_table()

Table & Database::add_table ( ThreadSafePooledString  name)

Adds a new Table to this Database.

Throws std::invalid_argument if a Table with the given name already exists.

Definition at line 316 of file Schema.cpp.

References m::Catalog::Get(), name, and tables_.

Referenced by generate_training_suite_filter(), generate_training_suite_group_by(), and generate_training_suite_join().

◆ begin_tables()

auto m::Database::begin_tables ( ) const
inline

Definition at line 907 of file Schema.hpp.

◆ cardinality_estimator() [1/2]

const CardinalityEstimator & m::Database::cardinality_estimator ( ) const
inline

Definition at line 949 of file Schema.hpp.

◆ cardinality_estimator() [2/2]

std::unique_ptr< CardinalityEstimator > m::Database::cardinality_estimator ( std::unique_ptr< CardinalityEstimator CE)
inline

◆ drop_index()

void m::Database::drop_index ( const ThreadSafePooledString index_name)
inline

Drops the index with the given index_name.

Throws m::invalid_argument if an index with the given index_name does not exist.

Definition at line 967 of file Schema.hpp.

◆ drop_indexes()

void m::Database::drop_indexes ( const ThreadSafePooledString table_name)
inline

Drops all indexes from the table with the given table_name.

Throws m::invalid_argument if a table with the given table_name does not exist.

Definition at line 978 of file Schema.hpp.

◆ drop_table()

void m::Database::drop_table ( const ThreadSafePooledString name)
inline

Drops the Table with the given name.

Throws std::invalid_argument if no such Table exists.

Definition at line 927 of file Schema.hpp.

◆ end_tables()

auto m::Database::end_tables ( ) const
inline

Definition at line 908 of file Schema.hpp.

◆ get_function()

const Function * Database::get_function ( const ThreadSafePooledString name) const

Returns a reference to the Function with the given name.

First searches this Database instance. If no Function with the given name is found, searches the global Catalog. Throws std::invalid_argument if no Function with the given name exists.

Definition at line 323 of file Schema.cpp.

References functions_, m::Catalog::Get(), m::Catalog::get_function(), and name.

◆ get_index() [1/2]

const idx::IndexBase & m::Database::get_index ( const ThreadSafePooledString index_name) const
inline

Returns the index with the given index_name.

Throws m::invalid_argument an index with the given index_name does not exist.

Definition at line 1016 of file Schema.hpp.

◆ get_index() [2/2]

const idx::IndexBase & m::Database::get_index ( const ThreadSafePooledString table_name,
const ThreadSafePooledString attribute_name,
idx::IndexMethod  method 
) const
inline

Returns a valid index using method on attribute_name of table_name iff one exists.

Throws m::invalid_argument if such an index does not exist. Throws m::invalid_argument if a Table with the given table_name does not exist. Throws m::invalid_argument if an Attribute with attribute_name does not exist in Table table_name.

Definition at line 1027 of file Schema.hpp.

References and().

◆ get_table()

Table & m::Database::get_table ( const ThreadSafePooledString name) const
inline

Returns a reference to the Table with the given name.

Throws std::out_of_range if no Table with the given name exists in this Database.

Definition at line 913 of file Schema.hpp.

References m::Table::at().

◆ has_index() [1/2]

bool m::Database::has_index ( const ThreadSafePooledString index_name) const
inline

Returns true iff there is an index with the given index_name.

Definition at line 989 of file Schema.hpp.

◆ has_index() [2/2]

bool m::Database::has_index ( const ThreadSafePooledString table_name,
const ThreadSafePooledString attribute_name,
idx::IndexMethod  method 
) const
inline

Returns true iff there is a valid index using method on attribute_name of table_name.

Throws m::invalid_argument if a Table with the given table_name does not exist. Throws m::invalid_argument if an Attribute with attribute_name does not exist in Table table_name.

Definition at line 997 of file Schema.hpp.

References and().

◆ has_table()

bool m::Database::has_table ( const ThreadSafePooledString name) const
inline

Returns true iff a Table with the given name exists.

Definition at line 925 of file Schema.hpp.

◆ invalidate_indexes()

void m::Database::invalidate_indexes ( const ThreadSafePooledString table_name)
inline

Invalidates all indexes on attributes of Table table_name s.t.

they are no longer used to answer queries. Throws m_invalid_argument if a Table with the given table_name does not exist.

Definition at line 1046 of file Schema.hpp.

◆ size()

std::size_t m::Database::size ( ) const
inline

Returns the number of tables in this Database.

Definition at line 906 of file Schema.hpp.

Friends And Related Function Documentation

◆ Catalog

friend struct Catalog
friend

Definition at line 871 of file Schema.hpp.

Field Documentation

◆ cardinality_estimator_

std::unique_ptr<CardinalityEstimator> m::Database::cardinality_estimator_
private

the CardinalityEstimator of this Database

Definition at line 896 of file Schema.hpp.

Referenced by Database().

◆ functions_

std::unordered_map<ThreadSafePooledString, Function*> m::Database::functions_
private

functions defined in this database

Definition at line 895 of file Schema.hpp.

Referenced by get_function(), and ~Database().

◆ indexes_

std::list<index_entry_type> m::Database::indexes_
private

the indexes of this database

Definition at line 897 of file Schema.hpp.

◆ name

ThreadSafePooledString m::Database::name

the name of the database

Definition at line 892 of file Schema.hpp.

Referenced by add_table(), Database(), m::Catalog::drop_database(), emit_cardinalities(), get_function(), and index_scan_resolve_index_method().

◆ tables_

std::unordered_map<ThreadSafePooledString, std::unique_ptr<Table> > m::Database::tables_
private

the tables of this database

Definition at line 894 of file Schema.hpp.

Referenced by add_table().


The documentation for this struct was generated from the following files: