1 #ifndef PERSIST_LOG_HPP 2 #define PERSIST_LOG_HPP 4 #if !defined(__GNUG__) && !defined(__clang__) 5 #error PersistLog.hpp only works with clang and gnu compilers 9 #include "../PersistException.hpp" 10 #include "../PersistentTypenames.hpp" 28 #define INVALID_VERSION ((int64_t)-1L) 29 #define INVALID_INDEX INT64_MAX 42 hlc_index_entry(
const uint64_t &r,
const uint64_t &l,
const int64_t &_log_idx) : hlc(r, l), log_idx(_log_idx) {
62 std::set<hlc_index_entry, hlc_index_entry_comp>
hidx;
65 #endif //DERECHO_DEBUG 71 PersistLog(
const std::string &name) noexcept(
true);
83 virtual
void append(const
void *pdata,
84 const uint64_t &size, const
version_t &ver,
85 const
HLC &mhlc) noexcept(false)
93 virtual
void advanceVersion(const
version_t &ver) noexcept(false) = 0;
96 virtual int64_t getLength() noexcept(false) = 0;
99 virtual int64_t getEarliestIndex() noexcept(false) = 0;
102 virtual int64_t getLatestIndex() noexcept(false) = 0;
105 virtual int64_t getVersionIndex(const
version_t &ver) noexcept(false) = 0;
108 virtual int64_t getHLCIndex(const
HLC&
hlc) noexcept(false) = 0;
111 virtual
version_t getEarliestVersion() noexcept(false) = 0;
114 virtual
version_t getLatestVersion() noexcept(false) = 0;
117 virtual const
version_t getLastPersisted() noexcept(false) = 0;
120 virtual const
void *getEntryByIndex(const int64_t &eno) noexcept(false) = 0;
123 virtual const
void *getEntry(const
version_t &ver) noexcept(false) = 0;
128 virtual const
void *getEntry(const
HLC &
hlc) noexcept(false) = 0;
136 virtual const
version_t persist(const
bool preLocked = false) noexcept(false) = 0;
143 virtual
void trimByIndex(const int64_t &idx) noexcept(false) = 0;
149 virtual
void trim(const
version_t &ver) noexcept(false) = 0;
155 virtual
void trim(const
HLC &
hlc) noexcept(false) = 0;
178 virtual
void post_object(const
std::function<
void(
char const *const,
std::
size_t)> &f,
187 virtual
void applyLogTail(
char const *v) = 0;
193 virtual
void truncate(const
version_t &ver) noexcept(false) = 0;
197 #endif //PERSIST_LOG_HPP hlc_index_entry(const struct hlc_index_entry &_entry)
This file include all common types internal to derecho and not necessarily being known by a client pr...
std::set< hlc_index_entry, hlc_index_entry_comp > hidx
auto bytes_size(const T &)
Just calls sizeof(T)
const std::string m_sName
hlc_index_entry(const HLC &_hlc, const int64_t &_log_idx)
hlc_index_entry(const uint64_t &r, const uint64_t &l, const int64_t &_log_idx)
std::enable_if_t< std::is_pod< BR >::value > post_object(const F &f, const BR &br, Args &&... args)
In-place serialization is also sometimes possible.
std::size_t to_bytes(const ByteRepresentable &b, char *v)
calls b.to_bytes(v) when b is a ByteRepresentable; calls std::memcpy() when b is POD.
bool operator()(const struct hlc_index_entry &e1, const struct hlc_index_entry &e2) const