libfoedus-core
FOEDUS Core Library
|
Writes out one snapshot file for all data pages in one reducer. More...
Writes out one snapshot file for all data pages in one reducer.
In a nutshell, snapshot writer is a in-memory page pool that dumps out some or all of the pages to a snapshot file. It consists of 3 phases for each storage.
Definition at line 76 of file snapshot_writer_impl.hpp.
#include <snapshot_writer_impl.hpp>
Public Member Functions | |
SnapshotWriter (Engine *engine, uint16_t numa_node, SnapshotId snapshot_id, memory::AlignedMemory *pool_memory, memory::AlignedMemory *intermediate_memory, bool append=false) | |
~SnapshotWriter () | |
ErrorStack | open () |
Open the file so that the writer can start writing. More... | |
bool | is_opened () const |
bool | close () |
Close the file and makes sure all writes become durable (including the directory entry). More... | |
SnapshotWriter ()=delete | |
SnapshotWriter (const SnapshotWriter &other)=delete | |
SnapshotWriter & | operator= (const SnapshotWriter &other)=delete |
uint16_t | get_numa_node () const |
storage::Page * | get_page_base () __attribute__((always_inline)) |
memory::PagePoolOffset | get_page_size () const __attribute__((always_inline)) |
storage::Page * | get_intermediate_base () __attribute__((always_inline)) |
memory::PagePoolOffset | get_intermediate_size () const __attribute__((always_inline)) |
storage::SnapshotPagePointer | get_next_page_id () const |
SnapshotId | get_snapshot_id () const |
storage::Page * | resolve (memory::PagePoolOffset offset) __attribute__((always_inline)) |
memory::PagePoolOffset | resolve (storage::Page *page) __attribute__((always_inline)) |
ErrorCode | dump_pages (memory::PagePoolOffset from_page, uint32_t count) |
Write out pages that are contiguous in the main page pool. More... | |
ErrorCode | dump_intermediates (memory::PagePoolOffset from_page, uint32_t count) |
Write out pages that are contiguous in the sub intermediate page pool. More... | |
std::string | to_string () const |
ErrorCode | expand_pool_memory (uint32_t required_pages, bool retain_content) |
Expands pool_memory_ in case it is too small. More... | |
ErrorCode | expand_intermediate_memory (uint32_t required_pages, bool retain_content) |
Expands intermediate_memory_ in case it is too small. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const SnapshotWriter &v) |
foedus::snapshot::SnapshotWriter::SnapshotWriter | ( | Engine * | engine, |
uint16_t | numa_node, | ||
SnapshotId | snapshot_id, | ||
memory::AlignedMemory * | pool_memory, | ||
memory::AlignedMemory * | intermediate_memory, | ||
bool | append = false |
||
) |
Definition at line 36 of file snapshot_writer_impl.cpp.
|
inline |
Definition at line 85 of file snapshot_writer_impl.hpp.
References close().
|
delete |
|
delete |
bool foedus::snapshot::SnapshotWriter::close | ( | ) |
Close the file and makes sure all writes become durable (including the directory entry).
Definition at line 53 of file snapshot_writer_impl.cpp.
References foedus::fs::DirectIoFile::close(), foedus::fs::fsync(), and foedus::fs::DirectIoFile::get_path().
Referenced by open(), and ~SnapshotWriter().
|
inline |
Write out pages that are contiguous in the sub intermediate page pool.
[in] | from_page | beginning of contiguous in-memory pages to fix |
[in] | count | number of pages to write out |
Definition at line 144 of file snapshot_writer_impl.hpp.
|
inline |
Write out pages that are contiguous in the main page pool.
[in] | from_page | beginning of contiguous in-memory pages to fix |
[in] | count | number of pages to write out |
Definition at line 135 of file snapshot_writer_impl.hpp.
Referenced by foedus::storage::hash::ComposedBinsMergedStream::assure_writer_buffer(), foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::hash::HashComposer::construct_root(), foedus::storage::masstree::MasstreeComposer::construct_root(), and foedus::storage::sequential::SequentialComposer::construct_root().
ErrorCode foedus::snapshot::SnapshotWriter::expand_intermediate_memory | ( | uint32_t | required_pages, |
bool | retain_content | ||
) |
Expands intermediate_memory_ in case it is too small.
[in] | required_pages | number of pages that are guaranteed after expansion. The actual size will probably be larger than this value to avoid frequent expansion. |
[in] | retain_content | whether to copy the content of old memory to new memory |
Does nothing if it's already enough large. We use this method to make sure intermediate pool (which some composer assumes sufficiently large) can contain all intermediate pages.
Definition at line 163 of file snapshot_writer_impl.cpp.
References ASSERT_ND, foedus::memory::AlignedMemory::assure_capacity(), CHECK_ERROR_CODE, get_intermediate_size(), and foedus::kErrorCodeOk.
Referenced by foedus::storage::hash::ComposedBinsMergedStream::assure_writer_buffer().
ErrorCode foedus::snapshot::SnapshotWriter::expand_pool_memory | ( | uint32_t | required_pages, |
bool | retain_content | ||
) |
Expands pool_memory_ in case it is too small.
[in] | required_pages | number of pages that are guaranteed after expansion. The actual size will probably be larger than this value to avoid frequent expansion. |
[in] | retain_content | whether to copy the content of old memory to new memory |
Does nothing if it's already enough large. Most likely we don't have to use this method as composers should be able to run even when the number of leaf (content) pages is large.
Definition at line 150 of file snapshot_writer_impl.cpp.
References ASSERT_ND, foedus::memory::AlignedMemory::assure_capacity(), CHECK_ERROR_CODE, get_page_size(), and foedus::kErrorCodeOk.
|
inline |
Definition at line 108 of file snapshot_writer_impl.hpp.
References foedus::memory::AlignedMemory::get_block().
Referenced by foedus::storage::array::ArrayComposeContext::ArrayComposeContext(), foedus::storage::hash::HashComposeContext::HashComposeContext(), and foedus::storage::hash::ComposedBinsMergedStream::open_path().
|
inline |
Definition at line 111 of file snapshot_writer_impl.hpp.
References foedus::memory::AlignedMemory::get_size(), and foedus::storage::kPageSize.
Referenced by foedus::storage::array::ArrayComposeContext::ArrayComposeContext(), foedus::storage::hash::ComposedBinsMergedStream::assure_writer_buffer(), expand_intermediate_memory(), foedus::storage::hash::HashComposeContext::HashComposeContext(), and foedus::storage::hash::ComposedBinsMergedStream::open_path().
|
inline |
Definition at line 115 of file snapshot_writer_impl.hpp.
Referenced by foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::hash::HashComposer::construct_root(), foedus::storage::masstree::MasstreeComposer::construct_root(), foedus::storage::sequential::SequentialComposer::construct_root(), foedus::storage::masstree::MasstreeComposeContext::MasstreeComposeContext(), and foedus::storage::hash::ComposedBinsMergedStream::open_path().
|
inline |
Definition at line 101 of file snapshot_writer_impl.hpp.
Referenced by foedus::storage::sequential::SequentialComposer::compose(), foedus::storage::sequential::SequentialComposer::construct_root(), and foedus::storage::array::ArrayComposeContext::execute().
|
inline |
Definition at line 102 of file snapshot_writer_impl.hpp.
References foedus::memory::AlignedMemory::get_block().
Referenced by foedus::storage::array::ArrayComposeContext::ArrayComposeContext(), foedus::storage::sequential::SequentialComposer::compose(), foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::hash::HashComposer::construct_root(), foedus::storage::masstree::MasstreeComposer::construct_root(), foedus::storage::sequential::SequentialComposer::construct_root(), foedus::storage::hash::HashComposeContext::HashComposeContext(), foedus::storage::hash::ComposedBinsMergedStream::open_path(), and resolve().
|
inline |
Definition at line 105 of file snapshot_writer_impl.hpp.
References foedus::memory::AlignedMemory::get_size(), and foedus::storage::kPageSize.
Referenced by foedus::storage::array::ArrayComposeContext::ArrayComposeContext(), foedus::storage::hash::ComposedBinsMergedStream::assure_writer_buffer(), foedus::storage::sequential::SequentialComposer::compose(), expand_pool_memory(), foedus::storage::hash::HashComposeContext::HashComposeContext(), foedus::storage::hash::ComposedBinsMergedStream::open_path(), and resolve().
|
inline |
Definition at line 116 of file snapshot_writer_impl.hpp.
Referenced by foedus::storage::sequential::SequentialComposer::compose(), foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::sequential::SequentialComposer::construct_root(), foedus::storage::masstree::from_this_snapshot(), and foedus::storage::hash::ComposedBinsMergedStream::init().
|
inline |
Definition at line 89 of file snapshot_writer_impl.hpp.
ErrorStack foedus::snapshot::SnapshotWriter::open | ( | ) |
Open the file so that the writer can start writing.
Definition at line 82 of file snapshot_writer_impl.cpp.
References ASSERT_ND, foedus::storage::PageHeader::checksum_, close(), foedus::snapshot::SnapshotOptions::emulation_, foedus::fs::file_size(), foedus::memory::AlignedMemory::get_block(), foedus::fs::DirectIoFile::get_current_offset(), foedus::Engine::get_options(), foedus::kRetOk, foedus::fs::DirectIoFile::open(), foedus::storage::PageHeader::page_id_, foedus::EngineOptions::snapshot_, foedus::storage::PageHeader::storage_id_, foedus::storage::to_snapshot_page_pointer(), to_string(), WRAP_ERROR_CODE, and foedus::fs::DirectIoFile::write().
|
delete |
|
inline |
Definition at line 118 of file snapshot_writer_impl.hpp.
References ASSERT_ND, get_page_base(), and get_page_size().
|
inline |
Definition at line 123 of file snapshot_writer_impl.hpp.
References ASSERT_ND, get_page_base(), and get_page_size().
|
inline |
Definition at line 148 of file snapshot_writer_impl.hpp.
Referenced by open().
|
friend |
Definition at line 174 of file snapshot_writer_impl.cpp.