vkdb
A time series database engine in C++.
Loading...
Searching...
No Matches
table.h
1#ifndef DATABASE_TABLE_H
2#define DATABASE_TABLE_H
3
4#include <vkdb/concepts.h>
5#include <vkdb/lsm_tree.h>
6#include <vkdb/friendly_builder.h>
7#include <fstream>
8
9namespace vkdb {
14static const FilePath TAG_COLUMNS_FILENAME{"tag_columns.metadata"};
15
20using DatabaseName = std::string;
21
26using TableName = std::string;
27
32class Table {
33public:
38 Table() = delete;
39
49 explicit Table(const FilePath& db_path, const TableName& name);
50
55 Table(Table&&) noexcept = default;
56
61 Table& operator=(Table&&) noexcept = default;
62
67 Table(const Table&) = delete;
68
73 Table& operator=(const Table&) = delete;
74
79 ~Table() noexcept = default;
80
87 Table& setTagColumns(const TagColumns& tag_columns) noexcept;
88
98 Table& addTagColumn(const TagKey& tag_column);
99
109 Table& removeTagColumn(const TagKey& tag_column);
110
116 void clear() const noexcept;
117
123 [[nodiscard]] FriendlyQueryBuilder<double> query() noexcept;
124
130 [[nodiscard]] TableName name() const noexcept;
131
137 [[nodiscard]] TagColumns tagColumns() const noexcept;
138
144 [[nodiscard]] FilePath path() const noexcept;
145
146private:
151 using StorageEngine = LSMTree<double>;
152
160 [[nodiscard]] bool been_populated() const noexcept;
161
168 void save_tag_columns() const;
169
176 void load_tag_columns();
177
183 [[nodiscard]] FilePath tag_columns_path() const noexcept;
184
193 void load();
194
199 DatabaseName db_path_;
200
205 TableName name_;
206
211 TagColumns tag_columns_;
212
217 StorageEngine storage_engine_;
218};
219
220} // namespace vkdb
221
222#endif // DATABASE_TABLE_H
Friendly query builder for querying a Table.
Represents a table in vkdb.
Definition table.h:32
void clear() const noexcept
Clear the table.
Definition table.cpp:54
Table & addTagColumn(const TagKey &tag_column)
Add a tag column.
Definition table.cpp:18
TableName name() const noexcept
Get the name of the table.
Definition table.cpp:63
Table & setTagColumns(const TagColumns &tag_columns) noexcept
Set the TagColumns object.
Definition table.cpp:13
Table(Table &&) noexcept=default
Move-construct a new Table object.
TagColumns tagColumns() const noexcept
Get the TagColumns object.
Definition table.cpp:67
FilePath path() const noexcept
Get the path to the table directory.
Definition table.cpp:71
FriendlyQueryBuilder< double > query() noexcept
Get a FriendlyQueryBuilder object.
Definition table.cpp:59
Table & removeTagColumn(const TagKey &tag_column)
Remove a tag column.
Definition table.cpp:36
Table()=delete
Deleted default constructor.