Summary: This work on my compiler, but it turns out some compilers don't implicitly add constness, see: https://github.com/facebook/rocksdb/issues/284. This diff adds constness explicitly.

Test Plan: still compiles

Reviewers: sdong

Reviewed By: sdong

Subscribers: leveldb

Differential Revision: https://reviews.facebook.net/D23409
main
Igor Canadi 10 years ago
parent 49aacd8d2b
commit faad439ac4
  1. 4
      table/full_filter_block.cc
  2. 4
      table/full_filter_block.h
  3. 6
      util/bloom.cc

@ -47,7 +47,7 @@ inline void FullFilterBlockBuilder::AddPrefix(const Slice& key) {
Slice FullFilterBlockBuilder::Finish() {
if (num_added_ != 0) {
num_added_ = 0;
return filter_bits_builder_->Finish(&filter_data);
return filter_bits_builder_->Finish(&filter_data_);
}
return Slice();
}
@ -64,7 +64,7 @@ FullFilterBlockReader::FullFilterBlockReader(
filter_bits_reader_.reset(filter_bits_reader);
if (delete_contents_after_use) {
filter_data.reset(contents.data());
filter_data_.reset(contents.data());
}
}

@ -56,7 +56,7 @@ class FullFilterBlockBuilder : public FilterBlockBuilder {
uint32_t num_added_;
std::unique_ptr<FilterBitsBuilder> filter_bits_builder_;
std::unique_ptr<const char[]> filter_data;
std::unique_ptr<const char[]> filter_data_;
void AddKey(const Slice& key);
void AddPrefix(const Slice& key);
@ -95,7 +95,7 @@ class FullFilterBlockReader : public FilterBlockReader {
std::unique_ptr<FilterBitsReader> filter_bits_reader_;
Slice contents_;
std::unique_ptr<const char[]> filter_data;
std::unique_ptr<const char[]> filter_data_;
bool MayMatch(const Slice& entry);

@ -54,9 +54,8 @@ class FullFilterBitsBuilder : public FilterBitsBuilder {
// | ... | num_probes : 1 byte | num_lines : 4 bytes |
// +----------------------------------------------------------------+
virtual Slice Finish(std::unique_ptr<const char[]>* buf) override {
char* data = nullptr;
uint32_t total_bits, num_lines;
data = ReserveSpace(hash_entries_.size(), &total_bits, &num_lines);
char* data = ReserveSpace(hash_entries_.size(), &total_bits, &num_lines);
assert(data);
if (total_bits != 0 && num_lines != 0) {
@ -67,7 +66,8 @@ class FullFilterBitsBuilder : public FilterBitsBuilder {
data[total_bits/8] = static_cast<char>(num_probes_);
EncodeFixed32(data + total_bits/8 + 1, static_cast<uint32_t>(num_lines));
buf->reset(data);
const char* const_data = data;
buf->reset(const_data);
hash_entries_.clear();
return Slice(data, total_bits / 8 + 5);

Loading…
Cancel
Save