]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
Implement PinnableSlice::remove_prefix (#6330)
authorMaysam Yabandeh <myabandeh@fb.com>
Fri, 24 Jan 2020 21:03:19 +0000 (13:03 -0800)
committermyabandeh <myabandeh@fb.com>
Fri, 24 Jan 2020 21:30:13 +0000 (13:30 -0800)
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

include/rocksdb/cache.h
include/rocksdb/env.h
include/rocksdb/slice.h
include/rocksdb/statistics.h

index 27b4a6f64322a24f315c57984b9de6fd0e541d1a..dfdc374d0ad2314b85558d9dc348a82c2af79397 100644 (file)
@@ -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
index e70a49ffc43c2c7e3b5748db0ef4c9fcc6562a83..8c3d74ecc9f269f7683a09de44f7e2c373dbc568 100644 (file)
@@ -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 {
index 2b01e6d9a66ec748900c520e59f70cb3a2cd9eca..00412bf3cba022de67bf93f5b38362bba83b279b 100644 (file)
@@ -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() {
index b6b78ef99a3037947eee5c5bafd0a0f600a92940..d0fdf8acb61b9ecca6e1dacba5e448976887b1ea 100644 (file)
@@ -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 {