libfoedus-core
FOEDUS Core Library
|
Represents one input stream of sorted log entries. More...
Represents one input stream of sorted log entries.
At the end of reducer, the reducer reads dumped sorted run files and does the final apply phase to construct the new version of each storage's pages. This is done by invoking each storage's composer interface with this object as inputs. To avoid invoking composer for each log entry (which is very expensive), this object allows the composer to receive sufficiently large buffers and do sort-merge itself.
Definition at line 81 of file log_buffer.hpp.
#include <log_buffer.hpp>
Public Member Functions | |
SortedBuffer (char *buffer, uint64_t buffer_size, uint64_t total_size) | |
virtual | ~SortedBuffer () |
uint64_t | to_relative_pos (uint64_t absolute_pos) const |
uint64_t | to_absolute_pos (uint64_t relative_pos) const |
const char * | get_buffer () const |
Returns the buffer memory. More... | |
uint64_t | get_buffer_size () const |
Returns the size of buffer memory. More... | |
uint64_t | get_offset () const |
Returns the absolute byte position of the buffer's beginning in the entire file. More... | |
uint64_t | get_total_size () const |
Returns the total size of the underlying stream (eg file size). More... | |
storage::StorageId | get_cur_block_storage_id () const |
uint32_t | get_cur_block_log_count () const |
uint64_t | get_cur_block_abosulte_begin () const |
Current storage block's beginning in absolute byte position in the file. More... | |
uint64_t | get_cur_block_abosulte_end () const |
Current storage block's end in absolute byte position in the file. More... | |
uint32_t | get_cur_block_shortest_key_length () const |
Current storage block's shortest key length. More... | |
uint32_t | get_cur_block_longest_key_length () const |
Current storage block's longest key length. More... | |
void | set_current_block (storage::StorageId storage_id, uint32_t log_count, uint64_t abosulte_begin, uint64_t abosulte_end, uint32_t shortest_key_length, uint32_t longest_key_length) |
bool | is_valid_current_block () const |
void | invalidate_current_block () |
virtual ErrorCode | wind (uint64_t next_absolute_pos)=0 |
Loads next data block to be consumed by the caller (composer). More... | |
virtual std::string | to_string () const =0 |
Returns a short string that briefly describes this object. More... | |
virtual void | describe (std::ostream *o) const =0 |
Writes out a detailed description of this object to stream. More... | |
void | assert_checks () |
Protected Member Functions | |
void | describe_base_elements (std::ostream *o) const |
Protected Attributes | |
char *const | buffer_ |
const uint64_t | buffer_size_ |
uint64_t | offset_ |
see get_offset() More... | |
const uint64_t | total_size_ |
see get_total_size() More... | |
storage::StorageId | cur_block_storage_id_ |
If this is zero, this buffer is not set for reading any block. More... | |
uint32_t | cur_block_log_count_ |
uint64_t | cur_block_abosulte_begin_ |
see get_cur_block_abosulte_begin() More... | |
uint64_t | cur_block_abosulte_end_ |
see get_cur_block_abosulte_end() More... | |
uint32_t | cur_block_shortest_key_length_ |
additional statistics for masstree/hash More... | |
uint32_t | cur_block_longest_key_length_ |
additional statistics for masstree/hash More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const SortedBuffer &v) |
|
inline |
Definition at line 83 of file log_buffer.hpp.
References assert_checks().
|
inlinevirtual |
Definition at line 94 of file log_buffer.hpp.
|
inline |
Definition at line 177 of file log_buffer.hpp.
References ASSERT_ND, buffer_size_, cur_block_abosulte_begin_, cur_block_abosulte_end_, cur_block_log_count_, cur_block_longest_key_length_, cur_block_shortest_key_length_, cur_block_storage_id_, offset_, and total_size_.
Referenced by foedus::storage::sequential::StreamStatus::init(), foedus::snapshot::MergeSort::initialize_once(), set_current_block(), SortedBuffer(), and foedus::snapshot::DumpFileSortedBuffer::wind().
|
pure virtual |
Writes out a detailed description of this object to stream.
Implemented in foedus::snapshot::DumpFileSortedBuffer, and foedus::snapshot::InMemorySortedBuffer.
Referenced by foedus::snapshot::operator<<().
|
protected |
Definition at line 37 of file log_buffer.cpp.
References buffer_, buffer_size_, cur_block_abosulte_begin_, cur_block_abosulte_end_, cur_block_log_count_, cur_block_storage_id_, offset_, and total_size_.
Referenced by foedus::snapshot::InMemorySortedBuffer::describe(), and foedus::snapshot::DumpFileSortedBuffer::describe().
|
inline |
Returns the buffer memory.
Definition at line 108 of file log_buffer.hpp.
References buffer_.
Referenced by foedus::storage::sequential::StreamStatus::init(), and foedus::snapshot::MergeSort::initialize_once().
|
inline |
Returns the size of buffer memory.
Definition at line 111 of file log_buffer.hpp.
References buffer_size_.
Referenced by foedus::storage::sequential::StreamStatus::init(), and foedus::snapshot::MergeSort::initialize_once().
|
inline |
Current storage block's beginning in absolute byte position in the file.
Definition at line 129 of file log_buffer.hpp.
References cur_block_abosulte_begin_.
Referenced by foedus::storage::sequential::StreamStatus::init(), and foedus::snapshot::MergeSort::initialize_once().
|
inline |
Current storage block's end in absolute byte position in the file.
Definition at line 131 of file log_buffer.hpp.
References cur_block_abosulte_end_.
Referenced by foedus::storage::sequential::StreamStatus::init(), and foedus::snapshot::MergeSort::initialize_once().
|
inline |
Definition at line 126 of file log_buffer.hpp.
References cur_block_log_count_.
|
inline |
Current storage block's longest key length.
Definition at line 135 of file log_buffer.hpp.
References cur_block_longest_key_length_.
Referenced by foedus::snapshot::extract_longest_key_length().
|
inline |
Current storage block's shortest key length.
Definition at line 133 of file log_buffer.hpp.
References cur_block_shortest_key_length_.
Referenced by foedus::snapshot::extract_shortest_key_length().
|
inline |
Definition at line 125 of file log_buffer.hpp.
References cur_block_storage_id_.
|
inline |
Returns the absolute byte position of the buffer's beginning in the entire file.
For example, buffer size = 1MB, file size = 1GB. Now we are reading 3200KB-4224KB region. In that case, this returns 3200KB. This value changes when the caller invokes wind() to shifts the buffer window.
Definition at line 120 of file log_buffer.hpp.
References offset_.
Referenced by foedus::storage::sequential::StreamStatus::init(), and foedus::snapshot::MergeSort::initialize_once().
|
inline |
Returns the total size of the underlying stream (eg file size).
Definition at line 123 of file log_buffer.hpp.
References total_size_.
|
inline |
Definition at line 153 of file log_buffer.hpp.
References cur_block_storage_id_.
|
inline |
Definition at line 152 of file log_buffer.hpp.
References cur_block_storage_id_.
|
inline |
Definition at line 137 of file log_buffer.hpp.
References assert_checks(), cur_block_abosulte_begin_, cur_block_abosulte_end_, cur_block_log_count_, cur_block_longest_key_length_, cur_block_shortest_key_length_, and cur_block_storage_id_.
|
inline |
Definition at line 102 of file log_buffer.hpp.
References ASSERT_ND, buffer_size_, and offset_.
|
inline |
Definition at line 96 of file log_buffer.hpp.
References ASSERT_ND, buffer_size_, and offset_.
Referenced by foedus::storage::sequential::StreamStatus::wind_stream().
|
pure virtual |
Returns a short string that briefly describes this object.
Implemented in foedus::snapshot::DumpFileSortedBuffer, and foedus::snapshot::InMemorySortedBuffer.
|
pure virtual |
Loads next data block to be consumed by the caller (composer).
[in] | next_absolute_pos | the absolute byte position that will be guaranteed to be within the buffer after this method call. Note that this position might not become 0-th byte position after this method call because the buffer might be backed by an aligned File I/O. |
Implemented in foedus::snapshot::DumpFileSortedBuffer, and foedus::snapshot::InMemorySortedBuffer.
Referenced by foedus::storage::sequential::StreamStatus::wind_stream().
|
friend |
Definition at line 32 of file log_buffer.cpp.
|
protected |
Definition at line 194 of file log_buffer.hpp.
Referenced by describe_base_elements(), get_buffer(), and foedus::snapshot::DumpFileSortedBuffer::wind().
|
protected |
Definition at line 195 of file log_buffer.hpp.
Referenced by assert_checks(), describe_base_elements(), foedus::snapshot::DumpFileSortedBuffer::DumpFileSortedBuffer(), get_buffer_size(), to_absolute_pos(), to_relative_pos(), foedus::snapshot::InMemorySortedBuffer::wind(), and foedus::snapshot::DumpFileSortedBuffer::wind().
|
protected |
see get_cur_block_abosulte_begin()
Definition at line 205 of file log_buffer.hpp.
Referenced by assert_checks(), describe_base_elements(), get_cur_block_abosulte_begin(), and set_current_block().
|
protected |
see get_cur_block_abosulte_end()
Definition at line 207 of file log_buffer.hpp.
Referenced by assert_checks(), describe_base_elements(), get_cur_block_abosulte_end(), and set_current_block().
|
protected |
Definition at line 203 of file log_buffer.hpp.
Referenced by assert_checks(), describe_base_elements(), get_cur_block_log_count(), and set_current_block().
|
protected |
additional statistics for masstree/hash
Definition at line 211 of file log_buffer.hpp.
Referenced by assert_checks(), get_cur_block_longest_key_length(), and set_current_block().
|
protected |
additional statistics for masstree/hash
Definition at line 209 of file log_buffer.hpp.
Referenced by assert_checks(), get_cur_block_shortest_key_length(), and set_current_block().
|
protected |
If this is zero, this buffer is not set for reading any block.
Definition at line 202 of file log_buffer.hpp.
Referenced by assert_checks(), describe_base_elements(), get_cur_block_storage_id(), invalidate_current_block(), is_valid_current_block(), and set_current_block().
|
protected |
see get_offset()
Definition at line 197 of file log_buffer.hpp.
Referenced by assert_checks(), describe_base_elements(), get_offset(), to_absolute_pos(), to_relative_pos(), and foedus::snapshot::DumpFileSortedBuffer::wind().
|
protected |
see get_total_size()
Definition at line 199 of file log_buffer.hpp.
Referenced by assert_checks(), describe_base_elements(), foedus::snapshot::DumpFileSortedBuffer::DumpFileSortedBuffer(), get_total_size(), and foedus::snapshot::DumpFileSortedBuffer::wind().