Revision 7c80a6d7d189d4414da7c2126e111ea71cf1504e authored by Andrew Kryczka on 03 March 2017, 01:40:24 UTC, committed by Facebook Github Bot on 03 March 2017, 01:54:15 UTC
Summary:
This is the metric I plan to use for adaptive rate limiting. The statistics are updated only if the rate limiter is drained by flush or compaction. I believe (but am not certain) that this is the normal case.

The Statistics object is passed in RateLimiter::Request() to avoid requiring changes to client code, which would've been necessary if we passed it in the RateLimiter constructor.
Closes https://github.com/facebook/rocksdb/pull/1946

Differential Revision: D4646489

Pulled By: ajkr

fbshipit-source-id: d8e0161
1 parent 0ad5af4
Raw File
2015-02-24-reading-rocksdb-options-from-a-file.markdown
---
title: Reading RocksDB options from a file
layout: post
author: lgalanis
category: blog
redirect_from:
  - /blog/1883/reading-rocksdb-options-from-a-file/
---

RocksDB options can be provided using a file or any string to RocksDB. The format is straightforward: `write_buffer_size=1024;max_write_buffer_number=2`. Any whitespace around `=` and `;` is OK. Moreover, options can be nested as necessary. For example `BlockBasedTableOptions` can be nested as follows: `write_buffer_size=1024; max_write_buffer_number=2; block_based_table_factory={block_size=4k};`. Similarly any white space around `{` or `}` is ok. Here is what it looks like in code:

<!--truncate-->

```c++
#include <string>
#include "rocksdb/db.h"
#include "rocksdb/table.h"
#include "rocksdb/utilities/convenience.h"

using namespace rocksdb;                                                                                           

int main(int argc, char** argv) {                                                                                  
  DB *db;

  Options opt;

  std::string options_string =                                                                                     
    "create_if_missing=true;max_open_files=1000;"                                                                  
    "block_based_table_factory={block_size=4096}";                                                                 

  Status s = GetDBOptionsFromString(opt, options_string, &opt);

  s = DB::Open(opt, "/tmp/mydb_rocks", &db);                                                                       

  // use db

  delete db;
}
```

Using `GetDBOptionsFromString` is a convenient way of changing options for your RocksDB application without needing to resort to recompilation or tedious command line parsing.
back to top