libfoedus-core
FOEDUS Core Library
foedus::storage::sequential::StreamStatus Struct Reference

Unlike other composers, this one doesn't need merge sort. More...

Detailed Description

Unlike other composers, this one doesn't need merge sort.

It's dumb simple.

Definition at line 52 of file sequential_composer_impl.cpp.

Collaboration diagram for foedus::storage::sequential::StreamStatus:

Public Member Functions

ErrorCode init (snapshot::SortedBuffer *stream)
 
ErrorCode next ()
 
ErrorCode wind_stream ()
 
void read_entry ()
 
const SequentialAppendLogTypeget_entry () const
 

Public Attributes

snapshot::SortedBufferstream_
 
const char * buffer_
 
uint64_t buffer_size_
 
uint64_t cur_absolute_pos_
 
uint64_t cur_relative_pos_
 
uint64_t end_absolute_pos_
 
uint32_t cur_length_
 
const void * cur_payload_
 
xct::XctId cur_owner_id_
 
bool ended_
 

Member Function Documentation

const SequentialAppendLogType* foedus::storage::sequential::StreamStatus::get_entry ( ) const
inline

Definition at line 107 of file sequential_composer_impl.cpp.

References buffer_, and cur_relative_pos_.

Referenced by foedus::storage::sequential::SequentialComposer::compose(), and read_entry().

107  {
108  return reinterpret_cast<const SequentialAppendLogType*>(buffer_ + cur_relative_pos_);
109  }

Here is the caller graph for this function:

ErrorCode foedus::storage::sequential::StreamStatus::init ( snapshot::SortedBuffer stream)
inline

Definition at line 53 of file sequential_composer_impl.cpp.

References foedus::snapshot::SortedBuffer::assert_checks(), ASSERT_ND, buffer_, buffer_size_, CHECK_ERROR_CODE, cur_absolute_pos_, cur_length_, cur_relative_pos_, end_absolute_pos_, ended_, foedus::snapshot::SortedBuffer::get_buffer(), foedus::snapshot::SortedBuffer::get_buffer_size(), foedus::snapshot::SortedBuffer::get_cur_block_abosulte_begin(), foedus::snapshot::SortedBuffer::get_cur_block_abosulte_end(), foedus::snapshot::SortedBuffer::get_offset(), foedus::kErrorCodeOk, read_entry(), stream_, and wind_stream().

Referenced by foedus::storage::sequential::SequentialComposer::compose().

53  {
54  stream_ = stream;
56  buffer_ = stream->get_buffer();
57  buffer_size_ = stream->get_buffer_size();
58  cur_absolute_pos_ = stream->get_cur_block_abosulte_begin();
59  ASSERT_ND(cur_absolute_pos_ >= stream->get_offset());
60  cur_relative_pos_ = cur_absolute_pos_ - stream->get_offset();
61  end_absolute_pos_ = stream->get_cur_block_abosulte_end();
62  ended_ = false;
63  read_entry();
65  ended_ = true;
66  } else if (cur_relative_pos_ + cur_length_ > buffer_size_) {
67  LOG(INFO) << "interesting, super unlucky case. wind immediately";
69  read_entry();
70  ASSERT_ND(cur_relative_pos_ + cur_length_ <= buffer_size_);
71  }
72  return kErrorCodeOk;
73  }
0 means no-error.
Definition: error_code.hpp:87
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
#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

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorCode foedus::storage::sequential::StreamStatus::next ( )
inline

Definition at line 74 of file sequential_composer_impl.cpp.

References ASSERT_ND, buffer_size_, CHECK_ERROR_CODE, cur_absolute_pos_, cur_length_, cur_relative_pos_, end_absolute_pos_, ended_, foedus::kErrorCodeOk, read_entry(), UNLIKELY, and wind_stream().

Referenced by foedus::storage::sequential::SequentialComposer::compose().

74  {
75  ASSERT_ND(!ended_);
80  ended_ = true;
81  return kErrorCodeOk;
82  } else if (UNLIKELY(cur_relative_pos_ >= buffer_size_)) {
84  }
85  read_entry();
88  read_entry();
89  }
90 
92  return kErrorCodeOk;
93  }
0 means no-error.
Definition: error_code.hpp:87
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155
#define UNLIKELY(x)
Hints that x is highly likely false.
Definition: compiler.hpp:104
#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

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::sequential::StreamStatus::read_entry ( )
inline

Definition at line 99 of file sequential_composer_impl.cpp.

References ASSERT_ND, cur_length_, cur_owner_id_, cur_payload_, get_entry(), foedus::log::LogHeader::get_type(), foedus::log::BaseLogType::header_, foedus::log::kLogCodeSequentialAppend, foedus::log::LogHeader::log_length_, foedus::storage::sequential::SequentialAppendLogType::payload_, and foedus::log::LogHeader::xct_id_.

Referenced by init(), and next().

99  {
100  const SequentialAppendLogType* entry = get_entry();
101  ASSERT_ND(entry->header_.get_type() == log::kLogCodeSequentialAppend);
102  ASSERT_ND(entry->header_.log_length_ > 0);
103  cur_length_ = entry->header_.log_length_;
104  cur_payload_ = entry->payload_;
105  cur_owner_id_ = entry->header_.xct_id_;
106  }
const SequentialAppendLogType * get_entry() const
0x0026 : foedus::storage::sequential::SequentialAppendLogType .
Definition: log_type.hpp:119
#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

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorCode foedus::storage::sequential::StreamStatus::wind_stream ( )
inline

Definition at line 94 of file sequential_composer_impl.cpp.

References CHECK_ERROR_CODE, cur_absolute_pos_, cur_relative_pos_, foedus::kErrorCodeOk, stream_, foedus::snapshot::SortedBuffer::to_relative_pos(), and foedus::snapshot::SortedBuffer::wind().

Referenced by init(), and next().

94  {
97  return kErrorCodeOk;
98  }
virtual ErrorCode wind(uint64_t next_absolute_pos)=0
Loads next data block to be consumed by the caller (composer).
0 means no-error.
Definition: error_code.hpp:87
uint64_t to_relative_pos(uint64_t absolute_pos) const
Definition: log_buffer.hpp:96
#define CHECK_ERROR_CODE(x)
This macro calls x and checks its returned error code.
Definition: error_code.hpp:155

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

const char* foedus::storage::sequential::StreamStatus::buffer_

Definition at line 112 of file sequential_composer_impl.cpp.

Referenced by get_entry(), and init().

uint64_t foedus::storage::sequential::StreamStatus::buffer_size_

Definition at line 113 of file sequential_composer_impl.cpp.

Referenced by init(), and next().

uint64_t foedus::storage::sequential::StreamStatus::cur_absolute_pos_

Definition at line 114 of file sequential_composer_impl.cpp.

Referenced by init(), next(), and wind_stream().

uint32_t foedus::storage::sequential::StreamStatus::cur_length_

Definition at line 117 of file sequential_composer_impl.cpp.

Referenced by init(), next(), and read_entry().

xct::XctId foedus::storage::sequential::StreamStatus::cur_owner_id_
const void* foedus::storage::sequential::StreamStatus::cur_payload_
uint64_t foedus::storage::sequential::StreamStatus::cur_relative_pos_

Definition at line 115 of file sequential_composer_impl.cpp.

Referenced by get_entry(), init(), next(), and wind_stream().

uint64_t foedus::storage::sequential::StreamStatus::end_absolute_pos_

Definition at line 116 of file sequential_composer_impl.cpp.

Referenced by init(), and next().

bool foedus::storage::sequential::StreamStatus::ended_
snapshot::SortedBuffer* foedus::storage::sequential::StreamStatus::stream_

Definition at line 111 of file sequential_composer_impl.cpp.

Referenced by init(), and wind_stream().


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