12#include <mutable/mutable-config.hpp>
22#include <unordered_map>
52 : prefix(
std::move(prefix)), name(
std::move(name))
54 if (this->prefix.has_value()
and strlen(*this->prefix) == 0)
60 bool is_constant()
const {
return operator==(GetConstant()); }
63 return this->prefix == other.
prefix and this->name == other.
name;
69 if (
id.prefix.has_value())
70 out <<
id.prefix <<
'.';
71 return out <<
id.name;
82 REFERENCES_UNIQUE = 0b100
U,
97 , constraints(constraints)
102 bool nullable()
const {
return not (NOT_NULLABLE & constraints); }
103 bool unique()
const {
return bool(UNIQUE & constraints); }
114 const std::vector<entry_type> &
entries()
const {
return entries_; }
126 bool empty()
const {
return entries_.empty(); }
130 auto pred = [&
id](
const entry_type &e) ->
bool {
return e.id ==
id; };
131 auto it = std::find_if(begin(), end(), pred);
132 if (it != end()
and std::find_if(std::next(it), end(), pred) != end())
144 if (idx >= entries_.size())
146 return entries_[idx];
152 M_insist(idx < entries_.size(),
"index out of bounds");
153 return entries_[idx];
164 return { std::distance(begin(), pos), *pos };
168 std::pair<std::size_t, const entry_type&>
at(
const Identifier &
id)
const {
return const_cast<Schema*
>(
this)->
at(
id); }
172 M_insist(pos != end(),
"identifier not found");
173 return { std::distance(begin(), pos), *pos };
177 return const_cast<Schema*
>(
this)->
operator[](
id);
186 entries_.emplace_back(std::move(
id), type, constraints);
192 for (
auto &e : *
this) {
193 if (not res.has(e.id))
194 res.add(e.id, e.type, e.constraints);
202 for (
auto &e : *
this) {
203 if (not e.id.is_constant())
204 res.add(e.id, e.type, e.constraints);
212 for (
auto &e : other)
213 entries_.emplace_back(e);
221 for (
auto &e : other) {
223 entries_.emplace_back(e);
230 return std::all_of(this->begin(), this->end(), [&](
const entry_type &p) {
return other.
has(p.
id); })
and
231 std::all_of(other.
begin(), other.
end(), [&](
const entry_type &p) { return this->has(p.id); });
238 for (
auto it = schema.
begin(), end = schema.
end(); it != end; ++it) {
239 if (it != schema.
begin()) out <<
',';
240 out <<
' ' << it->id <<
" :" << *it->type;
246 void dump(std::ostream &out)
const;
261 for (
auto &e : left) {
262 auto it = right.
find(e.id);
263 if (it != right.
end()) {
264 if (e.type != it->type)
266 res.add(e.id, e.type, e.constraints | it->constraints);
285struct TableDecorator;
296 bool not_nullable =
false;
299 bool is_hidden =
false;
307 , name(
std::move(name))
319 bool is_unique()
const;
327 return out <<
'`' << attr.
name <<
"` " << *attr.
type;
331 void dump(std::ostream &out)
const;
342 if constexpr (std::is_same_v<T, bool>) {
343 if (is<const Boolean>(ty))
348 if constexpr (std::is_same_v<T, std::string>) {
349 if (
auto s = cast<const CharacterSequence>(ty)) {
350 if (not s->is_varying)
354 if constexpr (std::is_same_v<T, const char*>) {
355 if (
auto s = cast<const CharacterSequence>(ty)) {
356 if (not s->is_varying)
362 if constexpr (std::is_arithmetic_v<T>) {
363 if (
auto n = cast<const Numeric>(ty)) {
366 if (std::is_integral_v<T>
and sizeof(
T) * 8 == ty->size())
370 case Numeric::N_Float:
371 if (std::is_floating_point_v<T>
and sizeof(
T) * 8 == ty->size())
375 case Numeric::N_Decimal:
376 if (std::is_integral_v<T>
and ceil_to_pow_2(ty->size()) == 8 *
sizeof(
T))
392 template<
bool V,
bool H>
395 static constexpr bool Show_Visible = V;
396 static constexpr bool Show_Hidden = H;
411 if constexpr (Show_Visible
and not Show_Hidden)
412 while (it_ != end_
and it_->is_hidden) {
415 else if constexpr (not Show_Visible
and Show_Hidden)
416 while (it_ != end_
and not it_->is_hidden) {
419 else if constexpr (not Show_Visible
and not Show_Hidden)
426 if constexpr (Show_Visible
and not Show_Hidden)
427 while (it_ != end_
and it_->is_hidden) {
430 else if constexpr (not Show_Visible
and Show_Hidden)
431 while (it_ != end_
and not it_->is_hidden) {
441 if constexpr (Show_Visible
and not Show_Hidden)
442 while (it_ != start_
and it_->is_hidden) {
445 else if constexpr (not Show_Visible
and Show_Hidden)
446 while (it_ != start_
and not it_->is_hidden) {
463 if constexpr (Show_Visible
and Show_Hidden) {
468 for (
size_t i = 0 ; i < offset; ++i) {
470 if constexpr (Show_Visible
and not Show_Hidden)
471 while (it_ != end_
and it_->is_hidden) {
474 else if constexpr (not Show_Visible
and Show_Hidden)
475 while (it_ != end_
and not it_->is_hidden) {
482 if constexpr (Show_Visible
and Show_Hidden) {
487 for (
size_t i = 0 ; i < offset; ++i) {
489 if constexpr (Show_Visible
and not Show_Hidden)
490 while (it_ != start_
and it_->is_hidden) {
493 else if constexpr (not Show_Visible
and Show_Hidden)
494 while (it_ != start_
and not it_->is_hidden) {
502 if constexpr (Show_Visible
and Show_Hidden)
return this->it_ - other.
it_;
503 if (this->it_ - other.
it_ == 0)
return 0;
505 auto smaller_it = (this->it_ < other.
it_) ? this->it_ : other.
it_;
506 auto larger_it = (this->it_ < other.
it_) ? other.
it_ : this->it_;
508 for (
auto i = smaller_it; i != larger_it; ++i) {
509 if constexpr (Show_Visible
and not Show_Hidden) {
510 if (i != end_
and i->is_hidden) ignored++;
511 }
else if constexpr (not Show_Visible
and Show_Hidden) {
512 if (i != end_
and not i->is_hidden) ignored++;
516 distance += (distance > 0) ? -ignored : ignored;
568 virtual bool operator== (
const Table &other) = 0;
569 virtual bool operator== (
const Table &other)
const = 0;
577 virtual void store(std::unique_ptr<Store> new_store) = 0;
587 virtual std::vector<std::reference_wrapper<const Attribute>>
primary_key()
const = 0;
604 virtual void dump(std::ostream &out)
const = 0;
614 std::unordered_map<ThreadSafePooledString, table_type::size_type>
name_to_attr_;
624 std::size_t
num_attrs()
const override {
return end() - begin(); }
650 if (
id >= attrs_.size())
651 throw std::out_of_range(
"id out of bounds");
652 auto &attr = attrs_[
id];
653 M_insist(attr.id ==
id,
"attribute ID mismatch");
660 auto &attr = attrs_[
id];
661 M_insist(attr.id ==
id,
"attribute ID mismatch");
669 if (
auto it = name_to_attr_.find(name); it != name_to_attr_.end()) {
670 M_insist(it->second < attrs_.size());
671 return operator[](it->second);
673 throw std::out_of_range(
"name does not exists");
684 bool operator== (
const Table &other)
override {
685 if (is<const ConcreteTable>(other))
686 return this == &other;
687 if (is<const TableDecorator>(other))
688 return other.operator==(*this);
691 bool operator== (
const Table &other)
const override {
return const_cast<ConcreteTable*
>(
this)->
operator==(other); }
699 void store(std::unique_ptr<Store> new_store)
override {
using std::swap;
swap(store_, new_store); }
709 std::vector<std::reference_wrapper<const Attribute>>
primary_key()
const override {
710 std::vector<std::reference_wrapper<const Attribute>> res;
711 for (
auto id : primary_key_)
712 res.emplace_back(
operator[](
id));
718 auto &attr = at(name);
719 primary_key_(attr.id) =
true;
725 auto res = name_to_attr_.emplace(name, attrs_.size());
727 throw std::invalid_argument(
"attribute name already in use");
728 attrs_.emplace_back(
Attribute(attrs_.size(), *
this, type, std::move(name)));
737 for (
size_t i = 0; i <=
id; ++i)
738 if (attrs_[i].is_hidden) ++
id;
742 virtual void dump(std::ostream &out)
const override;
743 virtual void dump()
const override;
795 virtual void store(std::unique_ptr<Store> new_store)
override {
table_->store(std::move(new_store)); }
801 virtual std::vector<std::reference_wrapper<const Attribute>>
primary_key()
const override {
return table_->primary_key(); }
810 virtual void dump(std::ostream & out)
const override {
table_->dump(out); }
822 void dump(std::ostream &out)
const override;
823 void dump()
const override;
834#define M_FUNCTION(NAME, KIND) FN_ ## NAME,
835#include <mutable/tables/Functions.tbl>
847 bool is_UDF()
const {
return fnid == FN_UDF; }
854 void dump(std::ostream &out)
const;
858 static constexpr const char *FNID_TO_STR_[] = {
859#define M_FUNCTION(NAME, KIND) "FN_" #NAME,
860#include <mutable/tables/Functions.tbl>
878 std::unique_ptr<idx::IndexBase>
index;
882 std::unique_ptr<idx::IndexBase> index)
883 : name(
std::move(name))
885 , attribute(attribute)
886 , index(
std::move(index))
894 std::unordered_map<ThreadSafePooledString, std::unique_ptr<Table>>
tables_;
895 std::unordered_map<ThreadSafePooledString, Function*>
functions_;
906 std::size_t
size()
const {
return tables_.size(); }
919 auto it = tables_.find(table->name());
920 if (it != tables_.end())
throw std::invalid_argument(
"table with that name already exists");
921 it = tables_.emplace_hint(it, table->name(), std::move(table));
928 auto it = tables_.find(name);
929 if (it == tables_.end())
930 throw std::invalid_argument(
"Table of that name does not exist.");
947 auto old = std::move(cardinality_estimator_); cardinality_estimator_ = std::move(CE);
return old;
959 if (has_index(index_name))
961 auto &table = get_table(table_name);
962 auto &attribute = table.at(attribute_name);
963 indexes_.emplace_back(std::move(index_name), table, attribute, std::move(index));
968 for (
auto it = indexes_.cbegin(); it != indexes_.cend(); ++it) {
969 if (it->name == index_name) {
979 if (not has_table(table_name))
981 for (
auto it = indexes_.cbegin(); it != indexes_.end();) {
982 if (it->table.name() == table_name)
983 it = indexes_.erase(it);
990 for (
auto it = indexes_.cbegin(); it != indexes_.cend(); ++it)
991 if (it->name == index_name)
return true;
999 auto it = tables_.find(table_name);
1000 if (it == tables_.end())
1002 auto &table = it->second;
1003 if (not table->has_attribute(attribute_name))
1005 for (
auto &entry : indexes_) {
1006 if (entry.is_valid
and entry.table.name() == table_name
and entry.attribute.name == attribute_name
and
1007 entry.index->method() == method)
1017 for (
auto &entry : indexes_) {
1018 if (entry.name == index_name)
1019 return *entry.index;
1029 auto it = tables_.find(table_name);
1030 if (it == tables_.end())
1032 auto &table = it->second;
1033 if (not table->has_attribute(attribute_name))
1035 for (
auto &entry : indexes_) {
1036 if (entry.is_valid
and entry.table.name() == table_name
and entry.attribute.name == attribute_name
and
1037 entry.index->method() == method)
1039 return *entry.index;
1042 throw m::invalid_argument(
"Index of that method on that attribute of that table does not exist.");
1047 if (not has_table(table_name))
1049 for (
auto &entry : indexes_) {
1050 if (entry.table.name() == table_name)
1051 entry.is_valid =
false;
1062struct hash<
m::Schema::Identifier>
1066 uint64_t h = hash<m::ThreadSafePooledString>{}(
id.name);
1067 if (
id.prefix.has_value())
1068 h *= hash<m::ThreadSafePooledOptionalString>{}(
id.prefix);
1075struct hash<
m::Attribute>
1079 auto h = hash<m::ThreadSafePooledString>{}(attr.
table.
name());
1080 return h * (attr.
id + 1);
and(sizeof(T)==4) U64x1 reinterpret_to_U64(m
#define M_unreachable(MSG)
#define M_ENUM_TO_STR(LIST)
IndexMethod
An enum class that lists all supported index methods.
Schema operator&(const Schema &left, const Schema &right)
Computes the set intersection of two Schemas.
bool type_check(const Attribute &attr)
Checks that the type of the attr matches the template type T.
Schema operator+(const Schema &left, const Schema &right)
void swap(PlanTableBase< Actual > &first, PlanTableBase< Actual > &second)
ThreadSafeStringPool::proxy_type ThreadSafePooledString
Schema operator|(const Schema &left, const Schema &right)
and arithmetic< U > and same_signedness< T, U > U
ThreadSafeStringPool::proxy_optional_type ThreadSafePooledOptionalString
const PrimitiveType * type
the type of the attribute
M_LCOV_EXCL_START friend std::ostream & operator<<(std::ostream &out, const Attribute &attr)
Attribute(Attribute &&)=default
const Table & table
the table the attribute belongs to
bool operator==(const Attribute &other) const
Compares to attributes.
std::size_t id
the internal identifier of the attribute, unique within its table
Attribute(std::size_t id, const Table &table, const PrimitiveType *type, ThreadSafePooledString name)
bool operator!=(const Attribute &other) const
Attribute(const Attribute &)=delete
ThreadSafePooledString name
the name of the attribute
The catalog contains all Databases and keeps track of all meta information of the database system.
Basic implementation of Table.
void add_primary_key(const ThreadSafePooledString &name) override
Adds an attribute with the given name to the primary key of this table.
void push_back(ThreadSafePooledString name, const PrimitiveType *type) override
Adds a new attribute with the given name and type to the table.
virtual hidden_iterator end_hidden() const override
virtual all_iterator begin_all() const override
std::size_t num_hidden_attrs() const override
Returns the number of hidden attributes in this table.
virtual all_iterator cend_all() const override
const Attribute & operator[](std::size_t id) const override
virtual iterator end() const override
const storage::DataLayout & layout() const override
Returns a reference to the physical data layout.
virtual hidden_iterator begin_hidden() const override
SmallBitset primary_key_
the primary key of this table, maintained as a SmallBitset over attribute id's
const ThreadSafePooledString & name() const override
Returns the name of the Table.
storage::DataLayout layout_
the physical data layout for this table
Attribute & operator[](const ThreadSafePooledString &name) override
Returns the attribute with the given name.
const Attribute & at(std::size_t id) const override
virtual all_iterator end_all() const override
std::size_t num_attrs() const override
Returns the number of non-hidden attributes in this table.
std::size_t num_all_attrs() const override
Returns the number of attributes in this table.
Store & store() const override
Returns a reference to the backing store.
size_t convert_id(size_t id) override
Converts the id an non-hidden attribute would have in a table without any hidden attributes and retur...
table_type attrs_
the attributes of this table, maintained as a sorted set
bool has_attribute(const ThreadSafePooledString &name) const override
Returns true iff the table has an attribute name.
Attribute & operator[](std::size_t id) override
Returns the attribute with the given id.
const Attribute & operator[](const ThreadSafePooledString &name) const override
ThreadSafePooledString name_
the name of the table
virtual hidden_iterator cend_hidden() const override
std::unique_ptr< Store > store_
the store backing this table; may be nullptr
virtual all_iterator cbegin_all() const override
std::vector< std::reference_wrapper< const Attribute > > primary_key() const override
Returns all attributes forming the primary key.
virtual ~ConcreteTable()=default
Attribute & at(const ThreadSafePooledString &name) override
Returns the attribute with the given name.
virtual iterator cend() const override
const Attribute & at(const ThreadSafePooledString &name) const override
ConcreteTable(ThreadSafePooledString name)
virtual iterator cbegin() const override
std::unordered_map< ThreadSafePooledString, table_type::size_type > name_to_attr_
maps attribute names to attributes
virtual hidden_iterator cbegin_hidden() const override
Attribute & at(std::size_t id) override
Returns the attribute with the given id.
void store(std::unique_ptr< Store > new_store) override
Sets the backing store for this table.
void layout(storage::DataLayout &&new_layout) override
Sets the physical data layout for this table.
virtual iterator begin() const override
index_entry_type(ThreadSafePooledString name, const Table &table, const Attribute &attribute, std::unique_ptr< idx::IndexBase > index)
bool is_valid
indicates if the index should be used to answer queries
const Table & table
the table of the index
std::unique_ptr< idx::IndexBase > index
the actual index
ThreadSafePooledString name
the name of the index
const Attribute & attribute
the indexed attribute
A Database is a set of Tables, Functions, and Statistics.
std::unordered_map< ThreadSafePooledString, Function * > functions_
functions defined in this database
void drop_table(const ThreadSafePooledString &name)
Drops the Table with the given name.
std::unordered_map< ThreadSafePooledString, std::unique_ptr< Table > > tables_
the tables of this database
Table & get_table(const ThreadSafePooledString &name) const
Returns a reference to the Table with the given name.
void invalidate_indexes(const ThreadSafePooledString &table_name)
Invalidates all indexes on attributes of Table table_name s.t.
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.
std::size_t size() const
Returns the number of tables in this Database.
auto begin_tables() 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.
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.
std::unique_ptr< CardinalityEstimator > cardinality_estimator_
the CardinalityEstimator of this Database
const idx::IndexBase & get_index(const ThreadSafePooledString &index_name) const
Returns the index with the given index_name.
std::list< index_entry_type > indexes_
the indexes of this database
std::unique_ptr< CardinalityEstimator > cardinality_estimator(std::unique_ptr< CardinalityEstimator > CE)
Sets the CardinalityEstimator of this Database.
const CardinalityEstimator & cardinality_estimator() const
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.
ThreadSafePooledString name
the name of the database
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.
bool is_UDF() const
Returns true iff this is a user-defined function.
M_DECLARE_ENUM(kind_t) kind
the function kind: Scalar, Aggregate, etc.
Function(ThreadSafePooledString name, fnid_t fnid, kind_t kind)
bool is_scalar() const
Returns true iff this function is scalar, i.e. if it is evaluated per tuple.
fnid_t fnid
the function id
ThreadSafePooledString name
the name of the function
bool is_aggregate() const
Returns true iff this function is an aggregation, i.e. if it is evaluated on all tuples.
A multi-versioning table is a Table with additional invisible timestamp attributes.
PrimitiveTypes represent Types of values.
bool is_vectorial() const
Returns true iff this PrimitiveType is vectorial, i.e. if it is for a sequence of values.
An Identifier is composed of a name and an optional prefix.
static Identifier CONST_ID_
bool operator!=(const Identifier &other) const
Identifier(ThreadSafePooledOptionalString prefix, ThreadSafePooledString name)
Identifier(ThreadSafePooledString name)
ThreadSafePooledOptionalString prefix
optional prefix of this Identifier, may not have a value
M_LCOV_EXCL_START friend std::ostream & operator<<(std::ostream &out, const Identifier &id)
ThreadSafePooledString name
the name of this Identifier
bool operator==(const Identifier &other) const
static entry_type CreateArtificial()
entry_type(Identifier id, const Type *type, constraints_t constraints=constraints_t{0})
constraints_t constraints
bool references_unique() const
A Schema represents a sequence of identifiers, optionally with a prefix, and their associated types.
std::size_t num_entries() const
Returns the number of entries in this Schema.
const_iterator end() const
const_iterator find(const Identifier &id) const
Returns an iterator to the entry with the given Identifier id, or end() if no such entry exists.
const entry_type & operator[](std::size_t idx) const
Returns the entry at index idx.
decltype(entries_)::const_iterator const_iterator
const_iterator cend() const
entry_type & at(std::size_t idx)
Returns the entry at index idx with in-bounds checking.
const entry_type & at(std::size_t idx) const
Returns the entry at index idx with in-bounds checking.
bool operator!=(const Schema &other) const
entry_type & operator[](std::size_t idx)
Returns the entry at index idx.
std::vector< entry_type > entries_
std::pair< std::size_t, entry_type & > operator[](const Identifier &id)
Returns a std::pair of the index and a reference to the entry with Identifier id.
std::pair< std::size_t, const entry_type & > operator[](const Identifier &id) const
Returns a std::pair of the index and a reference to the entry with Identifier id.
const std::vector< entry_type > & entries() const
const_iterator cbegin() const
void add(Identifier id, const Type *type)
Adds a new entry id of type type to this Schema.
Schema deduplicate() const
Returns a deduplicated version of this Schema, i.e.
iterator find(const Identifier &id)
Returns an iterator to the entry with the given Identifier id, or end() if no such entry exists.
void add(Identifier id, const Type *type, entry_type::constraints_t constraints)
Adds a new entry id of type type with constraints constraints to this Schema.
Schema & operator|=(const Schema &other)
Adds all entries of other to this Schema using set semantics.
M_LCOV_EXCL_START friend std::ostream & operator<<(std::ostream &out, const Schema &schema)
Schema & operator+=(const Schema &other)
Adds all entries of other to this Schema, potentially introducing duplicates.
std::pair< std::size_t, const entry_type & > at(const Identifier &id) const
Returns a std::pair of the index and a reference to the entry with Identifier id with in-bounds check...
void add(entry_type e)
Adds the entry e to this Schema.
decltype(entries_)::iterator iterator
Schema drop_constants() const
Returns a copy of this Schema where all constant entries are removed.
bool operator==(const Schema &other) const
Checks whether two Schemas have identical Identifiers by checking for mutual set-inclusion.
std::pair< std::size_t, entry_type & > at(const Identifier &id)
Returns a std::pair of the index and a reference to the entry with Identifier id with in-bounds check...
bool has(const Identifier &id) const
Returns true iff this Schema contains an entry with Identifier id.
const_iterator begin() const
Implements a small and efficient set over integers in the range of 0 to 63 (including).
Defines a generic store interface.
Abstract Decorator class that concrete TableDecorator inherit from.
virtual iterator end() const override
virtual std::vector< std::reference_wrapper< const Attribute > > primary_key() const override
Returns all attributes forming the primary key.
virtual hidden_iterator end_hidden() const override
virtual const storage::DataLayout & layout() const override
Returns a reference to the physical data layout.
virtual void store(std::unique_ptr< Store > new_store) override
Sets the backing store for this table.
virtual iterator cend() const override
virtual all_iterator begin_all() const override
virtual hidden_iterator begin_hidden() const override
virtual size_t num_all_attrs() const override
virtual hidden_iterator cend_hidden() const override
virtual all_iterator end_all() const override
virtual void dump(std::ostream &out) const override
virtual void add_primary_key(const ThreadSafePooledString &name) override
Adds an attribute with the given name to the primary key of this table.
virtual iterator begin() const override
virtual const Attribute & operator[](std::size_t id) const override
virtual Attribute & at(std::size_t id) override
Returns the attribute with the given id.
virtual Store & store() const override
Returns a reference to the backing store.
virtual const Attribute & at(const ThreadSafePooledString &name) const override
virtual size_t num_attrs() const override
Returns the number of attributes in this table.
virtual all_iterator cend_all() const override
std::unique_ptr< Table > table_
virtual const Attribute & at(std::size_t id) const override
virtual Attribute & operator[](std::size_t id) override
Returns the attribute with the given id.
virtual hidden_iterator cbegin_hidden() const override
virtual bool operator==(const Table &other) override
Returns true iff the Table other is the same as this, false otherwise.
virtual void layout(const storage::DataLayoutFactory &factory) override
Sets the physical data layout for this table by calling factory.make().
virtual size_t convert_id(size_t id) override
Converts the id an non-hidden attribute would have in a table without any hidden attributes and retur...
virtual iterator cbegin() const override
virtual void push_back(ThreadSafePooledString name, const PrimitiveType *type) override
Adds a new attribute with the given name and type to the table.
virtual all_iterator cbegin_all() const override
TableDecorator(std::unique_ptr< Table > table)
virtual ~TableDecorator()=default
virtual bool has_attribute(const ThreadSafePooledString &name) const override
Returns true iff the table has an attribute name.
virtual Attribute & at(const ThreadSafePooledString &name) override
Returns the attribute with the given name.
virtual const ThreadSafePooledString & name() const override
Returns the name of the Table.
virtual void layout(storage::DataLayout &&new_layout) override
Sets the physical data layout for this table.
virtual Attribute & operator[](const ThreadSafePooledString &name) override
Returns the attribute with the given name.
virtual const Attribute & operator[](const ThreadSafePooledString &name) const override
virtual void dump() const override
virtual size_t num_hidden_attrs() const override
virtual Schema schema(const ThreadSafePooledOptionalString &alias) const override
Returns a Schema for this Table given the alias alias.
difference_type operator-(the_iterator other) const
the_iterator(it_type start, it_type end)
the_iterator operator--(int)
the_iterator & operator+=(int offset)
std::ptrdiff_t difference_type
the_iterator & operator--()
bool operator==(const the_iterator &other) const
the_iterator & operator-=(int offset)
pointer operator->() const
reference operator*() const
the_iterator operator++(int)
table_type::const_iterator it_type
bool operator!=(const the_iterator &other) const
the_iterator(it_type it, it_type start, it_type end)
the_iterator & operator++()
A table is a sorted set of attributes.
virtual const storage::DataLayout & layout() const =0
Returns a reference to the physical data layout.
virtual all_iterator begin_all() const =0
virtual void layout(storage::DataLayout &&new_layout)=0
Sets the physical data layout for this table.
virtual iterator cend() const =0
virtual const ThreadSafePooledString & name() const =0
Returns the name of the Table.
virtual hidden_iterator cbegin_hidden() const =0
virtual const Attribute & operator[](std::size_t id) const =0
virtual hidden_iterator begin_hidden() const =0
virtual std::size_t num_hidden_attrs() const =0
virtual void store(std::unique_ptr< Store > new_store)=0
Sets the backing store for this table.
virtual iterator cbegin() const =0
virtual bool has_attribute(const ThreadSafePooledString &name) const =0
Returns true iff the table has an attribute name.
virtual const Attribute & at(const ThreadSafePooledString &name) const =0
virtual all_iterator cbegin_all() const =0
virtual hidden_iterator end_hidden() const =0
virtual const Attribute & at(std::size_t id) const =0
virtual void dump() const =0
virtual all_iterator end_all() const =0
virtual const Attribute & operator[](const ThreadSafePooledString &name) const =0
virtual void add_primary_key(const ThreadSafePooledString &name)=0
Adds an attribute with the given name to the primary key of this table.
virtual Attribute & operator[](const ThreadSafePooledString &name)=0
Returns the attribute with the given name.
virtual iterator end() const =0
virtual Store & store() const =0
Returns a reference to the backing store.
virtual hidden_iterator cend_hidden() const =0
virtual void dump(std::ostream &out) const =0
virtual Attribute & at(std::size_t id)=0
Returns the attribute with the given id.
virtual std::vector< std::reference_wrapper< const Attribute > > primary_key() const =0
Returns all attributes forming the primary key.
virtual std::size_t num_attrs() const =0
Returns the number of attributes in this table.
virtual std::size_t num_all_attrs() const =0
virtual Attribute & operator[](std::size_t id)=0
Returns the attribute with the given id.
virtual Schema schema(const ThreadSafePooledOptionalString &alias={}) const =0
Returns a Schema for this Table given the alias alias.
virtual size_t convert_id(size_t id)=0
Converts the id an non-hidden attribute would have in a table without any hidden attributes and retur...
std::vector< Attribute > table_type
virtual void push_back(ThreadSafePooledString name, const PrimitiveType *type)=0
Adds a new attribute with the given name and type to the table.
virtual Attribute & at(const ThreadSafePooledString &name)=0
Returns the attribute with the given name.
virtual iterator begin() const =0
virtual all_iterator cend_all() const =0
virtual void layout(const storage::DataLayoutFactory &factory)=0
Sets the physical data layout for this table by calling factory.make().
This class represents types in the SQL type system.
The base class for indexes.
Signals that an argument to a function of method was invalid.
Signals that an index-based or key-based access was out of range.
This is an interface for factories that compute particular DataLayouts for a given sequence of Types,...
Models how data is laid out in a linear address space.
uint64_t operator()(const m::Attribute &attr) const
uint64_t operator()(const m::Schema::Identifier &id) const