Skip to content

Commit

Permalink
Remove misc debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
udi-speedb committed Oct 18, 2022
1 parent 9295303 commit 4cf14cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion plugin/speedb/paired_filter/speedb_paired_bloom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ FilterBitsReader* SpdbPairedBloomFilterPolicy::GetFilterBitsReader(
uint32_t len_with_meta = static_cast<uint32_t>(contents.size());
const auto trailer_len = speedb_filter::FilterMetadata::kMetadataLen;
if (len_with_meta <= trailer_len) {
assert(0);
// filter is empty or broken. Treat like zero keys added.
return new AlwaysFalseFilter();
}
Expand Down
9 changes: 3 additions & 6 deletions plugin/speedb/paired_filter/speedb_paired_bloom_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,6 @@ Slice SpdbPairedBloomBitsBuilder::Finish(std::unique_ptr<const char[]>* buf,
const size_t num_entries = hash_entries_info_.entries.size();
size_t len_with_metadata = CalculateSpace(num_entries);

// // printf("len_with_metadata #1:%d\n", (int)len_with_metadata);

std::unique_ptr<char[]> mutable_buf;
std::unique_ptr<CacheReservationManager::CacheReservationHandle>
final_filter_cache_res_handle;
Expand All @@ -465,8 +463,6 @@ Slice SpdbPairedBloomBitsBuilder::Finish(std::unique_ptr<const char[]>* buf,
// Max size supported by implementation
assert(len_with_metadata <= kMaxSupportLenWithMetadata);

// // printf("len_with_metadata #2:%d\n", (int)len_with_metadata);

// Cache reservation for mutable_buf
if (cache_res_mgr_) {
Status s = cache_res_mgr_->MakeCacheReservation(
Expand Down Expand Up @@ -509,7 +505,7 @@ Slice SpdbPairedBloomBitsBuilder::Finish(std::unique_ptr<const char[]>* buf,
std::make_pair(&mutable_buf, len_with_metadata);
TEST_SYNC_POINT_CALLBACK("XXPH3FilterBitsBuilder::Finish::TamperFilter",
&TEST_arg_pair);

Slice rv(mutable_buf.get(), len_with_metadata);
*buf = std::move(mutable_buf);
final_filter_cache_res_handles_.push_back(
Expand Down Expand Up @@ -562,7 +558,8 @@ size_t SpdbPairedBloomBitsBuilder::RoundDownUsableSpace(size_t available_size) {
}

// round down to multiple of a Batch
rv = std::max<size_t>((rv / kBatchSizeInBytes) * kBatchSizeInBytes, kBatchSizeInBytes);
rv = std::max<size_t>((rv / kBatchSizeInBytes) * kBatchSizeInBytes,
kBatchSizeInBytes);

return rv + speedb_filter::FilterMetadata::kMetadataLen;
}
Expand Down
13 changes: 2 additions & 11 deletions table/block_based/filter_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1208,27 +1208,18 @@ Status XXPH3FilterBitsBuilder::MaybePostVerify(const Slice& filter_content) {

std::unique_ptr<FilterBitsReader> bits_reader(GetBitsReader(filter_content));

int num_mismtches = 0;
int first_mismatch_idx = -1;
// for (uint64_t h : hash_entries_info_.entries) {
for (auto i = 0U; i < hash_entries_info_.entries.size(); ++i) {
auto h = hash_entries_info_.entries[i];
for (uint64_t h : hash_entries_info_.entries) {
// The current approach will not detect corruption from XXPH3Filter to
// AlwaysTrueFilter, which can lead to performance cost later due to
// AlwaysTrueFilter not filtering anything. But this cost is acceptable
// given the extra implementation complixity to detect such case.
bool may_match = bits_reader->HashMayMatch(h);
if (!may_match) {
++num_mismtches;
if (first_mismatch_idx == -1) first_mismatch_idx = i;
s = Status::Corruption("Corrupted filter content");
// // break;
break;
}
}

if (num_mismtches > 0) {
fprintf(stderr, "FILTER CORRUPTION, num_mismtches:%d, num_entries:%d, first_mismatch:%d\n", num_mismtches, (int)hash_entries_info_.entries.size(), first_mismatch_idx);
}
ResetEntries();
return s;
}
Expand Down

0 comments on commit 4cf14cb

Please sign in to comment.