Skip to content

Commit

Permalink
Refactor code to address clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
umegane committed Feb 20, 2025
1 parent fb1ac19 commit 18309d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
16 changes: 2 additions & 14 deletions src/limestone/datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,21 +711,9 @@ void datastore::compact_with_online() {
compaction_options options = [&]() -> compaction_options {
if (blob_file_gc_runnable) {
blob_file_gc_snapshot gc_snapshot(boundary_version_copy);
return compaction_options{
location_,
compaction_temp_dir,
recover_max_parallelism_,
need_compaction_filenames,
gc_snapshot
};
} else {
return compaction_options{
location_,
compaction_temp_dir,
recover_max_parallelism_,
need_compaction_filenames
};
return compaction_options{location_, compaction_temp_dir, recover_max_parallelism_, need_compaction_filenames, gc_snapshot};
}
return compaction_options{location_, compaction_temp_dir, recover_max_parallelism_, need_compaction_filenames};
}();

std::cerr << "is_gc_enabled = " << options.is_gc_enabled() << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions src/limestone/datastore_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void insert_entry_or_update_to_max(sortdb_wrapper* sortdb, const log_entr
// followed by the value data and then the BLOB ID data.
// This allows later splitting the stored data into the value part and the blob IDs.
std::size_t value_size = e.value_etc().size();
db_value.append(reinterpret_cast<const char*>(&value_size), sizeof(value_size));
db_value.append(reinterpret_cast<const char*>(&value_size), sizeof(value_size)); // NOLINT(*-reinterpret-cast)
db_value.append(e.value_etc());
db_value.append(e.raw_blob_ids());
} else {
Expand Down Expand Up @@ -237,7 +237,7 @@ static std::pair<std::string, std::string_view> split_db_value_and_blob_ids(cons

// 1. Extract value_etc size from the 8 bytes following the entry_type.
// No endian conversion is required.
const std::size_t value_etc_size = *reinterpret_cast<const std::size_t*>(raw_db_value.data() + 1);
const std::size_t value_etc_size = *reinterpret_cast<const std::size_t*>(raw_db_value.data() + 1); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)

// 2. The value_etc data starts after the entry_type and size field.
// The size field occupies 8 bytes, so the offset is 1 + 8 = 9.
Expand All @@ -247,7 +247,7 @@ static std::pair<std::string, std::string_view> split_db_value_and_blob_ids(cons
std::string value_etc(value_etc_size, '\0');

// Copy value_etc data from raw_db_value starting at value_etc_offset for value_etc_size bytes.
std::memcpy(&value_etc[0], raw_db_value.data() + value_etc_offset, value_etc_size);
std::memcpy(value_etc.data(), raw_db_value.data() + value_etc_offset, value_etc_size);

// 4. The blob_ids part is the remainder of raw_db_value after value_etc.
const std::size_t blob_ids_offset = value_etc_offset + value_etc_size;
Expand Down

0 comments on commit 18309d7

Please sign in to comment.