2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02:00
|
|
|
// 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).
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
|
2017-04-06 04:02:00 +02:00
|
|
|
#include "options/options_parser.h"
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-04-06 04:02:00 +02:00
|
|
|
#include "options/options_helper.h"
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
#include "rocksdb/convenience.h"
|
|
|
|
#include "rocksdb/db.h"
|
2017-07-29 01:23:50 +02:00
|
|
|
#include "util/cast_util.h"
|
2018-05-22 01:37:47 +02:00
|
|
|
#include "util/file_reader_writer.h"
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
#include "util/string_util.h"
|
2015-12-09 02:01:02 +01:00
|
|
|
#include "util/sync_point.h"
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
|
2015-09-30 20:20:23 +02:00
|
|
|
#include "port/port.h"
|
|
|
|
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
static const std::string option_file_header =
|
|
|
|
"# This is a RocksDB option file.\n"
|
|
|
|
"#\n"
|
|
|
|
"# For detailed file format spec, please refer to the example file\n"
|
|
|
|
"# in examples/rocksdb_option_file_example.ini\n"
|
|
|
|
"#\n"
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
Status PersistRocksDBOptions(const DBOptions& db_opt,
|
|
|
|
const std::vector<std::string>& cf_names,
|
|
|
|
const std::vector<ColumnFamilyOptions>& cf_opts,
|
|
|
|
const std::string& file_name, Env* env) {
|
2015-12-09 02:01:02 +01:00
|
|
|
TEST_SYNC_POINT("PersistRocksDBOptions:start");
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (cf_names.size() != cf_opts.size()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"cf_names.size() and cf_opts.size() must be the same");
|
|
|
|
}
|
2018-05-22 01:37:47 +02:00
|
|
|
std::unique_ptr<WritableFile> wf;
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
|
2018-05-22 01:37:47 +02:00
|
|
|
Status s = env->NewWritableFile(file_name, &wf, EnvOptions());
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
2018-11-09 20:17:34 +01:00
|
|
|
std::unique_ptr<WritableFileWriter> writable;
|
2018-08-23 19:04:10 +02:00
|
|
|
writable.reset(new WritableFileWriter(std::move(wf), file_name, EnvOptions(),
|
2018-05-22 01:37:47 +02:00
|
|
|
nullptr /* statistics */));
|
|
|
|
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
std::string options_file_content;
|
|
|
|
|
|
|
|
writable->Append(option_file_header + "[" +
|
|
|
|
opt_section_titles[kOptionSectionVersion] +
|
|
|
|
"]\n"
|
|
|
|
" rocksdb_version=" +
|
|
|
|
ToString(ROCKSDB_MAJOR) + "." + ToString(ROCKSDB_MINOR) +
|
|
|
|
"." + ToString(ROCKSDB_PATCH) + "\n");
|
|
|
|
writable->Append(" options_file_version=" +
|
|
|
|
ToString(ROCKSDB_OPTION_FILE_MAJOR) + "." +
|
|
|
|
ToString(ROCKSDB_OPTION_FILE_MINOR) + "\n");
|
|
|
|
writable->Append("\n[" + opt_section_titles[kOptionSectionDBOptions] +
|
|
|
|
"]\n ");
|
|
|
|
|
|
|
|
s = GetStringFromDBOptions(&options_file_content, db_opt, "\n ");
|
|
|
|
if (!s.ok()) {
|
|
|
|
writable->Close();
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
writable->Append(options_file_content + "\n");
|
|
|
|
|
|
|
|
for (size_t i = 0; i < cf_opts.size(); ++i) {
|
2015-10-11 21:17:42 +02:00
|
|
|
// CFOptions section
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
writable->Append("\n[" + opt_section_titles[kOptionSectionCFOptions] +
|
|
|
|
" \"" + EscapeOptionString(cf_names[i]) + "\"]\n ");
|
|
|
|
s = GetStringFromColumnFamilyOptions(&options_file_content, cf_opts[i],
|
|
|
|
"\n ");
|
|
|
|
if (!s.ok()) {
|
|
|
|
writable->Close();
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
writable->Append(options_file_content + "\n");
|
2015-10-11 21:17:42 +02:00
|
|
|
// TableOptions section
|
|
|
|
auto* tf = cf_opts[i].table_factory.get();
|
|
|
|
if (tf != nullptr) {
|
|
|
|
writable->Append("[" + opt_section_titles[kOptionSectionTableOptions] +
|
|
|
|
tf->Name() + " \"" + EscapeOptionString(cf_names[i]) +
|
|
|
|
"\"]\n ");
|
2017-07-29 01:23:50 +02:00
|
|
|
options_file_content.clear();
|
|
|
|
s = tf->GetOptionString(&options_file_content, "\n ");
|
2015-10-11 21:17:42 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
writable->Append(options_file_content + "\n");
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
}
|
2018-05-22 01:37:47 +02:00
|
|
|
writable->Sync(true /* use_fsync */);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
writable->Close();
|
|
|
|
|
|
|
|
return RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
|
|
|
|
db_opt, cf_names, cf_opts, file_name, env);
|
|
|
|
}
|
|
|
|
|
|
|
|
RocksDBOptionsParser::RocksDBOptionsParser() { Reset(); }
|
|
|
|
|
|
|
|
void RocksDBOptionsParser::Reset() {
|
|
|
|
db_opt_ = DBOptions();
|
2015-10-03 00:35:32 +02:00
|
|
|
db_opt_map_.clear();
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
cf_names_.clear();
|
|
|
|
cf_opts_.clear();
|
2015-10-03 00:35:32 +02:00
|
|
|
cf_opt_maps_.clear();
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
has_version_section_ = false;
|
|
|
|
has_db_options_ = false;
|
|
|
|
has_default_cf_options_ = false;
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
db_version[i] = 0;
|
|
|
|
opt_file_version[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RocksDBOptionsParser::IsSection(const std::string& line) {
|
|
|
|
if (line.size() < 2) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (line[0] != '[' || line[line.size() - 1] != ']') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::ParseSection(OptionSection* section,
|
2015-10-11 21:17:42 +02:00
|
|
|
std::string* title,
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
std::string* argument,
|
|
|
|
const std::string& line,
|
|
|
|
const int line_num) {
|
|
|
|
*section = kOptionSectionUnknown;
|
|
|
|
// A section is of the form [<SectionName> "<SectionArg>"], where
|
|
|
|
// "<SectionArg>" is optional.
|
|
|
|
size_t arg_start_pos = line.find("\"");
|
|
|
|
size_t arg_end_pos = line.rfind("\"");
|
|
|
|
// The following if-then check tries to identify whether the input
|
|
|
|
// section has the optional section argument.
|
|
|
|
if (arg_start_pos != std::string::npos && arg_start_pos != arg_end_pos) {
|
2015-10-11 21:17:42 +02:00
|
|
|
*title = TrimAndRemoveComment(line.substr(1, arg_start_pos - 1), true);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
*argument = UnescapeOptionString(
|
|
|
|
line.substr(arg_start_pos + 1, arg_end_pos - arg_start_pos - 1));
|
|
|
|
} else {
|
2015-10-11 21:17:42 +02:00
|
|
|
*title = TrimAndRemoveComment(line.substr(1, line.size() - 2), true);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
*argument = "";
|
|
|
|
}
|
|
|
|
for (int i = 0; i < kOptionSectionUnknown; ++i) {
|
2015-10-11 21:17:42 +02:00
|
|
|
if (title->find(opt_section_titles[i]) == 0) {
|
|
|
|
if (i == kOptionSectionVersion || i == kOptionSectionDBOptions ||
|
|
|
|
i == kOptionSectionCFOptions) {
|
|
|
|
if (title->size() == opt_section_titles[i].size()) {
|
|
|
|
// if true, then it indicats equal
|
|
|
|
*section = static_cast<OptionSection>(i);
|
|
|
|
return CheckSection(*section, *argument, line_num);
|
|
|
|
}
|
|
|
|
} else if (i == kOptionSectionTableOptions) {
|
|
|
|
// This type of sections has a sufffix at the end of the
|
|
|
|
// section title
|
|
|
|
if (title->size() > opt_section_titles[i].size()) {
|
|
|
|
*section = static_cast<OptionSection>(i);
|
|
|
|
return CheckSection(*section, *argument, line_num);
|
|
|
|
}
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status::InvalidArgument(std::string("Unknown section ") + line);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::InvalidArgument(const int line_num,
|
|
|
|
const std::string& message) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"[RocksDBOptionsParser Error] ",
|
|
|
|
message + " (at line " + ToString(line_num) + ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::ParseStatement(std::string* name,
|
|
|
|
std::string* value,
|
|
|
|
const std::string& line,
|
|
|
|
const int line_num) {
|
|
|
|
size_t eq_pos = line.find("=");
|
|
|
|
if (eq_pos == std::string::npos) {
|
|
|
|
return InvalidArgument(line_num, "A valid statement must have a '='.");
|
|
|
|
}
|
|
|
|
|
|
|
|
*name = TrimAndRemoveComment(line.substr(0, eq_pos), true);
|
|
|
|
*value =
|
|
|
|
TrimAndRemoveComment(line.substr(eq_pos + 1, line.size() - eq_pos - 1));
|
|
|
|
if (name->empty()) {
|
|
|
|
return InvalidArgument(line_num,
|
|
|
|
"A valid statement must have a variable name.");
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
2017-06-14 01:55:08 +02:00
|
|
|
Status RocksDBOptionsParser::Parse(const std::string& file_name, Env* env,
|
|
|
|
bool ignore_unknown_options) {
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
Reset();
|
|
|
|
|
|
|
|
std::unique_ptr<SequentialFile> seq_file;
|
|
|
|
Status s = env->NewSequentialFile(file_name, &seq_file, EnvOptions());
|
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
OptionSection section = kOptionSectionUnknown;
|
2015-10-11 21:17:42 +02:00
|
|
|
std::string title;
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
std::string argument;
|
|
|
|
std::unordered_map<std::string, std::string> opt_map;
|
|
|
|
std::istringstream iss;
|
|
|
|
std::string line;
|
|
|
|
bool has_data = true;
|
|
|
|
// we only support single-lined statement.
|
|
|
|
for (int line_num = 1;
|
|
|
|
ReadOneLine(&iss, seq_file.get(), &line, &has_data, &s); ++line_num) {
|
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
line = TrimAndRemoveComment(line);
|
|
|
|
if (line.empty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (IsSection(line)) {
|
2017-06-14 01:55:08 +02:00
|
|
|
s = EndSection(section, title, argument, opt_map, ignore_unknown_options);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
opt_map.clear();
|
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
2018-02-22 22:23:53 +01:00
|
|
|
|
|
|
|
// If the option file is not generated by a higher minor version,
|
|
|
|
// there shouldn't be any unknown option.
|
|
|
|
if (ignore_unknown_options && section == kOptionSectionVersion) {
|
|
|
|
if (db_version[0] < ROCKSDB_MAJOR || (db_version[0] == ROCKSDB_MAJOR &&
|
|
|
|
db_version[1] <= ROCKSDB_MINOR)) {
|
|
|
|
ignore_unknown_options = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-11 21:17:42 +02:00
|
|
|
s = ParseSection(§ion, &title, &argument, line, line_num);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
std::string name;
|
|
|
|
std::string value;
|
|
|
|
s = ParseStatement(&name, &value, line, line_num);
|
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
opt_map.insert({name, value});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-14 01:55:08 +02:00
|
|
|
s = EndSection(section, title, argument, opt_map, ignore_unknown_options);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
opt_map.clear();
|
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
return ValidityCheck();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::CheckSection(const OptionSection section,
|
|
|
|
const std::string& section_arg,
|
|
|
|
const int line_num) {
|
|
|
|
if (section == kOptionSectionDBOptions) {
|
|
|
|
if (has_db_options_) {
|
|
|
|
return InvalidArgument(
|
|
|
|
line_num,
|
|
|
|
"More than one DBOption section found in the option config file");
|
|
|
|
}
|
|
|
|
has_db_options_ = true;
|
|
|
|
} else if (section == kOptionSectionCFOptions) {
|
|
|
|
bool is_default_cf = (section_arg == kDefaultColumnFamilyName);
|
|
|
|
if (cf_opts_.size() == 0 && !is_default_cf) {
|
|
|
|
return InvalidArgument(
|
|
|
|
line_num,
|
|
|
|
"Default column family must be the first CFOptions section "
|
|
|
|
"in the option config file");
|
|
|
|
} else if (cf_opts_.size() != 0 && is_default_cf) {
|
|
|
|
return InvalidArgument(
|
|
|
|
line_num,
|
|
|
|
"Default column family must be the first CFOptions section "
|
2015-10-11 21:17:42 +02:00
|
|
|
"in the optio/n config file");
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
} else if (GetCFOptions(section_arg) != nullptr) {
|
|
|
|
return InvalidArgument(
|
|
|
|
line_num,
|
|
|
|
"Two identical column families found in option config file");
|
|
|
|
}
|
|
|
|
has_default_cf_options_ |= is_default_cf;
|
2015-10-11 21:17:42 +02:00
|
|
|
} else if (section == kOptionSectionTableOptions) {
|
|
|
|
if (GetCFOptions(section_arg) == nullptr) {
|
|
|
|
return InvalidArgument(
|
|
|
|
line_num, std::string(
|
|
|
|
"Does not find a matched column family name in "
|
|
|
|
"TableOptions section. Column Family Name:") +
|
|
|
|
section_arg);
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
} else if (section == kOptionSectionVersion) {
|
|
|
|
if (has_version_section_) {
|
|
|
|
return InvalidArgument(
|
|
|
|
line_num,
|
|
|
|
"More than one Version section found in the option config file.");
|
|
|
|
}
|
|
|
|
has_version_section_ = true;
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::ParseVersionNumber(const std::string& ver_name,
|
|
|
|
const std::string& ver_string,
|
|
|
|
const int max_count,
|
|
|
|
int* version) {
|
|
|
|
int version_index = 0;
|
|
|
|
int current_number = 0;
|
|
|
|
int current_digit_count = 0;
|
|
|
|
bool has_dot = false;
|
|
|
|
for (int i = 0; i < max_count; ++i) {
|
|
|
|
version[i] = 0;
|
|
|
|
}
|
|
|
|
const int kBufferSize = 200;
|
|
|
|
char buffer[kBufferSize];
|
|
|
|
for (size_t i = 0; i < ver_string.size(); ++i) {
|
|
|
|
if (ver_string[i] == '.') {
|
|
|
|
if (version_index >= max_count - 1) {
|
|
|
|
snprintf(buffer, sizeof(buffer) - 1,
|
|
|
|
"A valid %s can only contains at most %d dots.",
|
|
|
|
ver_name.c_str(), max_count - 1);
|
|
|
|
return Status::InvalidArgument(buffer);
|
|
|
|
}
|
|
|
|
if (current_digit_count == 0) {
|
|
|
|
snprintf(buffer, sizeof(buffer) - 1,
|
|
|
|
"A valid %s must have at least one digit before each dot.",
|
|
|
|
ver_name.c_str());
|
|
|
|
return Status::InvalidArgument(buffer);
|
|
|
|
}
|
|
|
|
version[version_index++] = current_number;
|
|
|
|
current_number = 0;
|
|
|
|
current_digit_count = 0;
|
|
|
|
has_dot = true;
|
|
|
|
} else if (isdigit(ver_string[i])) {
|
|
|
|
current_number = current_number * 10 + (ver_string[i] - '0');
|
|
|
|
current_digit_count++;
|
|
|
|
} else {
|
|
|
|
snprintf(buffer, sizeof(buffer) - 1,
|
|
|
|
"A valid %s can only contains dots and numbers.",
|
|
|
|
ver_name.c_str());
|
|
|
|
return Status::InvalidArgument(buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
version[version_index] = current_number;
|
|
|
|
if (has_dot && current_digit_count == 0) {
|
|
|
|
snprintf(buffer, sizeof(buffer) - 1,
|
|
|
|
"A valid %s must have at least one digit after each dot.",
|
|
|
|
ver_name.c_str());
|
|
|
|
return Status::InvalidArgument(buffer);
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::EndSection(
|
2015-10-11 21:17:42 +02:00
|
|
|
const OptionSection section, const std::string& section_title,
|
|
|
|
const std::string& section_arg,
|
2017-06-14 01:55:08 +02:00
|
|
|
const std::unordered_map<std::string, std::string>& opt_map,
|
|
|
|
bool ignore_unknown_options) {
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
Status s;
|
|
|
|
if (section == kOptionSectionDBOptions) {
|
2017-06-14 01:55:08 +02:00
|
|
|
s = GetDBOptionsFromMap(DBOptions(), opt_map, &db_opt_, true,
|
|
|
|
ignore_unknown_options);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
2015-10-03 00:35:32 +02:00
|
|
|
db_opt_map_ = opt_map;
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
} else if (section == kOptionSectionCFOptions) {
|
|
|
|
// This condition should be ensured earlier in ParseSection
|
|
|
|
// so we make an assertion here.
|
|
|
|
assert(GetCFOptions(section_arg) == nullptr);
|
|
|
|
cf_names_.emplace_back(section_arg);
|
|
|
|
cf_opts_.emplace_back();
|
|
|
|
s = GetColumnFamilyOptionsFromMap(ColumnFamilyOptions(), opt_map,
|
2017-06-14 01:55:08 +02:00
|
|
|
&cf_opts_.back(), true,
|
|
|
|
ignore_unknown_options);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
2015-10-03 00:35:32 +02:00
|
|
|
// keep the parsed string.
|
|
|
|
cf_opt_maps_.emplace_back(opt_map);
|
2015-10-11 21:17:42 +02:00
|
|
|
} else if (section == kOptionSectionTableOptions) {
|
|
|
|
assert(GetCFOptions(section_arg) != nullptr);
|
|
|
|
auto* cf_opt = GetCFOptionsImpl(section_arg);
|
|
|
|
if (cf_opt == nullptr) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"The specified column family must be defined before the "
|
|
|
|
"TableOptions section:",
|
|
|
|
section_arg);
|
|
|
|
}
|
|
|
|
// Ignore error as table factory deserialization is optional
|
|
|
|
s = GetTableFactoryFromMap(
|
|
|
|
section_title.substr(
|
|
|
|
opt_section_titles[kOptionSectionTableOptions].size()),
|
2017-06-14 01:55:08 +02:00
|
|
|
opt_map, &(cf_opt->table_factory), ignore_unknown_options);
|
2015-10-11 21:17:42 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
} else if (section == kOptionSectionVersion) {
|
|
|
|
for (const auto pair : opt_map) {
|
|
|
|
if (pair.first == "rocksdb_version") {
|
|
|
|
s = ParseVersionNumber(pair.first, pair.second, 3, db_version);
|
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
} else if (pair.first == "options_file_version") {
|
|
|
|
s = ParseVersionNumber(pair.first, pair.second, 2, opt_file_version);
|
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
if (opt_file_version[0] < 1) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"A valid options_file_version must be at least 1.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::ValidityCheck() {
|
|
|
|
if (!has_db_options_) {
|
|
|
|
return Status::Corruption(
|
|
|
|
"A RocksDB Option file must have a single DBOptions section");
|
|
|
|
}
|
|
|
|
if (!has_default_cf_options_) {
|
|
|
|
return Status::Corruption(
|
|
|
|
"A RocksDB Option file must have a single CFOptions:default section");
|
|
|
|
}
|
|
|
|
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string RocksDBOptionsParser::TrimAndRemoveComment(const std::string& line,
|
|
|
|
bool trim_only) {
|
|
|
|
size_t start = 0;
|
|
|
|
size_t end = line.size();
|
|
|
|
|
|
|
|
// we only support "#" style comment
|
|
|
|
if (!trim_only) {
|
|
|
|
size_t search_pos = 0;
|
|
|
|
while (search_pos < line.size()) {
|
|
|
|
size_t comment_pos = line.find('#', search_pos);
|
|
|
|
if (comment_pos == std::string::npos) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (comment_pos == 0 || line[comment_pos - 1] != '\\') {
|
|
|
|
end = comment_pos;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
search_pos = comment_pos + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (start < end && isspace(line[start]) != 0) {
|
|
|
|
++start;
|
|
|
|
}
|
|
|
|
|
|
|
|
// start < end implies end > 0.
|
|
|
|
while (start < end && isspace(line[end - 1]) != 0) {
|
|
|
|
--end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (start < end) {
|
|
|
|
return line.substr(start, end - start);
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
bool AreEqualDoubles(const double a, const double b) {
|
|
|
|
return (fabs(a - b) < 0.00001);
|
|
|
|
}
|
2017-07-29 01:23:50 +02:00
|
|
|
} // namespace
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
|
2015-10-03 00:35:32 +02:00
|
|
|
bool AreEqualOptions(
|
|
|
|
const char* opt1, const char* opt2, const OptionTypeInfo& type_info,
|
|
|
|
const std::string& opt_name,
|
|
|
|
const std::unordered_map<std::string, std::string>* opt_map) {
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
const char* offset1 = opt1 + type_info.offset;
|
|
|
|
const char* offset2 = opt2 + type_info.offset;
|
2016-10-14 22:09:18 +02:00
|
|
|
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
switch (type_info.type) {
|
|
|
|
case OptionType::kBoolean:
|
|
|
|
return (*reinterpret_cast<const bool*>(offset1) ==
|
|
|
|
*reinterpret_cast<const bool*>(offset2));
|
|
|
|
case OptionType::kInt:
|
|
|
|
return (*reinterpret_cast<const int*>(offset1) ==
|
|
|
|
*reinterpret_cast<const int*>(offset2));
|
2019-03-12 21:46:12 +01:00
|
|
|
case OptionType::kInt32T:
|
|
|
|
return (*reinterpret_cast<const int32_t*>(offset1) ==
|
|
|
|
*reinterpret_cast<const int32_t*>(offset2));
|
|
|
|
case OptionType::kInt64T:
|
|
|
|
{
|
|
|
|
int64_t v1, v2;
|
|
|
|
GetUnaligned(reinterpret_cast<const int64_t*>(offset1), &v1);
|
|
|
|
GetUnaligned(reinterpret_cast<const int64_t*>(offset2), &v2);
|
|
|
|
return (v1 == v2);
|
|
|
|
}
|
2016-09-14 06:12:43 +02:00
|
|
|
case OptionType::kVectorInt:
|
|
|
|
return (*reinterpret_cast<const std::vector<int>*>(offset1) ==
|
|
|
|
*reinterpret_cast<const std::vector<int>*>(offset2));
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
case OptionType::kUInt:
|
|
|
|
return (*reinterpret_cast<const unsigned int*>(offset1) ==
|
|
|
|
*reinterpret_cast<const unsigned int*>(offset2));
|
|
|
|
case OptionType::kUInt32T:
|
|
|
|
return (*reinterpret_cast<const uint32_t*>(offset1) ==
|
|
|
|
*reinterpret_cast<const uint32_t*>(offset2));
|
|
|
|
case OptionType::kUInt64T:
|
2017-04-22 05:41:37 +02:00
|
|
|
{
|
|
|
|
uint64_t v1, v2;
|
|
|
|
GetUnaligned(reinterpret_cast<const uint64_t*>(offset1), &v1);
|
|
|
|
GetUnaligned(reinterpret_cast<const uint64_t*>(offset2), &v2);
|
|
|
|
return (v1 == v2);
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
case OptionType::kSizeT:
|
2017-04-22 05:41:37 +02:00
|
|
|
{
|
|
|
|
size_t v1, v2;
|
|
|
|
GetUnaligned(reinterpret_cast<const size_t*>(offset1), &v1);
|
|
|
|
GetUnaligned(reinterpret_cast<const size_t*>(offset2), &v2);
|
|
|
|
return (v1 == v2);
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
case OptionType::kString:
|
|
|
|
return (*reinterpret_cast<const std::string*>(offset1) ==
|
|
|
|
*reinterpret_cast<const std::string*>(offset2));
|
|
|
|
case OptionType::kDouble:
|
|
|
|
return AreEqualDoubles(*reinterpret_cast<const double*>(offset1),
|
|
|
|
*reinterpret_cast<const double*>(offset2));
|
|
|
|
case OptionType::kCompactionStyle:
|
|
|
|
return (*reinterpret_cast<const CompactionStyle*>(offset1) ==
|
|
|
|
*reinterpret_cast<const CompactionStyle*>(offset2));
|
2017-03-02 19:08:49 +01:00
|
|
|
case OptionType::kCompactionPri:
|
|
|
|
return (*reinterpret_cast<const CompactionPri*>(offset1) ==
|
|
|
|
*reinterpret_cast<const CompactionPri*>(offset2));
|
2015-10-03 00:35:32 +02:00
|
|
|
case OptionType::kCompressionType:
|
|
|
|
return (*reinterpret_cast<const CompressionType*>(offset1) ==
|
|
|
|
*reinterpret_cast<const CompressionType*>(offset2));
|
|
|
|
case OptionType::kVectorCompressionType: {
|
|
|
|
const auto* vec1 =
|
|
|
|
reinterpret_cast<const std::vector<CompressionType>*>(offset1);
|
|
|
|
const auto* vec2 =
|
|
|
|
reinterpret_cast<const std::vector<CompressionType>*>(offset2);
|
|
|
|
return (*vec1 == *vec2);
|
|
|
|
}
|
2015-10-11 21:17:42 +02:00
|
|
|
case OptionType::kChecksumType:
|
|
|
|
return (*reinterpret_cast<const ChecksumType*>(offset1) ==
|
|
|
|
*reinterpret_cast<const ChecksumType*>(offset2));
|
|
|
|
case OptionType::kBlockBasedTableIndexType:
|
|
|
|
return (
|
|
|
|
*reinterpret_cast<const BlockBasedTableOptions::IndexType*>(
|
|
|
|
offset1) ==
|
|
|
|
*reinterpret_cast<const BlockBasedTableOptions::IndexType*>(offset2));
|
2018-07-28 00:35:41 +02:00
|
|
|
case OptionType::kBlockBasedTableDataBlockIndexType:
|
|
|
|
return (
|
|
|
|
*reinterpret_cast<const BlockBasedTableOptions::DataBlockIndexType*>(
|
|
|
|
offset1) ==
|
|
|
|
*reinterpret_cast<const BlockBasedTableOptions::DataBlockIndexType*>(
|
|
|
|
offset2));
|
2019-04-22 17:17:45 +02:00
|
|
|
case OptionType::kBlockBasedTableIndexShorteningMode:
|
|
|
|
return (
|
|
|
|
*reinterpret_cast<const BlockBasedTableOptions::IndexShorteningMode*>(
|
|
|
|
offset1) ==
|
|
|
|
*reinterpret_cast<const BlockBasedTableOptions::IndexShorteningMode*>(
|
|
|
|
offset2));
|
2016-03-02 19:34:14 +01:00
|
|
|
case OptionType::kWALRecoveryMode:
|
|
|
|
return (*reinterpret_cast<const WALRecoveryMode*>(offset1) ==
|
|
|
|
*reinterpret_cast<const WALRecoveryMode*>(offset2));
|
|
|
|
case OptionType::kAccessHint:
|
|
|
|
return (*reinterpret_cast<const DBOptions::AccessHint*>(offset1) ==
|
|
|
|
*reinterpret_cast<const DBOptions::AccessHint*>(offset2));
|
|
|
|
case OptionType::kInfoLogLevel:
|
|
|
|
return (*reinterpret_cast<const InfoLogLevel*>(offset1) ==
|
|
|
|
*reinterpret_cast<const InfoLogLevel*>(offset2));
|
2017-10-20 00:19:20 +02:00
|
|
|
case OptionType::kCompactionOptionsFIFO: {
|
|
|
|
CompactionOptionsFIFO lhs =
|
|
|
|
*reinterpret_cast<const CompactionOptionsFIFO*>(offset1);
|
|
|
|
CompactionOptionsFIFO rhs =
|
|
|
|
*reinterpret_cast<const CompactionOptionsFIFO*>(offset2);
|
|
|
|
if (lhs.max_table_files_size == rhs.max_table_files_size &&
|
2019-02-15 18:48:44 +01:00
|
|
|
lhs.allow_compaction == rhs.allow_compaction) {
|
2017-10-20 00:19:20 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2017-12-11 22:12:12 +01:00
|
|
|
case OptionType::kCompactionOptionsUniversal: {
|
|
|
|
CompactionOptionsUniversal lhs =
|
|
|
|
*reinterpret_cast<const CompactionOptionsUniversal*>(offset1);
|
|
|
|
CompactionOptionsUniversal rhs =
|
|
|
|
*reinterpret_cast<const CompactionOptionsUniversal*>(offset2);
|
|
|
|
if (lhs.size_ratio == rhs.size_ratio &&
|
|
|
|
lhs.min_merge_width == rhs.min_merge_width &&
|
|
|
|
lhs.max_merge_width == rhs.max_merge_width &&
|
|
|
|
lhs.max_size_amplification_percent ==
|
|
|
|
rhs.max_size_amplification_percent &&
|
|
|
|
lhs.compression_size_percent == rhs.compression_size_percent &&
|
|
|
|
lhs.stop_style == rhs.stop_style &&
|
|
|
|
lhs.allow_trivial_move == rhs.allow_trivial_move) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
default:
|
2016-02-19 23:42:24 +01:00
|
|
|
if (type_info.verification == OptionVerificationType::kByName ||
|
2017-10-04 18:44:18 +02:00
|
|
|
type_info.verification ==
|
|
|
|
OptionVerificationType::kByNameAllowFromNull ||
|
2016-02-19 23:42:24 +01:00
|
|
|
type_info.verification == OptionVerificationType::kByNameAllowNull) {
|
2015-10-03 00:35:32 +02:00
|
|
|
std::string value1;
|
|
|
|
bool result =
|
|
|
|
SerializeSingleOptionHelper(offset1, type_info.type, &value1);
|
|
|
|
if (result == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (opt_map == nullptr) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
auto iter = opt_map->find(opt_name);
|
|
|
|
if (iter == opt_map->end()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
2016-02-19 23:42:24 +01:00
|
|
|
if (type_info.verification ==
|
|
|
|
OptionVerificationType::kByNameAllowNull) {
|
|
|
|
if (iter->second == kNullptrString || value1 == kNullptrString) {
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-04 18:44:18 +02:00
|
|
|
} else if (type_info.verification ==
|
|
|
|
OptionVerificationType::kByNameAllowFromNull) {
|
|
|
|
if (iter->second == kNullptrString) {
|
|
|
|
return true;
|
|
|
|
}
|
2016-02-19 23:42:24 +01:00
|
|
|
}
|
2015-10-03 00:35:32 +02:00
|
|
|
return (value1 == iter->second);
|
|
|
|
}
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::VerifyRocksDBOptionsFromFile(
|
|
|
|
const DBOptions& db_opt, const std::vector<std::string>& cf_names,
|
|
|
|
const std::vector<ColumnFamilyOptions>& cf_opts,
|
2015-11-05 03:53:30 +01:00
|
|
|
const std::string& file_name, Env* env,
|
2017-06-14 01:55:08 +02:00
|
|
|
OptionsSanityCheckLevel sanity_check_level, bool ignore_unknown_options) {
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
RocksDBOptionsParser parser;
|
|
|
|
std::unique_ptr<SequentialFile> seq_file;
|
2017-06-14 01:55:08 +02:00
|
|
|
Status s = parser.Parse(file_name, env, ignore_unknown_options);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify DBOptions
|
2015-11-05 03:53:30 +01:00
|
|
|
s = VerifyDBOptions(db_opt, *parser.db_opt(), parser.db_opt_map(),
|
|
|
|
sanity_check_level);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify ColumnFamily Name
|
|
|
|
if (cf_names.size() != parser.cf_names()->size()) {
|
2015-11-05 03:53:30 +01:00
|
|
|
if (sanity_check_level >= kSanityLevelLooselyCompatible) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"[RocksDBOptionParser Error] The persisted options does not have "
|
|
|
|
"the same number of column family names as the db instance.");
|
|
|
|
} else if (cf_opts.size() > parser.cf_opts()->size()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"[RocksDBOptionsParser Error]",
|
|
|
|
"The persisted options file has less number of column family "
|
|
|
|
"names than that of the specified one.");
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
}
|
|
|
|
for (size_t i = 0; i < cf_names.size(); ++i) {
|
|
|
|
if (cf_names[i] != parser.cf_names()->at(i)) {
|
2015-11-05 03:53:30 +01:00
|
|
|
return Status::InvalidArgument(
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
"[RocksDBOptionParser Error] The persisted options and the db"
|
|
|
|
"instance does not have the same name for column family ",
|
|
|
|
ToString(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify Column Family Options
|
|
|
|
if (cf_opts.size() != parser.cf_opts()->size()) {
|
2015-11-05 03:53:30 +01:00
|
|
|
if (sanity_check_level >= kSanityLevelLooselyCompatible) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"[RocksDBOptionsParser Error]",
|
|
|
|
"The persisted options does not have the same number of "
|
|
|
|
"column families as the db instance.");
|
|
|
|
} else if (cf_opts.size() > parser.cf_opts()->size()) {
|
|
|
|
return Status::InvalidArgument(
|
|
|
|
"[RocksDBOptionsParser Error]",
|
|
|
|
"The persisted options file has less number of column families "
|
|
|
|
"than that of the specified number.");
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
}
|
|
|
|
for (size_t i = 0; i < cf_opts.size(); ++i) {
|
2015-10-03 00:35:32 +02:00
|
|
|
s = VerifyCFOptions(cf_opts[i], parser.cf_opts()->at(i),
|
2015-11-05 03:53:30 +01:00
|
|
|
&(parser.cf_opt_maps()->at(i)), sanity_check_level);
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
2015-10-11 21:17:42 +02:00
|
|
|
s = VerifyTableFactory(cf_opts[i].table_factory.get(),
|
2015-11-05 03:53:30 +01:00
|
|
|
parser.cf_opts()->at(i).table_factory.get(),
|
|
|
|
sanity_check_level);
|
2015-10-11 21:17:42 +02:00
|
|
|
if (!s.ok()) {
|
|
|
|
return s;
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
2015-10-03 00:35:32 +02:00
|
|
|
Status RocksDBOptionsParser::VerifyDBOptions(
|
2015-11-05 03:53:30 +01:00
|
|
|
const DBOptions& base_opt, const DBOptions& persisted_opt,
|
2018-03-05 22:08:17 +01:00
|
|
|
const std::unordered_map<std::string, std::string>* /*opt_map*/,
|
2015-11-05 03:53:30 +01:00
|
|
|
OptionsSanityCheckLevel sanity_check_level) {
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
for (auto pair : db_options_type_info) {
|
2015-09-30 02:13:02 +02:00
|
|
|
if (pair.second.verification == OptionVerificationType::kDeprecated) {
|
|
|
|
// We skip checking deprecated variables as they might
|
|
|
|
// contain random values since they might not be initialized
|
|
|
|
continue;
|
|
|
|
}
|
2015-11-05 03:53:30 +01:00
|
|
|
if (DBOptionSanityCheckLevel(pair.first) <= sanity_check_level) {
|
|
|
|
if (!AreEqualOptions(reinterpret_cast<const char*>(&base_opt),
|
|
|
|
reinterpret_cast<const char*>(&persisted_opt),
|
|
|
|
pair.second, pair.first, nullptr)) {
|
|
|
|
const size_t kBufferSize = 2048;
|
|
|
|
char buffer[kBufferSize];
|
|
|
|
std::string base_value;
|
|
|
|
std::string persisted_value;
|
|
|
|
SerializeSingleOptionHelper(
|
|
|
|
reinterpret_cast<const char*>(&base_opt) + pair.second.offset,
|
|
|
|
pair.second.type, &base_value);
|
|
|
|
SerializeSingleOptionHelper(
|
|
|
|
reinterpret_cast<const char*>(&persisted_opt) + pair.second.offset,
|
|
|
|
pair.second.type, &persisted_value);
|
|
|
|
snprintf(buffer, sizeof(buffer),
|
|
|
|
"[RocksDBOptionsParser]: "
|
|
|
|
"failed the verification on DBOptions::%s --- "
|
|
|
|
"The specified one is %s while the persisted one is %s.\n",
|
|
|
|
pair.first.c_str(), base_value.c_str(),
|
|
|
|
persisted_value.c_str());
|
|
|
|
return Status::InvalidArgument(Slice(buffer, strlen(buffer)));
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
|
|
|
Status RocksDBOptionsParser::VerifyCFOptions(
|
2015-11-05 03:53:30 +01:00
|
|
|
const ColumnFamilyOptions& base_opt,
|
|
|
|
const ColumnFamilyOptions& persisted_opt,
|
|
|
|
const std::unordered_map<std::string, std::string>* persisted_opt_map,
|
|
|
|
OptionsSanityCheckLevel sanity_check_level) {
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
for (auto& pair : cf_options_type_info) {
|
2015-09-30 02:13:02 +02:00
|
|
|
if (pair.second.verification == OptionVerificationType::kDeprecated) {
|
|
|
|
// We skip checking deprecated variables as they might
|
|
|
|
// contain random values since they might not be initialized
|
|
|
|
continue;
|
|
|
|
}
|
2015-11-05 03:53:30 +01:00
|
|
|
if (CFOptionSanityCheckLevel(pair.first) <= sanity_check_level) {
|
|
|
|
if (!AreEqualOptions(reinterpret_cast<const char*>(&base_opt),
|
|
|
|
reinterpret_cast<const char*>(&persisted_opt),
|
|
|
|
pair.second, pair.first, persisted_opt_map)) {
|
|
|
|
const size_t kBufferSize = 2048;
|
|
|
|
char buffer[kBufferSize];
|
|
|
|
std::string base_value;
|
|
|
|
std::string persisted_value;
|
|
|
|
SerializeSingleOptionHelper(
|
|
|
|
reinterpret_cast<const char*>(&base_opt) + pair.second.offset,
|
|
|
|
pair.second.type, &base_value);
|
|
|
|
SerializeSingleOptionHelper(
|
|
|
|
reinterpret_cast<const char*>(&persisted_opt) + pair.second.offset,
|
|
|
|
pair.second.type, &persisted_value);
|
|
|
|
snprintf(buffer, sizeof(buffer),
|
|
|
|
"[RocksDBOptionsParser]: "
|
|
|
|
"failed the verification on ColumnFamilyOptions::%s --- "
|
|
|
|
"The specified one is %s while the persisted one is %s.\n",
|
|
|
|
pair.first.c_str(), base_value.c_str(),
|
|
|
|
persisted_value.c_str());
|
|
|
|
return Status::InvalidArgument(Slice(buffer, sizeof(buffer)));
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
2015-10-11 21:17:42 +02:00
|
|
|
|
2015-11-05 03:53:30 +01:00
|
|
|
Status RocksDBOptionsParser::VerifyTableFactory(
|
|
|
|
const TableFactory* base_tf, const TableFactory* file_tf,
|
|
|
|
OptionsSanityCheckLevel sanity_check_level) {
|
2015-10-11 21:17:42 +02:00
|
|
|
if (base_tf && file_tf) {
|
2015-11-05 03:53:30 +01:00
|
|
|
if (sanity_check_level > kSanityLevelNone &&
|
2017-07-29 01:23:50 +02:00
|
|
|
std::string(base_tf->Name()) != std::string(file_tf->Name())) {
|
2015-10-11 21:17:42 +02:00
|
|
|
return Status::Corruption(
|
|
|
|
"[RocksDBOptionsParser]: "
|
|
|
|
"failed the verification on TableFactory->Name()");
|
|
|
|
}
|
2017-07-29 01:23:50 +02:00
|
|
|
if (base_tf->Name() == BlockBasedTableFactory::kName) {
|
|
|
|
return VerifyBlockBasedTableFactory(
|
|
|
|
static_cast_with_check<const BlockBasedTableFactory,
|
|
|
|
const TableFactory>(base_tf),
|
|
|
|
static_cast_with_check<const BlockBasedTableFactory,
|
|
|
|
const TableFactory>(file_tf),
|
|
|
|
sanity_check_level);
|
2015-10-11 21:17:42 +02:00
|
|
|
}
|
|
|
|
// TODO(yhchiang): add checks for other table factory types
|
|
|
|
} else {
|
|
|
|
// TODO(yhchiang): further support sanity check here
|
|
|
|
}
|
|
|
|
return Status::OK();
|
|
|
|
}
|
RocksDB Options file format and its serialization / deserialization.
Summary:
This patch defines the format of RocksDB options file, which
follows the INI file format, and implements functions for its
serialization and deserialization. An example RocksDB options
file can be found in examples/rocksdb_option_file_example.ini.
A typical RocksDB options file has three sections, which are
Version, DBOptions, and more than one CFOptions. The RocksDB
options file in general follows the basic INI file format
with the following extensions / modifications:
* Escaped characters
We escaped the following characters:
- \n -- line feed - new line
- \r -- carriage return
- \\ -- backslash \
- \: -- colon symbol :
- \# -- hash tag #
* Comments
We support # style comments. Comments can appear at the ending
part of a line.
* Statements
A statement is of the form option_name = value.
Each statement contains a '=', where extra white-spaces
are supported. However, we don't support multi-lined statement.
Furthermore, each line can only contain at most one statement.
* Section
Sections are of the form [SecitonTitle "SectionArgument"],
where section argument is optional.
* List
We use colon-separated string to represent a list.
For instance, n1:n2:n3:n4 is a list containing four values.
Below is an example of a RocksDB options file:
[Version]
rocksdb_version=4.0.0
options_file_version=1.0
[DBOptions]
max_open_files=12345
max_background_flushes=301
[CFOptions "default"]
[CFOptions "the second column family"]
[CFOptions "the third column family"]
Test Plan: Added many tests in options_test.cc
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: maykov, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D46059
2015-09-29 23:42:40 +02:00
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
#endif // !ROCKSDB_LITE
|