18 std::map<Table_Id, Table_Id> table_map;
21 for (
const auto &[tid, tname]: db.
get_tables())
24 table_map[tid] = mapped_tid;
32 std::map<Table_Id, std::map<Field_Id, Field_Id>> field_maps;
34 for (
const auto &[tid, tname]: db.
get_tables())
37 for (
const auto &[fid, fname]: db.
get_fields(tid))
43 field_maps[tid][fid] = mapped_fid;
45 writable.
add_field(table_map[tid], fname, type);
56 for (
const auto &[tid, tname]: db.
get_tables())
64 record_id <= last_record_id &&
75 record_id + size <= last_record_id &&
76 db.
is_used(tid, record_id + size)
85 record_id = record_id + size;
89 for (
const auto &[fid, fname]: db.
get_fields(tid))
91 for (
Record_Id record_id{1}; record_id <= last_record_id; ++record_id)
95 Table_Id mapped_tid = table_map[tid];
96 Field_Id mapped_fid = field_maps[tid][fid];
103 #define TYPE_MACRO(type, return_type, type_id, R, W)\
104 case Type::Type_Id::type_id:\
105 writable.update_##type_id\
107 mapped_tid, record_id, mapped_fid, db.get_##type_id(tid, record_id, fid)\
122 for (
const auto &[tid, tname]: db.
get_tables())
130 while (record_id <= last_record_id)
134 record_id <= last_record_id &&
145 record_id + size <= last_record_id &&
156 for (
const auto &[fid, fname]: db.
get_fields(tid))
163 #define TYPE_MACRO(type, return_type, type_id, R, W)\
164 case Type::Type_Id::type_id:\
166 writable.update_vector_##type_id\
189 for (
const auto &[fid, fname]: db.
get_fields(tid))
196 #define TYPE_MACRO(type, return_type, type_id, R, W)\
197 case Type::Type_Id::type_id:\
199 writable.update_##type_id\
204 db.get_##type_id(tid, record_id, fid)\
213 record_id = record_id + size;
bool is_used(ptrdiff_t index) const override
virtual const Type & get_field_type(Table_Id table_id, Field_Id field_id) const =0
bool is_used(Table_Id table_id, Record_Id record_id) const
virtual const Compact_Freedom_Keeper & get_freedom(Table_Id table_id) const =0
virtual const std::map< Field_Id, std::string > & get_fields(Table_Id table_id) const =0
Record_Id get_last_record_id(Table_Id table_id) const
virtual const std::map< Table_Id, std::string > & get_tables() const =0
void replay_log(Writable &writable)
static Type reference(Table_Id table_id)
Table_Id get_table_id() const
Type_Id get_type_id() const
virtual void insert_into(Table_Id table_id, Record_Id record_id)
virtual void create_table(const std::string &name)
virtual void insert_vector(Table_Id table_id, Record_Id record_id, size_t size)
virtual void add_field(Table_Id table_id, const std::string &name, Type type)
void pack(Readonly_Journal &input_journal, Writable &writable)
void dump(const Readable &db, Writable &writable, bool schema_only)
void dump_data(const Readable &db, Writable &writable)
constexpr std::underlying_type< Table_Id >::type to_underlying(Table_Id id)