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

This class implements a row store. More...

#include <RowStore.hpp>

Inheritance diagram for m::RowStore:
[legend]
Collaboration diagram for m::RowStore:
[legend]

Public Member Functions

 RowStore (const Table &table)
 
 ~RowStore ()
 
virtual std::size_t num_rows () const override
 Return the number of rows in this store.
 
int offset (uint32_t idx) const
 
int offset (const Attribute &attr) const
 
std::size_t row_size () const
 Returns the effective size of a row, in bits.
 
void append () override
 Append a row to the store.
 
void drop () override
 Drop the most recently appended row.
 
const memory::Memorymemory () const override
 Returns the memory of the store.
 
void memory (memory::Memory memory)
 Sets the memory of the store to memory.
 
void dump (std::ostream &out) const override
 
virtual void dump (std::ostream &out) const=0
 
void dump () const
 
const Tabletable () const
 

Static Public Attributes

static constexpr std::size_t ALLOCATION_SIZE = 1UL << 30
 1 GiB
 

Private Member Functions

void compute_offsets ()
 Computes the offsets of the attributes within a row.
 
uintptr_t at (std::size_t idx) const
 Return a pointer to the idxth row.
 

Private Attributes

memory::LinearAllocator allocator_
 the memory allocator
 
memory::Memory data_
 the underlying memory containing the data
 
std::size_t num_rows_ = 0
 the number of rows in use
 
std::size_t capacity_
 the number of available rows
 
uint32_t * offsets_
 the offsets from the first column, in bits, of all columns
 
uint32_t row_size_
 the size of a row, in bits; includes NULL bitmap and other meta data
 
const Tabletable_
 the table defining this store's schema
 

Detailed Description

This class implements a row store.

Definition at line 11 of file RowStore.hpp.

Constructor & Destructor Documentation

◆ RowStore()

RowStore::RowStore ( const Table table)

◆ ~RowStore()

RowStore::~RowStore ( )

Definition at line 26 of file RowStore.cpp.

References offsets_.

Member Function Documentation

◆ append()

void m::RowStore::append ( )
inlineoverridevirtual

Append a row to the store.

Implements m::Store.

Definition at line 42 of file RowStore.hpp.

References capacity_, and num_rows_.

◆ at()

uintptr_t m::RowStore::at ( std::size_t  idx) const
inlineprivate

Return a pointer to the idxth row.

Definition at line 67 of file RowStore.hpp.

References m::memory::Memory::as(), data_, and row_size_.

◆ compute_offsets()

void RowStore::compute_offsets ( )
private

Computes the offsets of the attributes within a row.

Tries to minimize the row size by storing the attributes in descending order of their size, avoiding padding.

Definition at line 31 of file RowStore.cpp.

References m::Type::alignment(), m::Attribute::id, m::Table::num_attrs(), offsets_, row_size_, m::Type::size(), m::Store::table(), and m::Attribute::type.

Referenced by RowStore().

◆ drop()

void m::RowStore::drop ( )
inlineoverridevirtual

Drop the most recently appended row.

Implements m::Store.

Definition at line 48 of file RowStore.hpp.

References M_insist, and num_rows_.

◆ dump() [1/3]

M_LCOV_EXCL_START void Store::dump ( ) const

Definition at line 51 of file Store.cpp.

◆ dump() [2/3]

M_LCOV_EXCL_START void RowStore::dump ( std::ostream &  out) const
overridevirtual

◆ dump() [3/3]

virtual void m::Store::dump ( std::ostream &  out) const
virtual

Implements m::Store.

◆ memory() [1/2]

const memory::Memory & m::RowStore::memory ( ) const
inlineoverridevirtual

Returns the memory of the store.

Implements m::Store.

Definition at line 54 of file RowStore.hpp.

References data_.

Referenced by memory().

◆ memory() [2/2]

void m::RowStore::memory ( memory::Memory  memory)
inline

Sets the memory of the store to memory.

Definition at line 56 of file RowStore.hpp.

References data_, and memory().

◆ num_rows()

virtual std::size_t m::RowStore::num_rows ( ) const
inlineoverridevirtual

Return the number of rows in this store.

Implements m::Store.

Definition at line 31 of file RowStore.hpp.

References num_rows_.

◆ offset() [1/2]

int m::RowStore::offset ( const Attribute attr) const
inline

Definition at line 37 of file RowStore.hpp.

References m::Attribute::id, and offset().

Referenced by offset().

◆ offset() [2/2]

int m::RowStore::offset ( uint32_t  idx) const
inline

Definition at line 33 of file RowStore.hpp.

References M_insist, offsets_, and m::Store::table().

◆ row_size()

std::size_t m::RowStore::row_size ( ) const
inline

Returns the effective size of a row, in bits.

Definition at line 40 of file RowStore.hpp.

References row_size_.

◆ table()

const Table & m::Store::table ( ) const
inlineinherited

Field Documentation

◆ ALLOCATION_SIZE

constexpr std::size_t m::RowStore::ALLOCATION_SIZE = 1UL << 30
staticconstexpr

1 GiB

Definition at line 14 of file RowStore.hpp.

Referenced by RowStore().

◆ allocator_

memory::LinearAllocator m::RowStore::allocator_
private

the memory allocator

Definition at line 20 of file RowStore.hpp.

Referenced by RowStore().

◆ capacity_

std::size_t m::RowStore::capacity_
private

the number of available rows

Definition at line 23 of file RowStore.hpp.

Referenced by append(), dump(), and RowStore().

◆ data_

memory::Memory m::RowStore::data_
private

the underlying memory containing the data

Definition at line 21 of file RowStore.hpp.

Referenced by at(), dump(), memory(), and RowStore().

◆ num_rows_

std::size_t m::RowStore::num_rows_ = 0
private

the number of rows in use

Definition at line 22 of file RowStore.hpp.

Referenced by append(), drop(), dump(), and num_rows().

◆ offsets_

uint32_t* m::RowStore::offsets_
private

the offsets from the first column, in bits, of all columns

Definition at line 24 of file RowStore.hpp.

Referenced by compute_offsets(), dump(), offset(), and ~RowStore().

◆ row_size_

uint32_t m::RowStore::row_size_
private

the size of a row, in bits; includes NULL bitmap and other meta data

Definition at line 25 of file RowStore.hpp.

Referenced by at(), compute_offsets(), dump(), row_size(), and RowStore().

◆ table_

const Table& m::Store::table_
privateinherited

the table defining this store's schema

Definition at line 24 of file Store.hpp.


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