MCPcopy Create free account
hub / github.com/ceph/ceph / ParseOptionsFromStringStatic

Method ParseOptionsFromStringStatic

src/kv/RocksDBStore.cc:370–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370int RocksDBStore::ParseOptionsFromStringStatic(
371 CephContext *cct,
372 const string& opt_str,
373 rocksdb::Options& opt,
374 function<int(const string&, const string&, rocksdb::Options&)> interp)
375{
376 // keep aligned with func tryInterpret
377 const set<string> need_interp_keys = {"compaction_threads", "flusher_threads", "compact_on_mount", "disableWAL"};
378 rocksdb::Status status;
379 std::unordered_map<std::string, std::string> str_map;
380 status = StringToMap(opt_str, &str_map);
381 if (!status.ok()) {
382 dout(5) << __func__ << " error '" << status.getState() <<
383 "' while parsing options '" << opt_str << "'" << dendl;
384 return -EINVAL;
385 }
386
387 for (auto it = str_map.begin(); it != str_map.end(); ++it) {
388 string this_opt = it->first + "=" + it->second;
389 rocksdb::Status status =
390 rocksdb::GetOptionsFromString(opt, this_opt, &opt);
391 int r = 0;
392 if (!status.ok()) {
393 if (interp != nullptr) {
394 r = interp(it->first, it->second, opt);
395 } else if (!need_interp_keys.count(it->first)) {
396 r = -1;
397 }
398 if (r < 0) {
399 derr << status.ToString() << dendl;
400 return -EINVAL;
401 }
402 }
403 lgeneric_dout(cct, 1) << " set rocksdb option " << it->first
404 << " = " << it->second << dendl;
405 }
406 return 0;
407}
408
409int RocksDBStore::init(string _options_str)
410{

Callers

nothing calls this directly

Calls 5

StringToMapFunction · 0.85
okMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected