Implement PinnableSlice::remove_prefix (#6330)

Summary:
The function was left unimplemented. Although we currently don't have a use for that it was declared with an assert(0) to prevent mistakenly using the remove_prefix of the parent class. The function body  with only assert(0) however causes issues with some compiler's warning levels. The patch implements the function to avoid the warning.
It also piggybacks some minor code warning for unnecessary semicolons after the function definition.s
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6330

Differential Revision: D19559062

Pulled By: maysamyabandeh

fbshipit-source-id: 3a022484f688c9abd4556e5412bcc2628ab96a00
main
Maysam Yabandeh 5 years ago committed by Facebook Github Bot
parent f34782a67d
commit c4bc30e12d
  1. 2
      include/rocksdb/cache.h
  2. 4
      include/rocksdb/env.h
  3. 11
      include/rocksdb/slice.h
  4. 2
      include/rocksdb/statistics.h

@ -255,7 +255,7 @@ class Cache {
// Always delete the DB object before calling this method!
virtual void DisownData(){
// default implementation is noop
};
}
// Apply callback to all entries in the cache
// If thread_safe is true, it will also lock the accesses. Otherwise, it will

@ -672,7 +672,7 @@ class RandomAccessFile {
virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const {
return 0; // Default implementation to prevent issues with backwards
// compatibility.
};
}
enum AccessPattern { NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED };
@ -1414,7 +1414,7 @@ class RandomAccessFileWrapper : public RandomAccessFile {
}
size_t GetUniqueId(char* id, size_t max_size) const override {
return target_->GetUniqueId(id, max_size);
};
}
void Hint(AccessPattern pattern) override { target_->Hint(pattern); }
bool use_direct_io() const override { return target_->use_direct_io(); }
size_t GetRequiredBufferAlignment() const override {

@ -195,8 +195,15 @@ class PinnableSlice : public Slice, public Cleanable {
}
}
void remove_prefix(size_t /*n*/) {
assert(0); // Not implemented
void remove_prefix(size_t n) {
assert(n <= size());
if (pinned_) {
data_ += n;
size_ -= n;
} else {
buf_->erase(0, n);
PinSelf();
}
}
void Reset() {

@ -523,7 +523,7 @@ class Statistics {
virtual bool getTickerMap(std::map<std::string, uint64_t>*) const {
// Do nothing by default
return false;
};
}
// Override this function to disable particular histogram collection
virtual bool HistEnabledForType(uint32_t type) const {

Loading…
Cancel
Save