Skip to content

Commit

Permalink
remove unused code in OutputValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkr committed Jan 30, 2024
1 parent c67d61e commit fbb27b5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 30 deletions.
2 changes: 0 additions & 2 deletions db/builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Status BuildTable(
// Reports the IOStats for flush for every following bytes.
const size_t kReportFlushIOStatsEvery = 1048576;
OutputValidator output_validator(tboptions.internal_comparator,
/*enable_order_check=*/true,
/*enable_hash=*/paranoid_file_checks);
Status s;
meta->fd.file_size = 0;
Expand Down Expand Up @@ -423,7 +422,6 @@ Status BuildTable(
s = it->status();
if (s.ok() && paranoid_file_checks) {
OutputValidator file_validator(tboptions.internal_comparator,
/*enable_order_check=*/true,
/*enable_hash=*/true);
for (it->SeekToFirst(); it->Valid(); it->Next()) {
// Generate a rolling 64-bit hash of the key and values
Expand Down
3 changes: 1 addition & 2 deletions db/compaction/compaction_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@ Status CompactionJob::Run() {

if (s.ok() && paranoid_file_checks_) {
OutputValidator validator(cfd->internal_comparator(),
/*_enable_order_check=*/true,
/*_enable_hash=*/true);
for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
s = validator.Add(iter->key(), iter->value());
Expand Down Expand Up @@ -1948,7 +1947,7 @@ Status CompactionJob::OpenCompactionOutputFile(SubcompactionState* sub_compact,
}

outputs.AddOutput(std::move(meta), cfd->internal_comparator(),
true /* enable_order_check */, paranoid_file_checks_);
paranoid_file_checks_);
}

writable_file->SetIOPriority(GetRateLimiterPriority());
Expand Down
14 changes: 6 additions & 8 deletions db/compaction/compaction_outputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ class CompactionOutputs {
// compaction output file
struct Output {
Output(FileMetaData&& _meta, const InternalKeyComparator& _icmp,
bool _enable_order_check, bool _enable_hash, bool _finished,
uint64_t precalculated_hash)
bool _enable_hash, bool _finished, uint64_t precalculated_hash)
: meta(std::move(_meta)),
validator(_icmp, _enable_order_check, _enable_hash,
precalculated_hash),
validator(_icmp, _enable_hash, precalculated_hash),
finished(_finished) {}
FileMetaData meta;
OutputValidator validator;
Expand All @@ -49,10 +47,10 @@ class CompactionOutputs {

// Add generated output to the list
void AddOutput(FileMetaData&& meta, const InternalKeyComparator& icmp,
bool enable_order_check, bool enable_hash,
bool finished = false, uint64_t precalculated_hash = 0) {
outputs_.emplace_back(std::move(meta), icmp, enable_order_check,
enable_hash, finished, precalculated_hash);
bool enable_hash, bool finished = false,
uint64_t precalculated_hash = 0) {
outputs_.emplace_back(std::move(meta), icmp, enable_hash, finished,
precalculated_hash);
}

// Set new table builder for the current output
Expand Down
4 changes: 2 additions & 2 deletions db/compaction/compaction_service_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ CompactionJob::ProcessKeyValueCompactionWithCompactionService(

auto cfd = compaction->column_family_data();
sub_compact->Current().AddOutput(std::move(meta),
cfd->internal_comparator(), false, false,
true, file.paranoid_hash);
cfd->internal_comparator(), false, true,
file.paranoid_hash);
}
sub_compact->compaction_job_stats = compaction_result.stats;
sub_compact->Current().SetNumOutputRecords(
Expand Down
20 changes: 8 additions & 12 deletions db/output_validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@ Status OutputValidator::Add(const Slice& key, const Slice& value) {
paranoid_hash_ = NPHash64(key.data(), key.size(), paranoid_hash_);
paranoid_hash_ = NPHash64(value.data(), value.size(), paranoid_hash_);
}
if (enable_order_check_) {
TEST_SYNC_POINT_CALLBACK("OutputValidator::Add:order_check",
/*arg=*/nullptr);
if (key.size() < kNumInternalBytes) {
return Status::Corruption(
"Compaction tries to write a key without internal bytes.");
}
// prev_key_ starts with empty.
if (!prev_key_.empty() && icmp_.Compare(key, prev_key_) < 0) {
return Status::Corruption("Compaction sees out-of-order keys.");
}
prev_key_.assign(key.data(), key.size());
if (key.size() < kNumInternalBytes) {
return Status::Corruption(
"Compaction tries to write a key without internal bytes.");
}
// prev_key_ starts with empty.
if (!prev_key_.empty() && icmp_.Compare(key, prev_key_) < 0) {
return Status::Corruption("Compaction sees out-of-order keys.");
}
prev_key_.assign(key.data(), key.size());
return Status::OK();
}
} // namespace ROCKSDB_NAMESPACE
5 changes: 1 addition & 4 deletions db/output_validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ namespace ROCKSDB_NAMESPACE {
// of all the key and value.
class OutputValidator {
public:
explicit OutputValidator(const InternalKeyComparator& icmp,
bool enable_order_check, bool enable_hash,
explicit OutputValidator(const InternalKeyComparator& icmp, bool enable_hash,
uint64_t precalculated_hash = 0)
: icmp_(icmp),
paranoid_hash_(precalculated_hash),
enable_order_check_(enable_order_check),
enable_hash_(enable_hash) {}

// Add a key to the KV sequence, and return whether the key follows
Expand All @@ -42,7 +40,6 @@ class OutputValidator {
const InternalKeyComparator& icmp_;
std::string prev_key_;
uint64_t paranoid_hash_ = 0;
bool enable_order_check_;
bool enable_hash_;
};
} // namespace ROCKSDB_NAMESPACE

0 comments on commit fbb27b5

Please sign in to comment.