options_helper.cc 42.8 KB
Newer Older
1
//  Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
S
Siying Dong 已提交
2 3 4
//  This source code is licensed under both the GPLv2 (found in the
//  COPYING file in the root directory) and Apache 2.0 License
//  (found in the LICENSE.Apache file in the root directory).
5
#include "options/options_helper.h"
6 7

#include <cassert>
L
Lei Jin 已提交
8
#include <cctype>
S
sdong 已提交
9
#include <cstdlib>
10
#include <unordered_set>
11
#include <vector>
12
#include "rocksdb/cache.h"
13
#include "rocksdb/compaction_filter.h"
A
agiardullo 已提交
14
#include "rocksdb/convenience.h"
15
#include "rocksdb/filter_policy.h"
16 17
#include "rocksdb/memtablerep.h"
#include "rocksdb/merge_operator.h"
18
#include "rocksdb/options.h"
I
Igor Canadi 已提交
19
#include "rocksdb/rate_limiter.h"
20
#include "rocksdb/slice_transform.h"
21
#include "rocksdb/table.h"
22
#include "table/block_based_table_factory.h"
23
#include "table/plain_table_factory.h"
S
Siying Dong 已提交
24
#include "util/cast_util.h"
25
#include "util/string_util.h"
26 27 28

namespace rocksdb {

29 30 31 32 33 34 35 36 37 38 39 40 41 42
DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
                         const MutableDBOptions& mutable_db_options) {
  DBOptions options;

  options.create_if_missing = immutable_db_options.create_if_missing;
  options.create_missing_column_families =
      immutable_db_options.create_missing_column_families;
  options.error_if_exists = immutable_db_options.error_if_exists;
  options.paranoid_checks = immutable_db_options.paranoid_checks;
  options.env = immutable_db_options.env;
  options.rate_limiter = immutable_db_options.rate_limiter;
  options.sst_file_manager = immutable_db_options.sst_file_manager;
  options.info_log = immutable_db_options.info_log;
  options.info_log_level = immutable_db_options.info_log_level;
L
Leonidas Galanis 已提交
43
  options.max_open_files = mutable_db_options.max_open_files;
44 45
  options.max_file_opening_threads =
      immutable_db_options.max_file_opening_threads;
46
  options.max_total_wal_size = mutable_db_options.max_total_wal_size;
47 48 49 50 51 52
  options.statistics = immutable_db_options.statistics;
  options.use_fsync = immutable_db_options.use_fsync;
  options.db_paths = immutable_db_options.db_paths;
  options.db_log_dir = immutable_db_options.db_log_dir;
  options.wal_dir = immutable_db_options.wal_dir;
  options.delete_obsolete_files_period_micros =
53
      mutable_db_options.delete_obsolete_files_period_micros;
54
  options.max_background_jobs = mutable_db_options.max_background_jobs;
55
  options.base_background_compactions =
56
      mutable_db_options.base_background_compactions;
57
  options.max_background_compactions =
58
      mutable_db_options.max_background_compactions;
59 60
  options.bytes_per_sync = mutable_db_options.bytes_per_sync;
  options.wal_bytes_per_sync = mutable_db_options.wal_bytes_per_sync;
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
  options.max_subcompactions = immutable_db_options.max_subcompactions;
  options.max_background_flushes = immutable_db_options.max_background_flushes;
  options.max_log_file_size = immutable_db_options.max_log_file_size;
  options.log_file_time_to_roll = immutable_db_options.log_file_time_to_roll;
  options.keep_log_file_num = immutable_db_options.keep_log_file_num;
  options.recycle_log_file_num = immutable_db_options.recycle_log_file_num;
  options.max_manifest_file_size = immutable_db_options.max_manifest_file_size;
  options.table_cache_numshardbits =
      immutable_db_options.table_cache_numshardbits;
  options.WAL_ttl_seconds = immutable_db_options.wal_ttl_seconds;
  options.WAL_size_limit_MB = immutable_db_options.wal_size_limit_mb;
  options.manifest_preallocation_size =
      immutable_db_options.manifest_preallocation_size;
  options.allow_mmap_reads = immutable_db_options.allow_mmap_reads;
  options.allow_mmap_writes = immutable_db_options.allow_mmap_writes;
76
  options.use_direct_reads = immutable_db_options.use_direct_reads;
77 78
  options.use_direct_io_for_flush_and_compaction =
      immutable_db_options.use_direct_io_for_flush_and_compaction;
79 80
  options.allow_fallocate = immutable_db_options.allow_fallocate;
  options.is_fd_close_on_exec = immutable_db_options.is_fd_close_on_exec;
81
  options.stats_dump_period_sec = mutable_db_options.stats_dump_period_sec;
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
  options.advise_random_on_open = immutable_db_options.advise_random_on_open;
  options.db_write_buffer_size = immutable_db_options.db_write_buffer_size;
  options.write_buffer_manager = immutable_db_options.write_buffer_manager;
  options.access_hint_on_compaction_start =
      immutable_db_options.access_hint_on_compaction_start;
  options.new_table_reader_for_compaction_inputs =
      immutable_db_options.new_table_reader_for_compaction_inputs;
  options.compaction_readahead_size =
      immutable_db_options.compaction_readahead_size;
  options.random_access_max_buffer_size =
      immutable_db_options.random_access_max_buffer_size;
  options.writable_file_max_buffer_size =
      immutable_db_options.writable_file_max_buffer_size;
  options.use_adaptive_mutex = immutable_db_options.use_adaptive_mutex;
  options.listeners = immutable_db_options.listeners;
  options.enable_thread_tracking = immutable_db_options.enable_thread_tracking;
98
  options.delayed_write_rate = mutable_db_options.delayed_write_rate;
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
  options.allow_concurrent_memtable_write =
      immutable_db_options.allow_concurrent_memtable_write;
  options.enable_write_thread_adaptive_yield =
      immutable_db_options.enable_write_thread_adaptive_yield;
  options.write_thread_max_yield_usec =
      immutable_db_options.write_thread_max_yield_usec;
  options.write_thread_slow_yield_usec =
      immutable_db_options.write_thread_slow_yield_usec;
  options.skip_stats_update_on_db_open =
      immutable_db_options.skip_stats_update_on_db_open;
  options.wal_recovery_mode = immutable_db_options.wal_recovery_mode;
  options.allow_2pc = immutable_db_options.allow_2pc;
  options.row_cache = immutable_db_options.row_cache;
#ifndef ROCKSDB_LITE
  options.wal_filter = immutable_db_options.wal_filter;
#endif  // ROCKSDB_LITE
  options.fail_if_options_file_error =
      immutable_db_options.fail_if_options_file_error;
  options.dump_malloc_stats = immutable_db_options.dump_malloc_stats;
  options.avoid_flush_during_recovery =
      immutable_db_options.avoid_flush_during_recovery;
Y
Yi Wu 已提交
120 121
  options.avoid_flush_during_shutdown =
      mutable_db_options.avoid_flush_during_shutdown;
122 123
  options.allow_ingest_behind =
      immutable_db_options.allow_ingest_behind;
124 125 126 127

  return options;
}

128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
ColumnFamilyOptions BuildColumnFamilyOptions(
    const ColumnFamilyOptions& options,
    const MutableCFOptions& mutable_cf_options) {
  ColumnFamilyOptions cf_opts(options);

  // Memtable related options
  cf_opts.write_buffer_size = mutable_cf_options.write_buffer_size;
  cf_opts.max_write_buffer_number = mutable_cf_options.max_write_buffer_number;
  cf_opts.arena_block_size = mutable_cf_options.arena_block_size;
  cf_opts.memtable_prefix_bloom_size_ratio =
      mutable_cf_options.memtable_prefix_bloom_size_ratio;
  cf_opts.memtable_huge_page_size = mutable_cf_options.memtable_huge_page_size;
  cf_opts.max_successive_merges = mutable_cf_options.max_successive_merges;
  cf_opts.inplace_update_num_locks =
      mutable_cf_options.inplace_update_num_locks;

  // Compaction related options
  cf_opts.disable_auto_compactions =
      mutable_cf_options.disable_auto_compactions;
  cf_opts.level0_file_num_compaction_trigger =
      mutable_cf_options.level0_file_num_compaction_trigger;
  cf_opts.level0_slowdown_writes_trigger =
      mutable_cf_options.level0_slowdown_writes_trigger;
  cf_opts.level0_stop_writes_trigger =
      mutable_cf_options.level0_stop_writes_trigger;
  cf_opts.max_compaction_bytes = mutable_cf_options.max_compaction_bytes;
  cf_opts.target_file_size_base = mutable_cf_options.target_file_size_base;
  cf_opts.target_file_size_multiplier =
      mutable_cf_options.target_file_size_multiplier;
  cf_opts.max_bytes_for_level_base =
      mutable_cf_options.max_bytes_for_level_base;
  cf_opts.max_bytes_for_level_multiplier =
      mutable_cf_options.max_bytes_for_level_multiplier;

  cf_opts.max_bytes_for_level_multiplier_additional.clear();
  for (auto value :
       mutable_cf_options.max_bytes_for_level_multiplier_additional) {
    cf_opts.max_bytes_for_level_multiplier_additional.emplace_back(value);
  }

  // Misc options
  cf_opts.max_sequential_skip_in_iterations =
      mutable_cf_options.max_sequential_skip_in_iterations;
  cf_opts.paranoid_file_checks = mutable_cf_options.paranoid_file_checks;
  cf_opts.report_bg_io_stats = mutable_cf_options.report_bg_io_stats;
  cf_opts.compression = mutable_cf_options.compression;

  cf_opts.table_factory = options.table_factory;
  // TODO(yhchiang): find some way to handle the following derived options
  // * max_file_size

  return cf_opts;
}

182
#ifndef ROCKSDB_LITE
183

D
Dmitri Smirnov 已提交
184
namespace {
185 186
template <typename T>
bool ParseEnum(const std::unordered_map<std::string, T>& type_map,
S
SherlockNoMad 已提交
187 188 189 190 191 192 193 194 195
               const std::string& type, T* value) {
  auto iter = type_map.find(type);
  if (iter != type_map.end()) {
    *value = iter->second;
    return true;
  }
  return false;
}

196 197
template <typename T>
bool SerializeEnum(const std::unordered_map<std::string, T>& type_map,
S
SherlockNoMad 已提交
198 199 200 201
                   const T& type, std::string* value) {
  for (const auto& pair : type_map) {
    if (pair.second == type) {
      *value = pair.first;
202
      return true;
S
SherlockNoMad 已提交
203
    }
204
  }
S
SherlockNoMad 已提交
205
  return false;
206 207 208 209 210 211 212 213 214 215 216
}

bool SerializeVectorCompressionType(const std::vector<CompressionType>& types,
                                    std::string* value) {
  std::stringstream ss;
  bool result;
  for (size_t i = 0; i < types.size(); ++i) {
    if (i > 0) {
      ss << ':';
    }
    std::string string_type;
S
SherlockNoMad 已提交
217
    result = SerializeEnum<CompressionType>(compression_type_string_map,
218
                                            types[i], &string_type);
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
    if (result == false) {
      return result;
    }
    ss << string_type;
  }
  *value = ss.str();
  return true;
}

bool ParseVectorCompressionType(
    const std::string& value,
    std::vector<CompressionType>* compression_per_level) {
  compression_per_level->clear();
  size_t start = 0;
  while (start < value.size()) {
    size_t end = value.find(':', start);
    bool is_ok;
    CompressionType type;
    if (end == std::string::npos) {
238 239
      is_ok = ParseEnum<CompressionType>(compression_type_string_map,
                                         value.substr(start), &type);
240 241 242 243 244 245
      if (!is_ok) {
        return false;
      }
      compression_per_level->emplace_back(type);
      break;
    } else {
246 247
      is_ok = ParseEnum<CompressionType>(
          compression_type_string_map, value.substr(start, end - start), &type);
248 249 250 251 252 253 254 255 256 257 258 259 260 261
      if (!is_ok) {
        return false;
      }
      compression_per_level->emplace_back(type);
      start = end + 1;
    }
  }
  return true;
}

bool ParseSliceTransformHelper(
    const std::string& kFixedPrefixName, const std::string& kCappedPrefixName,
    const std::string& value,
    std::shared_ptr<const SliceTransform>* slice_transform) {
262

263 264 265 266 267 268 269 270 271 272 273
  auto& pe_value = value;
  if (pe_value.size() > kFixedPrefixName.size() &&
      pe_value.compare(0, kFixedPrefixName.size(), kFixedPrefixName) == 0) {
    int prefix_length = ParseInt(trim(value.substr(kFixedPrefixName.size())));
    slice_transform->reset(NewFixedPrefixTransform(prefix_length));
  } else if (pe_value.size() > kCappedPrefixName.size() &&
             pe_value.compare(0, kCappedPrefixName.size(), kCappedPrefixName) ==
                 0) {
    int prefix_length =
        ParseInt(trim(pe_value.substr(kCappedPrefixName.size())));
    slice_transform->reset(NewCappedPrefixTransform(prefix_length));
274
  } else if (value == kNullptrString) {
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
    slice_transform->reset();
  } else {
    return false;
  }

  return true;
}

bool ParseSliceTransform(
    const std::string& value,
    std::shared_ptr<const SliceTransform>* slice_transform) {
  // While we normally don't convert the string representation of a
  // pointer-typed option into its instance, here we do so for backward
  // compatibility as we allow this action in SetOption().

  // TODO(yhchiang): A possible better place for these serialization /
  // deserialization is inside the class definition of pointer-typed
  // option itself, but this requires a bigger change of public API.
  bool result =
      ParseSliceTransformHelper("fixed:", "capped:", value, slice_transform);
  if (result) {
    return result;
  }
  result = ParseSliceTransformHelper(
      "rocksdb.FixedPrefix.", "rocksdb.CappedPrefix.", value, slice_transform);
  if (result) {
    return result;
  }
  // TODO(yhchiang): we can further support other default
  //                 SliceTransforms here.
  return false;
}
S
Siying Dong 已提交
307
}  // anonymouse namespace
308

309 310 311 312 313 314 315 316 317
bool ParseOptionHelper(char* opt_address, const OptionType& opt_type,
                       const std::string& value) {
  switch (opt_type) {
    case OptionType::kBoolean:
      *reinterpret_cast<bool*>(opt_address) = ParseBoolean("", value);
      break;
    case OptionType::kInt:
      *reinterpret_cast<int*>(opt_address) = ParseInt(value);
      break;
Y
Yi Wu 已提交
318 319 320
    case OptionType::kVectorInt:
      *reinterpret_cast<std::vector<int>*>(opt_address) = ParseVectorInt(value);
      break;
321 322 323 324 325 326 327
    case OptionType::kUInt:
      *reinterpret_cast<unsigned int*>(opt_address) = ParseUint32(value);
      break;
    case OptionType::kUInt32T:
      *reinterpret_cast<uint32_t*>(opt_address) = ParseUint32(value);
      break;
    case OptionType::kUInt64T:
T
Tomas Kolda 已提交
328
      PutUnaligned(reinterpret_cast<uint64_t*>(opt_address), ParseUint64(value));
329 330
      break;
    case OptionType::kSizeT:
T
Tomas Kolda 已提交
331
      PutUnaligned(reinterpret_cast<size_t*>(opt_address), ParseSizeT(value));
332 333 334 335 336 337 338 339
      break;
    case OptionType::kString:
      *reinterpret_cast<std::string*>(opt_address) = value;
      break;
    case OptionType::kDouble:
      *reinterpret_cast<double*>(opt_address) = ParseDouble(value);
      break;
    case OptionType::kCompactionStyle:
340 341 342
      return ParseEnum<CompactionStyle>(
          compaction_style_string_map, value,
          reinterpret_cast<CompactionStyle*>(opt_address));
343 344 345 346
    case OptionType::kCompactionPri:
      return ParseEnum<CompactionPri>(
          compaction_pri_string_map, value,
          reinterpret_cast<CompactionPri*>(opt_address));
347
    case OptionType::kCompressionType:
348 349 350
      return ParseEnum<CompressionType>(
          compression_type_string_map, value,
          reinterpret_cast<CompressionType*>(opt_address));
351 352 353 354 355 356 357
    case OptionType::kVectorCompressionType:
      return ParseVectorCompressionType(
          value, reinterpret_cast<std::vector<CompressionType>*>(opt_address));
    case OptionType::kSliceTransform:
      return ParseSliceTransform(
          value, reinterpret_cast<std::shared_ptr<const SliceTransform>*>(
                     opt_address));
358
    case OptionType::kChecksumType:
359 360 361
      return ParseEnum<ChecksumType>(
          checksum_type_string_map, value,
          reinterpret_cast<ChecksumType*>(opt_address));
362
    case OptionType::kBlockBasedTableIndexType:
S
SherlockNoMad 已提交
363
      return ParseEnum<BlockBasedTableOptions::IndexType>(
364 365
          block_base_table_index_type_string_map, value,
          reinterpret_cast<BlockBasedTableOptions::IndexType*>(opt_address));
366
    case OptionType::kEncodingType:
367 368 369
      return ParseEnum<EncodingType>(
          encoding_type_string_map, value,
          reinterpret_cast<EncodingType*>(opt_address));
370 371 372 373 374 375 376 377 378 379 380 381
    case OptionType::kWALRecoveryMode:
      return ParseEnum<WALRecoveryMode>(
          wal_recovery_mode_string_map, value,
          reinterpret_cast<WALRecoveryMode*>(opt_address));
    case OptionType::kAccessHint:
      return ParseEnum<DBOptions::AccessHint>(
          access_hint_string_map, value,
          reinterpret_cast<DBOptions::AccessHint*>(opt_address));
    case OptionType::kInfoLogLevel:
      return ParseEnum<InfoLogLevel>(
          info_log_level_string_map, value,
          reinterpret_cast<InfoLogLevel*>(opt_address));
382 383 384 385 386 387 388 389 390
    default:
      return false;
  }
  return true;
}

bool SerializeSingleOptionHelper(const char* opt_address,
                                 const OptionType opt_type,
                                 std::string* value) {
391

392 393 394 395 396 397 398 399
  assert(value);
  switch (opt_type) {
    case OptionType::kBoolean:
      *value = *(reinterpret_cast<const bool*>(opt_address)) ? "true" : "false";
      break;
    case OptionType::kInt:
      *value = ToString(*(reinterpret_cast<const int*>(opt_address)));
      break;
Y
Yi Wu 已提交
400 401 402
    case OptionType::kVectorInt:
      return SerializeIntVector(
          *reinterpret_cast<const std::vector<int>*>(opt_address), value);
403 404 405 406 407 408 409
    case OptionType::kUInt:
      *value = ToString(*(reinterpret_cast<const unsigned int*>(opt_address)));
      break;
    case OptionType::kUInt32T:
      *value = ToString(*(reinterpret_cast<const uint32_t*>(opt_address)));
      break;
    case OptionType::kUInt64T:
T
Tomas Kolda 已提交
410 411 412 413 414
      {
        uint64_t v;
        GetUnaligned(reinterpret_cast<const uint64_t*>(opt_address), &v);
        *value = ToString(v);
      }
415 416
      break;
    case OptionType::kSizeT:
T
Tomas Kolda 已提交
417 418 419 420 421
      {
        size_t v;
        GetUnaligned(reinterpret_cast<const size_t*>(opt_address), &v);
        *value = ToString(v);
      }
422 423 424 425 426
      break;
    case OptionType::kDouble:
      *value = ToString(*(reinterpret_cast<const double*>(opt_address)));
      break;
    case OptionType::kString:
427 428
      *value = EscapeOptionString(
          *(reinterpret_cast<const std::string*>(opt_address)));
429 430
      break;
    case OptionType::kCompactionStyle:
431 432
      return SerializeEnum<CompactionStyle>(
          compaction_style_string_map,
S
SherlockNoMad 已提交
433
          *(reinterpret_cast<const CompactionStyle*>(opt_address)), value);
434 435 436 437
    case OptionType::kCompactionPri:
      return SerializeEnum<CompactionPri>(
          compaction_pri_string_map,
          *(reinterpret_cast<const CompactionPri*>(opt_address)), value);
438
    case OptionType::kCompressionType:
439 440
      return SerializeEnum<CompressionType>(
          compression_type_string_map,
441 442 443 444 445 446 447 448 449 450 451
          *(reinterpret_cast<const CompressionType*>(opt_address)), value);
    case OptionType::kVectorCompressionType:
      return SerializeVectorCompressionType(
          *(reinterpret_cast<const std::vector<CompressionType>*>(opt_address)),
          value);
      break;
    case OptionType::kSliceTransform: {
      const auto* slice_transform_ptr =
          reinterpret_cast<const std::shared_ptr<const SliceTransform>*>(
              opt_address);
      *value = slice_transform_ptr->get() ? slice_transform_ptr->get()->Name()
452
                                          : kNullptrString;
453 454 455 456 457 458 459
      break;
    }
    case OptionType::kTableFactory: {
      const auto* table_factory_ptr =
          reinterpret_cast<const std::shared_ptr<const TableFactory>*>(
              opt_address);
      *value = table_factory_ptr->get() ? table_factory_ptr->get()->Name()
460
                                        : kNullptrString;
461 462 463 464 465
      break;
    }
    case OptionType::kComparator: {
      // it's a const pointer of const Comparator*
      const auto* ptr = reinterpret_cast<const Comparator* const*>(opt_address);
466 467 468
      // Since the user-specified comparator will be wrapped by
      // InternalKeyComparator, we should persist the user-specified one
      // instead of InternalKeyComparator.
S
Siying Dong 已提交
469 470
      if (*ptr == nullptr) {
        *value = kNullptrString;
471
      } else {
S
Siying Dong 已提交
472 473 474 475 476
        const Comparator* root_comp = (*ptr)->GetRootComparator();
        if (root_comp == nullptr) {
          root_comp = (*ptr);
        }
        *value = root_comp->Name();
477
      }
478 479 480 481 482 483
      break;
    }
    case OptionType::kCompactionFilter: {
      // it's a const pointer of const CompactionFilter*
      const auto* ptr =
          reinterpret_cast<const CompactionFilter* const*>(opt_address);
484
      *value = *ptr ? (*ptr)->Name() : kNullptrString;
485 486 487 488 489 490
      break;
    }
    case OptionType::kCompactionFilterFactory: {
      const auto* ptr =
          reinterpret_cast<const std::shared_ptr<CompactionFilterFactory>*>(
              opt_address);
491
      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
492 493 494 495 496 497
      break;
    }
    case OptionType::kMemTableRepFactory: {
      const auto* ptr =
          reinterpret_cast<const std::shared_ptr<MemTableRepFactory>*>(
              opt_address);
498
      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
499 500 501 502 503
      break;
    }
    case OptionType::kMergeOperator: {
      const auto* ptr =
          reinterpret_cast<const std::shared_ptr<MergeOperator>*>(opt_address);
504 505 506 507 508 509 510 511 512 513
      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
      break;
    }
    case OptionType::kFilterPolicy: {
      const auto* ptr =
          reinterpret_cast<const std::shared_ptr<FilterPolicy>*>(opt_address);
      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
      break;
    }
    case OptionType::kChecksumType:
514 515
      return SerializeEnum<ChecksumType>(
          checksum_type_string_map,
516 517
          *reinterpret_cast<const ChecksumType*>(opt_address), value);
    case OptionType::kBlockBasedTableIndexType:
S
SherlockNoMad 已提交
518 519
      return SerializeEnum<BlockBasedTableOptions::IndexType>(
          block_base_table_index_type_string_map,
520 521 522 523 524 525 526 527
          *reinterpret_cast<const BlockBasedTableOptions::IndexType*>(
              opt_address),
          value);
    case OptionType::kFlushBlockPolicyFactory: {
      const auto* ptr =
          reinterpret_cast<const std::shared_ptr<FlushBlockPolicyFactory>*>(
              opt_address);
      *value = ptr->get() ? ptr->get()->Name() : kNullptrString;
528 529
      break;
    }
530
    case OptionType::kEncodingType:
531 532
      return SerializeEnum<EncodingType>(
          encoding_type_string_map,
533
          *reinterpret_cast<const EncodingType*>(opt_address), value);
534 535 536 537 538 539 540 541 542 543 544 545
    case OptionType::kWALRecoveryMode:
      return SerializeEnum<WALRecoveryMode>(
          wal_recovery_mode_string_map,
          *reinterpret_cast<const WALRecoveryMode*>(opt_address), value);
    case OptionType::kAccessHint:
      return SerializeEnum<DBOptions::AccessHint>(
          access_hint_string_map,
          *reinterpret_cast<const DBOptions::AccessHint*>(opt_address), value);
    case OptionType::kInfoLogLevel:
      return SerializeEnum<InfoLogLevel>(
          info_log_level_string_map,
          *reinterpret_cast<const InfoLogLevel*>(opt_address), value);
546 547 548 549 550 551
    default:
      return false;
  }
  return true;
}

552
Status GetMutableOptionsFromStrings(
553 554 555 556 557
    const MutableCFOptions& base_options,
    const std::unordered_map<std::string, std::string>& options_map,
    MutableCFOptions* new_options) {
  assert(new_options);
  *new_options = base_options;
558 559
  for (const auto& o : options_map) {
    try {
Y
Yi Wu 已提交
560 561 562 563 564 565 566 567 568 569 570 571 572
      auto iter = cf_options_type_info.find(o.first);
      if (iter == cf_options_type_info.end()) {
        return Status::InvalidArgument("Unrecognized option: " + o.first);
      }
      const auto& opt_info = iter->second;
      if (!opt_info.is_mutable) {
        return Status::InvalidArgument("Option not changeable: " + o.first);
      }
      bool is_ok = ParseOptionHelper(
          reinterpret_cast<char*>(new_options) + opt_info.mutable_offset,
          opt_info.type, o.second);
      if (!is_ok) {
        return Status::InvalidArgument("Error parsing " + o.first);
573
      }
574
    } catch (std::exception& e) {
Y
Yi Wu 已提交
575
      return Status::InvalidArgument("Error parsing " + o.first + ":" +
576
                                     std::string(e.what()));
577 578
    }
  }
579
  return Status::OK();
580 581
}

582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
Status GetMutableDBOptionsFromStrings(
    const MutableDBOptions& base_options,
    const std::unordered_map<std::string, std::string>& options_map,
    MutableDBOptions* new_options) {
  assert(new_options);
  *new_options = base_options;
  for (const auto& o : options_map) {
    try {
      auto iter = db_options_type_info.find(o.first);
      if (iter == db_options_type_info.end()) {
        return Status::InvalidArgument("Unrecognized option: " + o.first);
      }
      const auto& opt_info = iter->second;
      if (!opt_info.is_mutable) {
        return Status::InvalidArgument("Option not changeable: " + o.first);
      }
      bool is_ok = ParseOptionHelper(
          reinterpret_cast<char*>(new_options) + opt_info.mutable_offset,
          opt_info.type, o.second);
      if (!is_ok) {
        return Status::InvalidArgument("Error parsing " + o.first);
      }
    } catch (std::exception& e) {
      return Status::InvalidArgument("Error parsing " + o.first + ":" +
                                     std::string(e.what()));
    }
  }
  return Status::OK();
}

612 613
Status StringToMap(const std::string& opts_str,
                   std::unordered_map<std::string, std::string>* opts_map) {
L
Lei Jin 已提交
614 615
  assert(opts_map);
  // Example:
616 617
  //   opts_str = "write_buffer_size=1024;max_write_buffer_number=2;"
  //              "nested_opt={opt1=1;opt2=2};max_bytes_for_level_base=100"
L
Lei Jin 已提交
618 619 620 621 622
  size_t pos = 0;
  std::string opts = trim(opts_str);
  while (pos < opts.size()) {
    size_t eq_pos = opts.find('=', pos);
    if (eq_pos == std::string::npos) {
623
      return Status::InvalidArgument("Mismatched key value pair, '=' expected");
L
Lei Jin 已提交
624 625
    }
    std::string key = trim(opts.substr(pos, eq_pos - pos));
626 627 628
    if (key.empty()) {
      return Status::InvalidArgument("Empty key found");
    }
L
Lei Jin 已提交
629

630 631 632 633 634 635 636 637
    // skip space after '=' and look for '{' for possible nested options
    pos = eq_pos + 1;
    while (pos < opts.size() && isspace(opts[pos])) {
      ++pos;
    }
    // Empty value at the end
    if (pos >= opts.size()) {
      (*opts_map)[key] = "";
L
Lei Jin 已提交
638
      break;
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
    }
    if (opts[pos] == '{') {
      int count = 1;
      size_t brace_pos = pos + 1;
      while (brace_pos < opts.size()) {
        if (opts[brace_pos] == '{') {
          ++count;
        } else if (opts[brace_pos] == '}') {
          --count;
          if (count == 0) {
            break;
          }
        }
        ++brace_pos;
      }
      // found the matching closing brace
      if (count == 0) {
        (*opts_map)[key] = trim(opts.substr(pos + 1, brace_pos - pos - 1));
        // skip all whitespace and move to the next ';'
        // brace_pos points to the next position after the matching '}'
        pos = brace_pos + 1;
        while (pos < opts.size() && isspace(opts[pos])) {
          ++pos;
        }
        if (pos < opts.size() && opts[pos] != ';') {
          return Status::InvalidArgument(
              "Unexpected chars after nested options");
        }
        ++pos;
      } else {
        return Status::InvalidArgument(
            "Mismatched curly braces for nested options");
      }
L
Lei Jin 已提交
672
    } else {
673 674 675 676 677 678 679 680 681
      size_t sc_pos = opts.find(';', pos);
      if (sc_pos == std::string::npos) {
        (*opts_map)[key] = trim(opts.substr(pos));
        // It either ends with a trailing semi-colon or the last key-value pair
        break;
      } else {
        (*opts_map)[key] = trim(opts.substr(pos, sc_pos - pos));
      }
      pos = sc_pos + 1;
L
Lei Jin 已提交
682 683 684
    }
  }

685
  return Status::OK();
L
Lei Jin 已提交
686 687
}

688 689 690 691
Status ParseColumnFamilyOption(const std::string& name,
                               const std::string& org_value,
                               ColumnFamilyOptions* new_options,
                               bool input_strings_escaped = false) {
692
  const std::string& value =
693
      input_strings_escaped ? UnescapeOptionString(org_value) : org_value;
694
  try {
Y
Yi Wu 已提交
695
    if (name == "block_based_table_factory") {
696 697
      // Nested options
      BlockBasedTableOptions table_opt, base_table_options;
S
Siying Dong 已提交
698 699 700
      BlockBasedTableFactory* block_based_table_factory =
          static_cast_with_check<BlockBasedTableFactory, TableFactory>(
              new_options->table_factory.get());
701
      if (block_based_table_factory != nullptr) {
S
SherlockNoMad 已提交
702
        base_table_options = block_based_table_factory->table_options();
703 704 705 706
      }
      Status table_opt_s = GetBlockBasedTableOptionsFromString(
          base_table_options, value, &table_opt);
      if (!table_opt_s.ok()) {
707 708
        return Status::InvalidArgument(
            "unable to parse the specified CF option " + name);
709 710
      }
      new_options->table_factory.reset(NewBlockBasedTableFactory(table_opt));
711 712 713
    } else if (name == "plain_table_factory") {
      // Nested options
      PlainTableOptions table_opt, base_table_options;
S
Siying Dong 已提交
714 715 716
      PlainTableFactory* plain_table_factory =
          static_cast_with_check<PlainTableFactory, TableFactory>(
              new_options->table_factory.get());
717
      if (plain_table_factory != nullptr) {
S
SherlockNoMad 已提交
718
        base_table_options = plain_table_factory->table_options();
719 720 721 722
      }
      Status table_opt_s = GetPlainTableOptionsFromString(
          base_table_options, value, &table_opt);
      if (!table_opt_s.ok()) {
723 724
        return Status::InvalidArgument(
            "unable to parse the specified CF option " + name);
725 726
      }
      new_options->table_factory.reset(NewPlainTableFactory(table_opt));
727 728 729 730 731 732 733 734 735
    } else if (name == "memtable") {
      std::unique_ptr<MemTableRepFactory> new_mem_factory;
      Status mem_factory_s =
          GetMemTableRepFactoryFromString(value, &new_mem_factory);
      if (!mem_factory_s.ok()) {
        return Status::InvalidArgument(
            "unable to parse the specified CF option " + name);
      }
      new_options->memtable_factory.reset(new_mem_factory.release());
736 737 738 739
    } else if (name == "compression_opts") {
      size_t start = 0;
      size_t end = value.find(':');
      if (end == std::string::npos) {
740 741
        return Status::InvalidArgument(
            "unable to parse the specified CF option " + name);
742 743 744 745 746 747
      }
      new_options->compression_opts.window_bits =
          ParseInt(value.substr(start, end - start));
      start = end + 1;
      end = value.find(':', start);
      if (end == std::string::npos) {
748 749
        return Status::InvalidArgument(
            "unable to parse the specified CF option " + name);
750 751 752 753
      }
      new_options->compression_opts.level =
          ParseInt(value.substr(start, end - start));
      start = end + 1;
754
      if (start >= value.size()) {
755 756
        return Status::InvalidArgument(
            "unable to parse the specified CF option " + name);
757
      }
758
      end = value.find(':', start);
759 760
      new_options->compression_opts.strategy =
          ParseInt(value.substr(start, value.size() - start));
761 762 763 764 765 766 767 768 769
      // max_dict_bytes is optional for backwards compatibility
      if (end != std::string::npos) {
        start = end + 1;
        if (start >= value.size()) {
          return Status::InvalidArgument(
              "unable to parse the specified CF option " + name);
        }
        new_options->compression_opts.max_dict_bytes =
            ParseInt(value.substr(start, value.size() - start));
770
      }
771 772 773 774
    } else if (name == "compaction_options_fifo") {
      new_options->compaction_options_fifo.max_table_files_size =
          ParseUint64(value);
    } else {
775 776
      auto iter = cf_options_type_info.find(name);
      if (iter == cf_options_type_info.end()) {
777 778
        return Status::InvalidArgument(
            "Unable to parse the specified CF option " + name);
779 780
      }
      const auto& opt_info = iter->second;
781 782
      if (opt_info.verification != OptionVerificationType::kDeprecated &&
          ParseOptionHelper(
783 784 785 786 787 788
              reinterpret_cast<char*>(new_options) + opt_info.offset,
              opt_info.type, value)) {
        return Status::OK();
      }
      switch (opt_info.verification) {
        case OptionVerificationType::kByName:
789
        case OptionVerificationType::kByNameAllowNull:
790 791 792 793 794 795 796 797 798
          return Status::NotSupported(
              "Deserializing the specified CF option " + name +
                  " is not supported");
        case OptionVerificationType::kDeprecated:
          return Status::OK();
        default:
          return Status::InvalidArgument(
              "Unable to parse the specified CF option " + name);
      }
799
    }
D
Dmitri Smirnov 已提交
800
  } catch (const std::exception&) {
801 802
    return Status::InvalidArgument(
        "unable to parse the specified option " + name);
803
  }
804
  return Status::OK();
805 806
}

807 808 809 810
bool SerializeSingleDBOption(std::string* opt_string,
                             const DBOptions& db_options,
                             const std::string& name,
                             const std::string& delimiter) {
811 812 813 814 815 816 817 818
  auto iter = db_options_type_info.find(name);
  if (iter == db_options_type_info.end()) {
    return false;
  }
  auto& opt_info = iter->second;
  const char* opt_address =
      reinterpret_cast<const char*>(&db_options) + opt_info.offset;
  std::string value;
819 820
  bool result = SerializeSingleOptionHelper(opt_address, opt_info.type, &value);
  if (result) {
821
    *opt_string = name + "=" + value + delimiter;
822
  }
823
  return result;
824 825
}

826 827 828
Status GetStringFromDBOptions(std::string* opt_string,
                              const DBOptions& db_options,
                              const std::string& delimiter) {
829 830 831 832
  assert(opt_string);
  opt_string->clear();
  for (auto iter = db_options_type_info.begin();
       iter != db_options_type_info.end(); ++iter) {
833 834 835 836 837
    if (iter->second.verification == OptionVerificationType::kDeprecated) {
      // If the option is no longer used in rocksdb and marked as deprecated,
      // we skip it in the serialization.
      continue;
    }
838
    std::string single_output;
839 840
    bool result = SerializeSingleDBOption(&single_output, db_options,
                                          iter->first, delimiter);
841 842 843 844 845 846 847 848
    assert(result);
    if (result) {
      opt_string->append(single_output);
    }
  }
  return Status::OK();
}

849 850
bool SerializeSingleColumnFamilyOption(std::string* opt_string,
                                       const ColumnFamilyOptions& cf_options,
851
                                       const std::string& name,
852
                                       const std::string& delimiter) {
853 854 855 856 857 858 859 860 861 862
  auto iter = cf_options_type_info.find(name);
  if (iter == cf_options_type_info.end()) {
    return false;
  }
  auto& opt_info = iter->second;
  const char* opt_address =
      reinterpret_cast<const char*>(&cf_options) + opt_info.offset;
  std::string value;
  bool result = SerializeSingleOptionHelper(opt_address, opt_info.type, &value);
  if (result) {
863
    *opt_string = name + "=" + value + delimiter;
864 865 866 867
  }
  return result;
}

868 869 870
Status GetStringFromColumnFamilyOptions(std::string* opt_string,
                                        const ColumnFamilyOptions& cf_options,
                                        const std::string& delimiter) {
871 872 873 874
  assert(opt_string);
  opt_string->clear();
  for (auto iter = cf_options_type_info.begin();
       iter != cf_options_type_info.end(); ++iter) {
875
    if (iter->second.verification == OptionVerificationType::kDeprecated) {
876 877
      // If the option is no longer used in rocksdb and marked as deprecated,
      // we skip it in the serialization.
878 879
      continue;
    }
880
    std::string single_output;
881 882
    bool result = SerializeSingleColumnFamilyOption(&single_output, cf_options,
                                                    iter->first, delimiter);
883 884 885
    if (result) {
      opt_string->append(single_output);
    } else {
886 887
      return Status::InvalidArgument("failed to serialize %s\n",
                                     iter->first.c_str());
888 889 890 891 892 893
    }
    assert(result);
  }
  return Status::OK();
}

894 895 896 897 898 899 900 901 902 903 904
Status GetStringFromCompressionType(std::string* compression_str,
                                    CompressionType compression_type) {
  bool ok = SerializeEnum<CompressionType>(compression_type_string_map,
                                           compression_type, compression_str);
  if (ok) {
    return Status::OK();
  } else {
    return Status::InvalidArgument("Invalid compression types");
  }
}

905 906 907 908 909 910 911 912 913 914 915
std::vector<CompressionType> GetSupportedCompressions() {
  std::vector<CompressionType> supported_compressions;
  for (const auto& comp_to_name : compression_type_string_map) {
    CompressionType t = comp_to_name.second;
    if (t != kDisableCompressionOption && CompressionTypeSupported(t)) {
      supported_compressions.push_back(t);
    }
  }
  return supported_compressions;
}

916 917 918 919
Status ParseDBOption(const std::string& name,
                     const std::string& org_value,
                     DBOptions* new_options,
                     bool input_strings_escaped = false) {
920
  const std::string& value =
921
      input_strings_escaped ? UnescapeOptionString(org_value) : org_value;
922
  try {
923
    if (name == "rate_limiter_bytes_per_sec") {
I
Igor Canadi 已提交
924 925
      new_options->rate_limiter.reset(
          NewGenericRateLimiter(static_cast<int64_t>(ParseUint64(value))));
926
    } else {
927 928
      auto iter = db_options_type_info.find(name);
      if (iter == db_options_type_info.end()) {
929
        return Status::InvalidArgument("Unrecognized option DBOptions:", name);
930
      }
931
      const auto& opt_info = iter->second;
932 933
      if (opt_info.verification != OptionVerificationType::kDeprecated &&
          ParseOptionHelper(
934 935 936 937 938 939
              reinterpret_cast<char*>(new_options) + opt_info.offset,
              opt_info.type, value)) {
        return Status::OK();
      }
      switch (opt_info.verification) {
        case OptionVerificationType::kByName:
940
        case OptionVerificationType::kByNameAllowNull:
941 942 943 944 945 946 947 948
          return Status::NotSupported(
              "Deserializing the specified DB option " + name +
                  " is not supported");
        case OptionVerificationType::kDeprecated:
          return Status::OK();
        default:
          return Status::InvalidArgument(
              "Unable to parse the specified DB option " + name);
949
      }
950
    }
D
Dmitri Smirnov 已提交
951
  } catch (const std::exception&) {
952
    return Status::InvalidArgument("Unable to parse DBOptions:", name);
953
  }
954
  return Status::OK();
955
}
L
Lei Jin 已提交
956

957
Status GetColumnFamilyOptionsFromMap(
L
Lei Jin 已提交
958 959
    const ColumnFamilyOptions& base_options,
    const std::unordered_map<std::string, std::string>& opts_map,
960 961
    ColumnFamilyOptions* new_options, bool input_strings_escaped,
    bool ignore_unknown_options) {
962
  return GetColumnFamilyOptionsFromMapInternal(
963 964
      base_options, opts_map, new_options, input_strings_escaped, nullptr,
      ignore_unknown_options);
965 966 967 968 969 970
}

Status GetColumnFamilyOptionsFromMapInternal(
    const ColumnFamilyOptions& base_options,
    const std::unordered_map<std::string, std::string>& opts_map,
    ColumnFamilyOptions* new_options, bool input_strings_escaped,
971 972
    std::vector<std::string>* unsupported_options_names,
    bool ignore_unknown_options) {
973 974
  assert(new_options);
  *new_options = base_options;
975 976 977
  if (unsupported_options_names) {
    unsupported_options_names->clear();
  }
L
Lei Jin 已提交
978
  for (const auto& o : opts_map) {
979 980 981 982 983 984 985 986 987 988 989 990 991
    auto s = ParseColumnFamilyOption(o.first, o.second, new_options,
                                 input_strings_escaped);
    if (!s.ok()) {
      if (s.IsNotSupported()) {
        // If the deserialization of the specified option is not supported
        // and an output vector of unsupported_options is provided, then
        // we log the name of the unsupported option and proceed.
        if (unsupported_options_names != nullptr) {
          unsupported_options_names->push_back(o.first);
        }
        // Note that we still return Status::OK in such case to maintain
        // the backward compatibility in the old public API defined in
        // rocksdb/convenience.h
992 993
      } else if (s.IsInvalidArgument() && ignore_unknown_options) {
        continue;
994
      } else {
995 996
        // Restore "new_options" to the default "base_options".
        *new_options = base_options;
997
        return s;
998
      }
L
Lei Jin 已提交
999 1000
    }
  }
1001
  return Status::OK();
L
Lei Jin 已提交
1002 1003
}

1004
Status GetColumnFamilyOptionsFromString(
L
Lei Jin 已提交
1005 1006 1007 1008
    const ColumnFamilyOptions& base_options,
    const std::string& opts_str,
    ColumnFamilyOptions* new_options) {
  std::unordered_map<std::string, std::string> opts_map;
1009 1010
  Status s = StringToMap(opts_str, &opts_map);
  if (!s.ok()) {
1011
    *new_options = base_options;
1012
    return s;
L
Lei Jin 已提交
1013 1014 1015 1016
  }
  return GetColumnFamilyOptionsFromMap(base_options, opts_map, new_options);
}

1017
Status GetDBOptionsFromMap(
L
Lei Jin 已提交
1018 1019
    const DBOptions& base_options,
    const std::unordered_map<std::string, std::string>& opts_map,
1020 1021 1022 1023 1024
    DBOptions* new_options, bool input_strings_escaped,
    bool ignore_unknown_options) {
  return GetDBOptionsFromMapInternal(base_options, opts_map, new_options,
                                     input_strings_escaped, nullptr,
                                     ignore_unknown_options);
1025 1026 1027 1028 1029 1030
}

Status GetDBOptionsFromMapInternal(
    const DBOptions& base_options,
    const std::unordered_map<std::string, std::string>& opts_map,
    DBOptions* new_options, bool input_strings_escaped,
1031 1032
    std::vector<std::string>* unsupported_options_names,
    bool ignore_unknown_options) {
L
Lei Jin 已提交
1033 1034
  assert(new_options);
  *new_options = base_options;
1035 1036 1037
  if (unsupported_options_names) {
    unsupported_options_names->clear();
  }
L
Lei Jin 已提交
1038
  for (const auto& o : opts_map) {
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
    auto s = ParseDBOption(o.first, o.second,
                           new_options, input_strings_escaped);
    if (!s.ok()) {
      if (s.IsNotSupported()) {
        // If the deserialization of the specified option is not supported
        // and an output vector of unsupported_options is provided, then
        // we log the name of the unsupported option and proceed.
        if (unsupported_options_names != nullptr) {
          unsupported_options_names->push_back(o.first);
        }
        // Note that we still return Status::OK in such case to maintain
        // the backward compatibility in the old public API defined in
        // rocksdb/convenience.h
1052 1053
      } else if (s.IsInvalidArgument() && ignore_unknown_options) {
        continue;
1054
      } else {
1055 1056
        // Restore "new_options" to the default "base_options".
        *new_options = base_options;
1057 1058
        return s;
      }
1059 1060
    }
  }
1061
  return Status::OK();
1062 1063
}

1064
Status GetDBOptionsFromString(
L
Lei Jin 已提交
1065 1066 1067 1068
    const DBOptions& base_options,
    const std::string& opts_str,
    DBOptions* new_options) {
  std::unordered_map<std::string, std::string> opts_map;
1069 1070
  Status s = StringToMap(opts_str, &opts_map);
  if (!s.ok()) {
1071
    *new_options = base_options;
1072
    return s;
L
Lei Jin 已提交
1073 1074 1075 1076
  }
  return GetDBOptionsFromMap(base_options, opts_map, new_options);
}

1077 1078 1079 1080 1081 1082 1083 1084 1085 1086
Status GetOptionsFromString(const Options& base_options,
                            const std::string& opts_str, Options* new_options) {
  std::unordered_map<std::string, std::string> opts_map;
  Status s = StringToMap(opts_str, &opts_map);
  if (!s.ok()) {
    return s;
  }
  DBOptions new_db_options(base_options);
  ColumnFamilyOptions new_cf_options(base_options);
  for (const auto& o : opts_map) {
1087 1088 1089
    if (ParseDBOption(o.first, o.second, &new_db_options).ok()) {
    } else if (ParseColumnFamilyOption(
        o.first, o.second, &new_cf_options).ok()) {
1090 1091 1092 1093 1094 1095 1096 1097
    } else {
      return Status::InvalidArgument("Can't parse option " + o.first);
    }
  }
  *new_options = Options(new_db_options, new_cf_options);
  return Status::OK();
}

1098 1099 1100
Status GetTableFactoryFromMap(
    const std::string& factory_name,
    const std::unordered_map<std::string, std::string>& opt_map,
1101
    std::shared_ptr<TableFactory>* table_factory, bool ignore_unknown_options) {
1102 1103 1104 1105
  Status s;
  if (factory_name == BlockBasedTableFactory().Name()) {
    BlockBasedTableOptions bbt_opt;
    s = GetBlockBasedTableOptionsFromMap(BlockBasedTableOptions(), opt_map,
1106 1107 1108
                                         &bbt_opt,
                                         true, /* input_strings_escaped */
                                         ignore_unknown_options);
1109 1110 1111 1112 1113
    if (!s.ok()) {
      return s;
    }
    table_factory->reset(new BlockBasedTableFactory(bbt_opt));
    return Status::OK();
1114 1115
  } else if (factory_name == PlainTableFactory().Name()) {
    PlainTableOptions pt_opt;
I
Islam AbdelRahman 已提交
1116
    s = GetPlainTableOptionsFromMap(PlainTableOptions(), opt_map, &pt_opt,
1117 1118
                                    true, /* input_strings_escaped */
                                    ignore_unknown_options);
1119 1120 1121 1122 1123
    if (!s.ok()) {
      return s;
    }
    table_factory->reset(new PlainTableFactory(pt_opt));
    return Status::OK();
1124 1125 1126 1127 1128 1129 1130
  }
  // Return OK for not supported table factories as TableFactory
  // Deserialization is optional.
  table_factory->reset();
  return Status::OK();
}

1131
#endif  // !ROCKSDB_LITE
1132

1133
}  // namespace rocksdb