![]() |
mutable
A Database System for Research and Fast Prototyping
|
A Database
is a set of Table
s, Function
s, and Statistics
.
More...
#include <Schema.hpp>
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 |
Table & | get_table (const ThreadSafePooledString &name) const |
Returns a reference to the Table with the given name . | |
Table & | add_table (ThreadSafePooledString name) |
Adds a new Table to this Database . | |
Table & | add (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 Function * | get_function (const ThreadSafePooledString &name) const |
Returns a reference to the Function with the given name . | |
std::unique_ptr< CardinalityEstimator > | cardinality_estimator (std::unique_ptr< CardinalityEstimator > CE) |
Sets the CardinalityEstimator of this Database . | |
const CardinalityEstimator & | cardinality_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::IndexBase & | get_index (const ThreadSafePooledString &index_name) const |
Returns the index with the given index_name . | |
const idx::IndexBase & | get_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< CardinalityEstimator > | cardinality_estimator_ |
the CardinalityEstimator of this Database | |
std::list< index_entry_type > | indexes_ |
the indexes of this database | |
Friends | |
struct | Catalog |
A Database
is a set of Table
s, Function
s, and Statistics
.
Definition at line 869 of file Schema.hpp.
|
private |
Definition at line 304 of file Schema.cpp.
References cardinality_estimator_, m::Catalog::create_cardinality_estimator(), m::Catalog::Get(), and name.
Database::~Database | ( | ) |
Definition at line 310 of file Schema.cpp.
References functions_.
Adds a new Table
to this Database
.
Definition at line 918 of file Schema.hpp.
|
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.
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().
|
inline |
Definition at line 907 of file Schema.hpp.
|
inline |
Definition at line 949 of file Schema.hpp.
|
inline |
Sets the CardinalityEstimator
of this Database
.
Returns the old CardinalityEstimator
.
CardinalityEstimator
, may be nullptr
Definition at line 946 of file Schema.hpp.
Referenced by m::Optimizer::construct_join_order(), m::pe::hs::HeuristicSearch::operator()(), m::pe::DPccp::operator()(), m::pe::GOO::operator()(), m::pe::TDGOO::operator()(), PEall::operator()(), DPsize::operator()(), DPsizeOpt::operator()(), DPsizeSub::operator()(), DPsub::operator()(), DPsubOpt::operator()(), IKKBZ::operator()(), LinearizedDP::operator()(), TDbasic::operator()(), TDMinCutAGaT::operator()(), m::Optimizer::optimize_join_order(), m::Optimizer::optimize_plan(), and m::Optimizer::optimize_source_plans().
|
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.
|
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.
|
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.
|
inline |
Definition at line 908 of file Schema.hpp.
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.
|
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.
|
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().
|
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().
|
inline |
Returns true
iff there is an index with the given index_name
.
Definition at line 989 of file Schema.hpp.
|
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().
|
inline |
Returns true
iff a Table
with the given name
exists.
Definition at line 925 of file Schema.hpp.
|
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.
|
inline |
Returns the number of tables in this Database
.
Definition at line 906 of file Schema.hpp.
Definition at line 871 of file Schema.hpp.
|
private |
the CardinalityEstimator
of this Database
Definition at line 896 of file Schema.hpp.
Referenced by Database().
|
private |
functions defined in this database
Definition at line 895 of file Schema.hpp.
Referenced by get_function(), and ~Database().
|
private |
the indexes of this database
Definition at line 897 of file Schema.hpp.
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().
|
private |