Skip to content

Commit

Permalink
internal_repo_rocksdb (435146444452818992) (facebook#12115)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: facebook#12115

Differential Revision: D51745742

Pulled By: ajkr

fbshipit-source-id: a78b0a762df4263268193faa87d7c03c4d771f65
  • Loading branch information
ajkr authored and facebook-github-bot committed Dec 1, 2023
1 parent b760af3 commit 4f82416
Show file tree
Hide file tree
Showing 35 changed files with 281 additions and 207 deletions.
8 changes: 5 additions & 3 deletions table/cuckoo/cuckoo_table_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CuckooTableReader::CuckooTableReader(
identity_as_first_hash_(false),
use_module_hash_(false),
num_hash_func_(0),
unused_key_(""),

key_length_(0),
user_key_length_(0),
value_length_(0),
Expand Down Expand Up @@ -182,7 +182,9 @@ Status CuckooTableReader::Get(const ReadOptions& /*readOptions*/,
ParsedInternalKey found_ikey;
Status s = ParseInternalKey(full_key, &found_ikey,
false /* log_err_key */); // TODO
if (!s.ok()) return s;
if (!s.ok()) {
return s;
}
bool dont_care __attribute__((__unused__));
get_context->SaveValue(found_ikey, value, &dont_care);
}
Expand Down Expand Up @@ -213,7 +215,7 @@ class CuckooTableIterator : public InternalIterator {
// No copying allowed
CuckooTableIterator(const CuckooTableIterator&) = delete;
void operator=(const Iterator&) = delete;
~CuckooTableIterator() override {}
~CuckooTableIterator() override = default;
bool Valid() const override;
void SeekToFirst() override;
void SeekToLast() override;
Expand Down
8 changes: 4 additions & 4 deletions table/cuckoo/cuckoo_table_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ TEST_F(CuckooReaderTest, WhenKeyExistsWithUint64Comparator) {
fname = test::PerThreadDBPath("CuckooReaderUint64_WhenKeyExists");
for (uint64_t i = 0; i < num_items; i++) {
user_keys[i].resize(8);
memcpy(&user_keys[i][0], static_cast<void*>(&i), 8);
memcpy(user_keys[i].data(), static_cast<void*>(&i), 8);
ParsedInternalKey ikey(user_keys[i], i + 1000, kTypeValue);
AppendInternalKey(&keys[i], ikey);
values[i] = "value" + NumToStr(i);
Expand Down Expand Up @@ -296,7 +296,7 @@ TEST_F(CuckooReaderTest, CheckIteratorUint64) {
fname = test::PerThreadDBPath("CuckooReader_CheckIterator");
for (uint64_t i = 0; i < num_items; i++) {
user_keys[i].resize(8);
memcpy(&user_keys[i][0], static_cast<void*>(&i), 8);
memcpy(user_keys[i].data(), static_cast<void*>(&i), 8);
ParsedInternalKey ikey(user_keys[i], 1000, kTypeValue);
AppendInternalKey(&keys[i], ikey);
values[i] = "value" + NumToStr(i);
Expand Down Expand Up @@ -425,7 +425,7 @@ void WriteFile(const std::vector<std::string>& keys, const uint64_t num,
ASSERT_OK(builder.status());
for (uint64_t key_idx = 0; key_idx < num; ++key_idx) {
// Value is just a part of key.
builder.Add(Slice(keys[key_idx]), Slice(&keys[key_idx][0], 4));
builder.Add(Slice(keys[key_idx]), Slice(keys[key_idx].data(), 4));
ASSERT_EQ(builder.NumEntries(), key_idx + 1);
ASSERT_OK(builder.status());
}
Expand Down Expand Up @@ -454,7 +454,7 @@ void WriteFile(const std::vector<std::string>& keys, const uint64_t num,
value.Reset();
value.clear();
ASSERT_OK(reader.Get(r_options, Slice(keys[i]), &get_context, nullptr));
ASSERT_TRUE(Slice(keys[i]) == Slice(&keys[i][0], 4));
ASSERT_TRUE(Slice(keys[i]) == Slice(keys[i].data(), 4));
}
}

Expand Down
8 changes: 5 additions & 3 deletions table/format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ Status Footer::DecodeFrom(Slice input, uint64_t input_offset,
if (checksum_type_ != kNoChecksum && format_version_ >= 6) {
std::array<char, kNewVersionsEncodedLength> copy_without_checksum;
std::copy_n(input.data(), kNewVersionsEncodedLength,
&copy_without_checksum[0]);
copy_without_checksum.data());
EncodeFixed32(&copy_without_checksum[5], 0); // Clear embedded checksum
computed_checksum =
ComputeBuiltinChecksum(checksum_type(), copy_without_checksum.data(),
Expand Down Expand Up @@ -518,9 +518,11 @@ Status ReadFooterFromFile(const IOOptions& opts, RandomAccessFileReader* file,
} else {
footer_buf.reserve(Footer::kMaxEncodedLength);
s = file->Read(opts, read_offset, Footer::kMaxEncodedLength,
&footer_input, &footer_buf[0], nullptr);
&footer_input, footer_buf.data(), nullptr);
}
if (!s.ok()) {
return s;
}
if (!s.ok()) return s;
}

// Check that we actually read the whole footer from the file. It may be
Expand Down
2 changes: 1 addition & 1 deletion table/merger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class MergerTest : public testing::Test {
}

merging_iterator_.reset(
NewMergingIterator(&icomp_, &small_iterators[0],
NewMergingIterator(&icomp_, small_iterators.data(),
static_cast<int>(small_iterators.size())));
single_iterator_.reset(new VectorIterator(all_keys_, all_keys_, &icomp_));
}
Expand Down
4 changes: 2 additions & 2 deletions table/mock_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MockTableReader : public TableReader {

std::shared_ptr<const TableProperties> GetTableProperties() const override;

~MockTableReader() {}
~MockTableReader() = default;

private:
const KVVector& table_;
Expand Down Expand Up @@ -134,7 +134,7 @@ class MockTableBuilder : public TableBuilder {
}

// REQUIRES: Either Finish() or Abandon() has been called.
~MockTableBuilder() {}
~MockTableBuilder() = default;

// Add key,value to the table being constructed.
// REQUIRES: key is after any previously added key according to comparator.
Expand Down
3 changes: 1 addition & 2 deletions table/plain/plain_table_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

#include "table/plain/plain_table_builder.h"

#include <assert.h>

#include <cassert>
#include <limits>
#include <map>
#include <string>
Expand Down
11 changes: 5 additions & 6 deletions table/plain/plain_table_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

#include "table/plain/plain_table_factory.h"

#include <stdint.h>

#include <cstdint>
#include <memory>

#include "db/dbformat.h"
Expand Down Expand Up @@ -157,7 +156,7 @@ static int RegisterBuiltinMemTableRepFactory(ObjectLibrary& library,
AsPattern(VectorRepFactory::kClassName(), VectorRepFactory::kNickName()),
[](const std::string& uri, std::unique_ptr<MemTableRepFactory>* guard,
std::string* /*errmsg*/) {
auto colon = uri.find(":");
auto colon = uri.find(':');
if (colon != std::string::npos) {
size_t count = ParseSizeT(uri.substr(colon + 1));
guard->reset(new VectorRepFactory(count));
Expand All @@ -170,7 +169,7 @@ static int RegisterBuiltinMemTableRepFactory(ObjectLibrary& library,
AsPattern(SkipListFactory::kClassName(), SkipListFactory::kNickName()),
[](const std::string& uri, std::unique_ptr<MemTableRepFactory>* guard,
std::string* /*errmsg*/) {
auto colon = uri.find(":");
auto colon = uri.find(':');
if (colon != std::string::npos) {
size_t lookahead = ParseSizeT(uri.substr(colon + 1));
guard->reset(new SkipListFactory(lookahead));
Expand All @@ -184,7 +183,7 @@ static int RegisterBuiltinMemTableRepFactory(ObjectLibrary& library,
[](const std::string& uri, std::unique_ptr<MemTableRepFactory>* guard,
std::string* /*errmsg*/) {
// Expecting format: hash_linkedlist:<hash_bucket_count>
auto colon = uri.find(":");
auto colon = uri.find(':');
if (colon != std::string::npos) {
size_t hash_bucket_count = ParseSizeT(uri.substr(colon + 1));
guard->reset(NewHashLinkListRepFactory(hash_bucket_count));
Expand All @@ -198,7 +197,7 @@ static int RegisterBuiltinMemTableRepFactory(ObjectLibrary& library,
[](const std::string& uri, std::unique_ptr<MemTableRepFactory>* guard,
std::string* /*errmsg*/) {
// Expecting format: prefix_hash:<hash_bucket_count>
auto colon = uri.find(":");
auto colon = uri.find(':');
if (colon != std::string::npos) {
size_t hash_bucket_count = ParseSizeT(uri.substr(colon + 1));
guard->reset(NewHashSkipListRepFactory(hash_bucket_count));
Expand Down
10 changes: 7 additions & 3 deletions table/plain/plain_table_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,9 @@ Status PlainTableReader::GetOffset(PlainTableKeyDecoder* decoder,
ParsedInternalKey parsed_target;
Status s = ParseInternalKey(target, &parsed_target,
false /* log_err_key */); // TODO
if (!s.ok()) return s;
if (!s.ok()) {
return s;
}

// The key is between [low, high). Do a binary search between it.
while (high - low > 1) {
Expand Down Expand Up @@ -591,7 +593,9 @@ Status PlainTableReader::Get(const ReadOptions& /*ro*/, const Slice& target,
ParsedInternalKey parsed_target;
s = ParseInternalKey(target, &parsed_target,
false /* log_err_key */); // TODO
if (!s.ok()) return s;
if (!s.ok()) {
return s;
}

Slice found_value;
while (offset < file_info_.data_end_offset) {
Expand Down Expand Up @@ -642,7 +646,7 @@ PlainTableIterator::PlainTableIterator(PlainTableReader* table,
next_offset_ = offset_ = table_->file_info_.data_end_offset;
}

PlainTableIterator::~PlainTableIterator() {}
PlainTableIterator::~PlainTableIterator() = default;

bool PlainTableIterator::Valid() const {
return offset_ < table_->file_info_.data_end_offset &&
Expand Down
4 changes: 3 additions & 1 deletion table/sst_file_dumper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ Status SstFileDumper::ReadSequential(bool print_kv, uint64_t read_num,
Slice key = iter->key();
Slice value = iter->value();
++i;
if (read_num > 0 && i > read_num) break;
if (read_num > 0 && i > read_num) {
break;
}

ParsedInternalKey ikey;
Status pik_status = ParseInternalKey(key, &ikey, true /* log_err_key */);
Expand Down
2 changes: 1 addition & 1 deletion table/sst_file_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct SstFileReader::Rep {

SstFileReader::SstFileReader(const Options& options) : rep_(new Rep(options)) {}

SstFileReader::~SstFileReader() {}
SstFileReader::~SstFileReader() = default;

Status SstFileReader::Open(const std::string& file_path) {
auto r = rep_.get();
Expand Down
Loading

0 comments on commit 4f82416

Please sign in to comment.