A RowSnapshot that stores rows in shared, immutable chunks.
More...
#include <data_source.hpp>
|
| | TableSnapshot (std::size_t columnCount) |
| | Constructs an empty snapshot.
|
| std::size_t | rowCount () const override |
| | The number of rows.
|
| std::size_t | columnCount () const noexcept |
| | The number of columns.
|
| RowId | rowId (std::size_t row) const override |
| | A row's key.
|
| Cell | cell (std::size_t row, std::size_t column) const override |
| | One cell.
|
| void | readColumn (std::size_t column, ColumnSink &sink, std::size_t first, std::size_t last) const override |
| | Hands rows [first, last) of column to sink, one run per chunk.
|
| std::shared_ptr< TableSnapshot const > | withRow (std::size_t row, std::vector< Cell > cells) const |
| | A copy of this snapshot with one row's cells replaced. Only that row's chunk is copied.
|
| std::shared_ptr< TableSnapshot const > | withInserted (std::size_t row, RowId key, std::vector< Cell > cells) const |
| | A copy with a row inserted before row. Chunks before it are shared.
|
| std::shared_ptr< TableSnapshot const > | withRemoved (std::size_t row) const |
| | A copy with row row removed. Chunks before it are shared.
|
| bool | sharesChunk (TableSnapshot const &other, std::size_t row) const noexcept |
| | Whether this snapshot and other share the chunk holding row.
|
|
| static std::shared_ptr< TableSnapshot const > | fromRows (std::size_t columnCount, std::vector< RowId > ids, std::vector< std::vector< Cell > > rows) |
| | Builds a snapshot from rows.
|
|
| static constexpr std::size_t | kChunkRows = 256 |
| | Rows per chunk: small enough that copying one is cheap, large enough that a column read hands long runs.
|
|
|
| RowSnapshot (RowSnapshot const &)=default |
| | Copies the base of a snapshot: a derived snapshot makes a changed copy of itself this way.
|
|
| RowSnapshot (RowSnapshot &&)=default |
| | Moves the base of a snapshot.
|
| RowSnapshot & | operator= (RowSnapshot const &)=default |
| | Copy-assigns the base of a snapshot.
|
| RowSnapshot & | operator= (RowSnapshot &&)=default |
| | Move-assigns the base of a snapshot.
|
A RowSnapshot that stores rows in shared, immutable chunks.
Changing one row produces a new snapshot that shares every chunk but the one holding the row, so a stream of updates against a table a worker is still reading costs one chunk copy per update, not one table copy.
Definition at line 513 of file data_source.hpp.
◆ TableSnapshot()
| morph::table::TableSnapshot::TableSnapshot |
( |
std::size_t | columnCount | ) |
|
|
inlineexplicit |
Constructs an empty snapshot.
- Parameters
-
| columnCount | Number of columns every row has. |
Definition at line 521 of file data_source.hpp.
◆ fromRows()
| std::shared_ptr< TableSnapshot const > morph::table::TableSnapshot::fromRows |
( |
std::size_t | columnCount, |
|
|
std::vector< RowId > | ids, |
|
|
std::vector< std::vector< Cell > > | rows ) |
|
inlinestaticnodiscard |
Builds a snapshot from rows.
- Parameters
-
| columnCount | Number of columns. |
| ids | The rows' keys. |
| rows | The rows' cells; each row has columnCount cells (missing cells are empty, extra cells are dropped). |
- Returns
- The snapshot.
Definition at line 529 of file data_source.hpp.
◆ rowCount()
| std::size_t morph::table::TableSnapshot::rowCount |
( |
| ) |
const |
|
inlinenodiscardoverridevirtual |
◆ columnCount()
| std::size_t morph::table::TableSnapshot::columnCount |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
The number of columns.
- Returns
- Column count.
Definition at line 542 of file data_source.hpp.
◆ rowId()
| RowId morph::table::TableSnapshot::rowId |
( |
std::size_t | row | ) |
const |
|
inlinenodiscardoverridevirtual |
◆ cell()
| Cell morph::table::TableSnapshot::cell |
( |
std::size_t | row, |
|
|
std::size_t | column ) const |
|
inlinenodiscardoverridevirtual |
◆ readColumn()
| void morph::table::TableSnapshot::readColumn |
( |
std::size_t | column, |
|
|
ColumnSink & | sink, |
|
|
std::size_t | first, |
|
|
std::size_t | last ) const |
|
inlineoverridevirtual |
Hands rows [first, last) of column to sink, one run per chunk.
- Parameters
-
| column | Column index. |
| sink | Receives the cells. |
| first | First row. |
| last | One past the last row. |
Reimplemented from morph::table::RowSnapshot.
Definition at line 564 of file data_source.hpp.
◆ withRow()
| std::shared_ptr< TableSnapshot const > morph::table::TableSnapshot::withRow |
( |
std::size_t | row, |
|
|
std::vector< Cell > | cells ) const |
|
inlinenodiscard |
A copy of this snapshot with one row's cells replaced. Only that row's chunk is copied.
- Parameters
-
| row | Row index. |
| cells | The new cells. |
- Returns
- The new snapshot.
Definition at line 579 of file data_source.hpp.
◆ withInserted()
| std::shared_ptr< TableSnapshot const > morph::table::TableSnapshot::withInserted |
( |
std::size_t | row, |
|
|
RowId | key, |
|
|
std::vector< Cell > | cells ) const |
|
inlinenodiscard |
A copy with a row inserted before row. Chunks before it are shared.
- Parameters
-
| row | Insert position, at most rowCount(). |
| key | The new row's key. |
| cells | The new row's cells. |
- Returns
- The new snapshot.
Definition at line 595 of file data_source.hpp.
◆ withRemoved()
| std::shared_ptr< TableSnapshot const > morph::table::TableSnapshot::withRemoved |
( |
std::size_t | row | ) |
const |
|
inlinenodiscard |
A copy with row row removed. Chunks before it are shared.
- Parameters
-
- Returns
- The new snapshot.
Definition at line 608 of file data_source.hpp.
◆ sharesChunk()
| bool morph::table::TableSnapshot::sharesChunk |
( |
TableSnapshot const & | other, |
|
|
std::size_t | row ) const |
|
inlinenodiscardnoexcept |
Whether this snapshot and other share the chunk holding row.
- Parameters
-
| other | Another snapshot. |
| row | Row index valid in both. |
- Returns
- true when the chunk is the same object.
Definition at line 621 of file data_source.hpp.
◆ kChunkRows
| std::size_t morph::table::TableSnapshot::kChunkRows = 256 |
|
staticconstexpr |
Rows per chunk: small enough that copying one is cheap, large enough that a column read hands long runs.
Definition at line 517 of file data_source.hpp.
The documentation for this class was generated from the following file: