Joedb 10.2.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Readonly_Journal.h
Go to the documentation of this file.
1#ifndef joedb_Readonly_Journal_declared
2#define joedb_Readonly_Journal_declared
3
4#include "joedb/Writable.h"
9
10#include <array>
11
12namespace joedb
13{
14 class Writable_Journal;
15
16 /// @ingroup journal
18 {
19 friend class Writable_Journal;
20
21 private:
22 void read_checkpoint(const std::array<int64_t, 4> &pos, int64_t file_size);
23 void pull_without_locking();
24
25 #define TYPE_MACRO(cpp_type, return_type, type_id, read_method, W)\
26 void perform_update_##type_id(Writable &writable);
27 #include "joedb/TYPE_MACRO.h"
28
29 protected:
32
37
41
42 void reset_context();
43
45 std::string safe_read_string();
46
47 #define TYPE_MACRO(cpp_type, return_type, type_id, read_method, W)\
48 void read_vector_of_##type_id(cpp_type *data, size_t size);
49 #include "joedb/TYPE_MACRO.h"
50
51 enum class operation_t: uint8_t
52 {
53 create_table = 0x01,
54 drop_table = 0x02,
55 add_field = 0x03,
56 drop_field = 0x04,
57 insert_into = 0x05,
58 delete_from = 0x06,
59 update = 0x07, // deprecated
60 append = 0x08,
61 update_last = 0x09, // deprecated
62 comment = 0x0a,
63 timestamp = 0x0b,
64 rename_table = 0x0c,
65 rename_field = 0x0d,
66 valid_data = 0x0e,
67 insert_vector = 0x0f,
68 custom = 0x10,
69 update_vector = 0x11, // deprecated
70 update_next = 0x12, // deprecated
71 blob = 0x13,
72 delete_vector = 0x14,
73 updates = 0x80,
74 #define TYPE_MACRO(t, rt, type_id, r, w)\
75 update_##type_id,\
76 update_last_##type_id,\
77 update_next_##type_id,\
78 update_vector_##type_id,
79 #include "joedb/TYPE_MACRO.h"
80 };
81
82 public:
84
87 {
88 }
89
94
95 int64_t get_position() const {return file_buffer.get_position();}
96 int64_t get_checkpoint() const {return checkpoint_position;}
98 bool is_empty() const {return file.get_size() == Header::ssize;}
99 bool is_shared() const {return file.is_shared();}
100 int64_t pull();
101 const Abstract_File &get_file() const {return file;}
102 void replay_log(Writable &writable);
104 void rewind();
105 void one_step(Writable &writable);
106 void play_until(Writable &writable, int64_t end);
107 void raw_play_until(Writable &writable, int64_t end);
109 {
111 }
113 {
115 }
116 void skip_directly_to(int64_t position)
117 {
118 file_buffer.set_position(position);
119 }
120 bool equal_to(Readonly_Journal &journal, int64_t from, int64_t until) const
121 {
122 return file.equal_to(journal.file, from, until);
123 }
124
125 Async_Reader get_async_tail_reader(int64_t start_position) const
126 {
127 return Async_Reader(file, start_position, get_checkpoint());
128 }
129
130 Async_Reader get_async_reader(int64_t start_position, int64_t until_position) const
131 {
132 return Async_Reader
133 (
134 file,
135 start_position,
136 until_position
137 );
138 }
139
140 static constexpr uint32_t format_version = 5;
141 };
142}
143
144#endif
virtual int64_t get_size() const
Get the size of the file, or -1 if it is unknown.
bool is_shared() const noexcept
virtual bool equal_to(const Abstract_File &destination, int64_t from, int64_t until) const
int64_t get_position() const noexcept
Definition File_Buffer.h:75
void set_position(int64_t position)
int64_t get_hard_checkpoint() const
Readonly_Journal(Abstract_File &file)
void play_until(Writable &writable, int64_t end)
void one_step(Writable &writable)
static constexpr uint32_t format_version
Readonly_Journal(Journal_Construction_Lock &&lock)
int64_t get_position() const
void replay_with_checkpoint_comments(Writable &writable)
bool equal_to(Readonly_Journal &journal, int64_t from, int64_t until) const
const Abstract_File & get_file() const
void replay_log(Writable &writable)
void raw_play_until(Writable &writable, int64_t end)
Async_Reader get_async_reader(int64_t start_position, int64_t until_position) const
void play_until_checkpoint(Writable &writable)
void raw_play_until_checkpoint(Writable &writable)
int64_t get_checkpoint() const
Async_Reader get_async_tail_reader(int64_t start_position) const
void skip_directly_to(int64_t position)
Superclass with all joedb journal event listeners as virtual functions.
Definition Writable.h:17
static constexpr int64_t ssize
Definition Header.h:18