Skip to content

Commit 2173a93

Browse files
author
Vahag Bejanyan
committed
Merge branch 'master' of https://github.com/lnikon/tinykvpp
2 parents 2b72bbd + 928ff53 commit 2173a93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+993
-1036
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
BasedOnStyle: LLVM
2-
ColumnLimit: 80
2+
ColumnLimit: 120
33
IndentWidth: 4
44
TabWidth: 4
55
UseTab: Never

bench/fs/lots_of_write.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
void fstream_test()
1515
{
1616
const std::string filename("test_stream_3.txt");
17-
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
17+
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
1818
if (!fs.is_open())
1919
{
2020
std::cerr << "unable to open" << filename << '\n';
2121
exit(EXIT_FAILURE);
2222
}
2323

24-
size_t count{9 * 1024};
24+
size_t count{9 * 1024};
2525
std::string payload("aaa");
2626
while (count-- != 0)
2727
{
@@ -32,14 +32,14 @@ void fstream_test()
3232
void posix_write_test()
3333
{
3434
const std::string filename("test_stream_2.txt");
35-
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
35+
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
3636
if (fd == -1)
3737
{
3838
std::cerr << "Unable to open " << filename << '\n';
3939
}
4040

4141
std::string payload("bbbbb");
42-
size_t count{9 * 1024};
42+
size_t count{9 * 1024};
4343
while (count-- != 0)
4444
{
4545
write(fd, payload.c_str(), payload.size());

bench/fs/open_write_streams.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
static void BM_BenchmarkFstreamWrite(benchmark::State &state)
1414
{
1515
const std::string filename("test_stream.txt");
16-
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
16+
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
1717
if (!fs.is_open())
1818
{
1919
std::cerr << "unable to open" << filename << '\n';
@@ -33,7 +33,7 @@ BENCHMARK(BM_BenchmarkFstreamWrite);
3333
static void BM_BenchmarkFstreamWriteWithFlush(benchmark::State &state)
3434
{
3535
const std::string filename("test_stream.txt");
36-
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
36+
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
3737
if (!fs.is_open())
3838
{
3939
std::cerr << "unable to open" << filename << '\n';
@@ -54,7 +54,7 @@ BENCHMARK(BM_BenchmarkFstreamWriteWithFlush);
5454
static void BM_BenchmarkFstreamWriteWithSync(benchmark::State &state)
5555
{
5656
const std::string filename("test_stream.txt");
57-
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
57+
std::fstream fs(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
5858
if (!fs.is_open())
5959
{
6060
std::cerr << "unable to open" << filename << '\n';
@@ -75,7 +75,7 @@ BENCHMARK(BM_BenchmarkFstreamWriteWithSync);
7575
static void BM_BenchmarkFstreamWriteNoBuffering(benchmark::State &state)
7676
{
7777
const std::string filename("test_stream.txt");
78-
std::fstream fs;
78+
std::fstream fs;
7979
fs.rdbuf()->pubsetbuf(nullptr, 0);
8080

8181
fs.open(filename, std::fstream::in | std::fstream::out | std::fstream::app | std::fstream::ate);
@@ -98,7 +98,7 @@ BENCHMARK(BM_BenchmarkFstreamWriteNoBuffering);
9898
static void BM_BenchmarkPosixWrite(benchmark::State &state)
9999
{
100100
const std::string filename("test_stream_2.txt");
101-
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
101+
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
102102
if (fd == -1)
103103
{
104104
std::cerr << "Unable to open " << filename << '\n';
@@ -117,7 +117,7 @@ BENCHMARK(BM_BenchmarkPosixWrite);
117117
static void BM_BenchmarkPosixWriteODirect(benchmark::State &state)
118118
{
119119
const std::string filename("test_stream_2.txt");
120-
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT | O_DIRECT, 0644);
120+
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT | O_DIRECT, 0644);
121121
if (fd == -1)
122122
{
123123
std::cerr << "Unable to open " << filename << '\n';
@@ -136,14 +136,14 @@ BENCHMARK(BM_BenchmarkPosixWriteODirect);
136136
static void BM_BenchmarkPosixScatterWrite(benchmark::State &state)
137137
{
138138
const std::string filename("test_stream_2.txt");
139-
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
139+
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
140140
if (fd == -1)
141141
{
142142
std::cerr << "Unable to open " << filename << '\n';
143143
}
144144

145145
std::vector<iovec> iov;
146-
std::string payload("bbbbb");
146+
std::string payload("bbbbb");
147147
for (auto _ : state)
148148
{
149149
iov.emplace_back(iovec{.iov_base = payload.data(), .iov_len = payload.size()});
@@ -157,14 +157,14 @@ BENCHMARK(BM_BenchmarkPosixScatterWrite);
157157
static void BM_BenchmarkPosixScatterWriteWithODirect(benchmark::State &state)
158158
{
159159
const std::string filename("test_stream_2.txt");
160-
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT | O_DIRECT, 0644);
160+
int fd = open(filename.c_str(), O_WRONLY | O_APPEND | O_CREAT | O_DIRECT, 0644);
161161
if (fd == -1)
162162
{
163163
std::cerr << "Unable to open " << filename << '\n';
164164
}
165165

166166
std::vector<iovec> iov;
167-
std::string payload("bbbbb");
167+
std::string payload("bbbbb");
168168
for (auto _ : state)
169169
{
170170
iov.emplace_back(iovec{.iov_base = payload.data(), .iov_len = payload.size()});
@@ -178,7 +178,7 @@ BENCHMARK(BM_BenchmarkPosixScatterWriteWithODirect);
178178
static void BM_BenchmarkFWrite(benchmark::State &state)
179179
{
180180
const std::string filename("test_stream_3.txt");
181-
FILE *file = fopen(filename.c_str(), "w");
181+
FILE *file = fopen(filename.c_str(), "w");
182182
if (file == nullptr)
183183
{
184184
std::cerr << "Unable to open " << filename << '\n';
@@ -197,7 +197,7 @@ BENCHMARK(BM_BenchmarkFWrite);
197197
static void BM_BenchmarkFWriteNoBuffering(benchmark::State &state)
198198
{
199199
const std::string filename("test_stream_3.txt");
200-
FILE *file = fopen(filename.c_str(), "w");
200+
FILE *file = fopen(filename.c_str(), "w");
201201
if (file == nullptr)
202202
{
203203
std::cerr << "Unable to open " << filename << '\n';

examples/absl/concurrency/thread_safe_queue.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ template <typename TItem> class thread_safe_queue_t
3636
{
3737
/*absl::WriterMutexLock lock(&m_mutex);*/
3838
// if (!m_mutex.AwaitWithTimeout(
39-
// absl::Condition(+[](queue_t *queue) { return !queue->empty(); }, &m_queue), absl::Seconds(1)))
39+
// absl::Condition(+[](queue_t *queue) { return !queue->empty();
40+
// }, &m_queue), absl::Seconds(1)))
4041
//{
4142
// return std::nullopt;
4243
// }
4344

44-
/*spdlog::debug("Popping item from the queue. size={}", m_queue.size());*/
45+
/*spdlog::debug("Popping item from the queue. size={}",
46+
* m_queue.size());*/
4547

4648
std::unique_lock<std::mutex> lk(smut);
4749
cv.wait_for(lk, std::chrono::seconds(1), [this] { return !m_queue.empty(); });

lib/config/config.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ namespace config
44
{
55

66
/**
7-
* @brief Name of directory inside the database root dir where segments should be stored
7+
* @brief Name of directory inside the database root dir where segments should
8+
* be stored
89
*/
910
constexpr const std::string_view SegmentsDirectoryName{"segments"};
1011

lib/db/db.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ auto db_t::get(const structures::lsmtree::key_t &key) -> std::optional<structure
7272
return m_lsmTree.get(key);
7373
}
7474

75-
auto db_t::config() const noexcept -> config::shared_ptr_t
75+
auto db_t::config() const noexcept -> config::shared_ptr_t
7676
{
7777
return m_config;
7878
}

lib/db/db.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class db_t
4545
*/
4646
auto get(const structures::lsmtree::key_t &key) -> std::optional<structures::memtable::memtable_t::record_t>;
4747

48-
auto config() const noexcept -> config::shared_ptr_t ;
48+
auto config() const noexcept -> config::shared_ptr_t;
4949

5050
private:
5151
auto prepare_directory_structure() -> bool;
@@ -58,7 +58,7 @@ class db_t
5858

5959
using shared_ptr_t = std::shared_ptr<db_t>;
6060

61-
template <typename... Args> auto make_shared(Args&&... args)
61+
template <typename... Args> auto make_shared(Args &&...args)
6262
{
6363
return std::make_shared<db_t>(std::forward<Args>(args)...);
6464
}

lib/db/db_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
TEST_CASE("db interface validation", "[db]")
1010
{
1111
config::shared_ptr_t pConfig{config::make_shared()};
12-
auto pSegmentStorage{structures::lsmtree::segments::storage::make_shared()};
13-
auto manifest{db::manifest::make_shared(pConfig)};
14-
auto wal{db::wal::make_shared("wal")};
15-
auto lsmTree{structures::lsmtree::lsmtree_t{pConfig, manifest, wal}};
12+
auto pSegmentStorage{structures::lsmtree::segments::storage::make_shared()};
13+
auto manifest{db::manifest::make_shared(pConfig)};
14+
auto wal{db::wal::make_shared("wal")};
15+
auto lsmTree{structures::lsmtree::lsmtree_t{pConfig, manifest, wal}};
1616

1717
SECTION("fail when db path is empty")
1818
{

lib/db/manifest/manifest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ namespace db::manifest
1414

1515
static constexpr const std::string_view current_filename("current");
1616

17-
// Manifest file will be periodically rotated to we need a unique filename every time
17+
// Manifest file will be periodically rotated to we need a unique filename every
18+
// time
1819
auto manifest_filename() -> std::string
1920
{
2021
return fmt::format("manifest_{}", structures::lsmtree::segments::helpers::uuid());

lib/db/manifest/manifest.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ struct manifest_t
7272

7373
/**
7474
* @brief Serialize manifest segment record into stream.
75-
* Format: <operation-type><whitespace><segment-name><whitespace><level-index>
76-
* |int |char |string |char |int
75+
* Format:
76+
* <operation-type><whitespace><segment-name><whitespace><level-index>
77+
* |int |char |string |char |int
7778
*
7879
* @tparam stream_gt
7980
* @param os

0 commit comments

Comments
 (0)