6#include <mutable/mutable-config.hpp>
25struct ConstDataLayoutVisitor;
57 uint64_t inode_offset_in_bits)>;
67 virtual void accept(ConstDataLayoutVisitor &v)
const = 0;
93 void accept(ConstDataLayoutVisitor &v)
const override;
105 std::unique_ptr<Node>
ptr;
118 : the_inode_(the_inode)
123 M_insist(&this->the_inode_ == &other.
the_inode_,
"comparing iterators to different INodes");
124 return this->idx_ == other.
idx_;
159 Leaf & add_leaf(
const m::Type *type,
size_type idx, uint64_t offset_in_bits, uint64_t stride_in_bits);
162 INode & add_inode(
size_type num_tuples, uint64_t offset_in_bits, uint64_t stride_in_bits);
166 M_insist(idx < children_.size(),
"index out of bounds");
167 return children_[idx];
172 return children_[idx];
180 void accept(ConstDataLayoutVisitor &v)
const override;
182 void for_sibling_leaves(
level_info_stack_t &level_info_stack, uint64_t inode_offset_in_bits,
185 void print(std::ostream &out,
unsigned indentation = 0)
const;
203 M_insist(is_finite(),
"infinite data layouts have no number of tuples");
214 explicit operator const INode&()
const {
return inode_; }
218 Leaf & add_leaf(
const m::Type *type, size_type idx, uint64_t stride_in_bits);
222 INode & add_inode(size_type num_tuples, uint64_t stride_in_bits);
224 void accept(ConstDataLayoutVisitor &v)
const;
225 void for_sibling_leaves(callback_leaves_t callback)
const;
230 out <<
"DataLayout of " << layout.
num_tuples() <<
" tuple(s)";
232 out <<
"DataLayout of infinite tuples";
238 void dump(std::ostream &out)
const { out << *
this << std::endl; }
242#define M_DATA_LAYOUT_CLASSES(X) \
243 X(DataLayout::INode) \
244 X(DataLayout::Leaf) \
#define M_DATA_LAYOUT_CLASSES(X)
#define M_DECLARE_VISITOR(VISITOR_NAME, BASE_CLASS, CLASS_LIST)
Defines a visitor VISITOR_NAME to visit the class hierarchy rooted in BASE_CLASS and with subclasses ...
const Schema const Schema & tuple_schema
std::size_t get_num_simd_lanes(const DataLayout &layout, const Schema &layout_schema, const Schema &tuple_schema)
Returns the number of SIMD lanes used for accessing tuples of schema tuple_schema in SIMDfied manner ...
const Schema & layout_schema
A Schema represents a sequence of identifiers, optionally with a prefix, and their associated types.
This class represents types in the SQL type system.
Signals that an argument to a function of method was invalid.
a child Node and its relative offset and stride within the containing INode
std::unique_ptr< Node > ptr
const child_t & operator->()
const child_t & operator*()
const_iterator operator++(int)
bool operator==(const_iterator other) const
const_iterator(const INode &the_inode, size_type idx=0)
const_iterator & operator++()
bool operator!=(const_iterator other) const
An internal node of the recursive data layout model.
std::vector< child_t > children_
the child Nodes of this INode
const child_t & at(size_type idx) const
returns a reference to the idx -th child; throws m::invalid_argument if idx is out of bounds
const_iterator cend() const
void print(std::ostream &out, unsigned indentation=0) const
const_iterator end() const
const_iterator cbegin() const
size_type num_tuples() const override
returns the number of tuples represented by an instance of this node
const child_t & operator[](size_type idx) const
returns a reference to the idx -th child
INode & operator=(INode &&)=default
INode(size_type num_tuples)
const_iterator begin() const
size_type num_tuples_
the number of tuples that fit into one instance of this INode
size_type num_children() const
returns the number of child Nodes of this INode
The Leaf represents exactly one attribue.
size_type num_tuples() const override
returns the number of tuples represented by an instance of this node
size_type idx_
an index that must be unique within the entire DataLayout
size_type index() const
Returns the index assigned to this Leaf.
Leaf(const m::Type *type, size_type idx)
const m::Type * type() const
Returns the Type of this Leaf.
const m::Type * type_
the Type of the attribute represented by this Leaf
an abstract node in the recursive data layout model
virtual size_type num_tuples() const =0
returns the number of tuples represented by an instance of this node
virtual void accept(ConstDataLayoutVisitor &v) const =0
combines information of a single leaf for for_sibling_leaves()
combines information of a single internal level inside the DataLayout, used by for_sibling_leaves()
uint64_t stride_in_bits
the stride of instances of this level
size_type num_tuples
number of tuples that fit into an instance of this level
Models how data is laid out in a linear address space.
bool is_finite() const
returns true iff this DataLayout lays out a finite sequence of tuples
INode inode_
use an INode to store a single child, allowing us to exploit INode abstractions within DataLayout
uint64_t stride_in_bits() const
return the stride (in bits) of the single child of the DataLayout
const Node & child() const
returns a reference to the single child of this DataLayout
size_type num_tuples() const
returns the number of tuples laid out by this DataLayout; must not be called when not is_finite()
std::vector< level_info_t > level_info_stack_t
void dump(std::ostream &out) const
M_LCOV_EXCL_START friend std::ostream & operator<<(std::ostream &out, const DataLayout &layout)
DataLayout(size_type num_tuples=0)
Create a new DataLayout for laying out num_tuples many tuples in linear memory.
std::function< void(const std::vector< leaf_info_t > &leaves, const level_info_stack_t &levels, uint64_t inode_offset_in_bits)> callback_leaves_t