libfoedus-core
FOEDUS Core Library
foedus::snapshot::InMemorySortedBuffer Class Referencefinal

Implementation of SortedBuffer that is backed by fully in-memory buffer. More...

Detailed Description

Implementation of SortedBuffer that is backed by fully in-memory buffer.

After all mappers are completed, the reducer actually skips dumping the last buffer because anyway it needs to read it back (BTW, if this is the only buffer, everything becomes in-memory, so efficient). In that case, we just sort the last buffer and provides it to composers as it is. This object is used in such cases.

Definition at line 225 of file log_buffer.hpp.

#include <log_buffer.hpp>

Inheritance diagram for foedus::snapshot::InMemorySortedBuffer:
Collaboration diagram for foedus::snapshot::InMemorySortedBuffer:

Public Member Functions

 InMemorySortedBuffer (char *buffer, uint64_t buffer_size)
 
 ~InMemorySortedBuffer () override
 
std::string to_string () const override
 Returns a short string that briefly describes this object. More...
 
ErrorCode wind (uint64_t next_absolute_pos) override
 Loads next data block to be consumed by the caller (composer). More...
 
void describe (std::ostream *o) const override
 Writes out a detailed description of this object to stream. More...
 
- Public Member Functions inherited from foedus::snapshot::SortedBuffer
 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 ()
 
void assert_checks ()
 

Additional Inherited Members

- Protected Member Functions inherited from foedus::snapshot::SortedBuffer
void describe_base_elements (std::ostream *o) const
 
- Protected Attributes inherited from foedus::snapshot::SortedBuffer
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...
 

Constructor & Destructor Documentation

foedus::snapshot::InMemorySortedBuffer::InMemorySortedBuffer ( char *  buffer,
uint64_t  buffer_size 
)
inline

Definition at line 227 of file log_buffer.hpp.

228  : SortedBuffer(buffer, buffer_size, buffer_size) {
229  }
SortedBuffer(char *buffer, uint64_t buffer_size, uint64_t total_size)
Definition: log_buffer.hpp:83
foedus::snapshot::InMemorySortedBuffer::~InMemorySortedBuffer ( )
inlineoverride

Definition at line 230 of file log_buffer.hpp.

230 {}

Member Function Documentation

void foedus::snapshot::InMemorySortedBuffer::describe ( std::ostream *  o) const
overridevirtual

Writes out a detailed description of this object to stream.

Implements foedus::snapshot::SortedBuffer.

Definition at line 49 of file log_buffer.cpp.

References foedus::snapshot::SortedBuffer::describe_base_elements().

49  {
50  std::ostream& o = *optr;
51  o << "<InMemorySortedBuffer>";
53  o << "</InMemorySortedBuffer>";
54 }
void describe_base_elements(std::ostream *o) const
Definition: log_buffer.cpp:37

Here is the call graph for this function:

std::string foedus::snapshot::InMemorySortedBuffer::to_string ( ) const
inlineoverridevirtual

Returns a short string that briefly describes this object.

Implements foedus::snapshot::SortedBuffer.

Definition at line 232 of file log_buffer.hpp.

232 { return "<in-memory buffer>"; }
ErrorCode foedus::snapshot::InMemorySortedBuffer::wind ( uint64_t  next_absolute_pos)
inlineoverridevirtual

Loads next data block to be consumed by the caller (composer).

Parameters
[in]next_absolute_posthe 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.
Precondition
next_absolute_pos <= get_total_size()
next_absolute_pos >= get_offset() : we allow foward-only iteration.
next_absolute_pos <= get_offset() + get_buffer_size() : we allow contiguous-read only.
Postcondition
get_offset() + get_buffer_size() > next_absolute_pos >= get_offset()
Returns
File I/O related errors only

Implements foedus::snapshot::SortedBuffer.

Definition at line 233 of file log_buffer.hpp.

References ASSERT_ND, foedus::snapshot::SortedBuffer::buffer_size_, and foedus::kErrorCodeOk.

233  {
234  ASSERT_ND(next_absolute_pos <= buffer_size_);
235  return kErrorCodeOk;
236  }
0 means no-error.
Definition: error_code.hpp:87
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

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