#12390·rocksdb

Doc bug: CustomFilterPolicy example

Author: alexbudfbCreated Feb 27, 2024Updated Sep 10, 2026
Labelsdocumentation

The doc section https://github.com/facebook/rocksdb/wiki/Basic-Operations#filters example has a typo:

    void CreateFilter(const Slice* keys, int n, std::string* dst) const {
      // Use builtin bloom filter code after removing trailing spaces
      std::vector<Slice> trimmed(n);
      for (int i = 0; i < n; i++) {
        trimmed[i] = RemoveTrailingSpaces(keys[i]);
      }
      return builtin_policy_->CreateFilter(&trimmed[i], n, dst);  // <-- should be [0], not [i]
    }

For one thing, i is out of scope on that line, for another, CreateFilter wants the base of the vector, not some element in the middle.