Skip to content

Commit 0b35c12

Browse files
andrewgithubandrewgithub
andrewgithub
authored and
andrewgithub
committed
添加对option的说明
1 parent 6de937d commit 0b35c12

File tree

4 files changed

+13
-21
lines changed

4 files changed

+13
-21
lines changed

doc/instruction/readme.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ endif::rootpath[]
5959

6060
使用 `static Status Open(const Options &options, const std::string &name, DB **dbptr)` 可以打开一个数据库, options填入数据库打开选项,name指定数据库名,DB给出一个数据库指针(原先指向nullptr),因为调用之后会把创建的数据库句柄赋值给对应的指针。
6161

62-
- Options 用来控制数据库行为的一些参数在调用 `DB::Open` 的时候使用
62+
- Options 用来控制数据库行为的一些参数在调用 `DB::Open` 的时候使用,下面试Options的说明
6363

6464
[source,c++]
6565
----

doc/persistence/log_format.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bytes free in the third block, which will be left empty as the trailer.
7878

7979
**C** will be stored as a FULL record in the fourth block.
8080

81-
----
81+
8282

8383
## Some benefits over the recordio format:
8484

doc/utils/c++_common_knowledge.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class NoDestructor {
109109

110110
*总结*
111111

112-
这一个实例的创建使用了三个比较重要的C++知识点,alignof取结构体对齐长度,`new(placement new)` 来实现预分配内存的new,在结合 `aligned_storage` 来保证已有对象内存绝对大于等于需要申请对象的内存,然后经过饿汉式单例模式封装,经过以上几个步骤之后,一个能长久陪伴数据库句柄的对比工具便诞生了。
112+
在整个levelDB中有很多地方都用了这个特性进行单例的创建,在这个实例的创建中使用了三个比较重要的C++知识点,alignof取结构体对齐长度,`new(placement new)` 来实现预分配内存的new,在结合 `aligned_storage` 来保证已有对象内存绝对大于等于需要申请对象的内存,然后经过饿汉式单例模式封装,经过以上几个步骤之后,一个能长久陪伴数据库句柄的对比工具便诞生了。
113113

114114

115115

include/leveldb/options.h

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,25 @@ namespace leveldb {
3434
kSnappyCompression = 0x1
3535
};
3636

37-
// Options to control the behavior of a database (passed to DB::Open)
37+
// Options 通过传入给 DB::OPen 来控制数据库行为
3838
struct LEVELDB_EXPORT Options {
39-
// Create an Options object with default values for all fields.
39+
// 使用默认值构造Options
4040
Options();
4141

42-
// -------------------
43-
// Parameters that affect behavior
44-
45-
// Comparator used to define the order of keys in the table.
46-
// Default: a comparator that uses lexicographic byte-wise ordering
47-
//
48-
// REQUIRES: The client must ensure that the comparator supplied
49-
// here has the same name and orders keys *exactly* the same as the
50-
// comparator provided to previous open calls on the same DB.
42+
// Comparator 用来定义keys值在table中的排序方式
43+
// Default: 默认提供的对比工具是按照字典顺序进行排序的,也就是字典中字幕的排列顺序进行排序
44+
// 需要用户保证所有打开数据的对比工具都是一致的
5145
const Comparator *comparator;
5246

53-
// If true, the database will be created if it is missing.
47+
// 如果设置为true,当数据库丢失时会创建一个新的数据库
5448
bool create_if_missing = false;
5549

56-
// If true, an error is raised if the database already exists.
50+
// 如果设置为true,当同名数据库已经存在就直接报错
5751
bool error_if_exists = false;
5852

59-
// If true, the implementation will do aggressive checking of the
60-
// data it is processing and will stop early if it detects any
61-
// errors. This may have unforeseen ramifications: for example, a
62-
// corruption of one DB entry may cause a large number of entries to
63-
// become unreadable or for the entire DB to become unopenable.
53+
// 如果设置为true,将会实现对正在设置的数据进行检查,如果检测到任何错误将会提前停止
54+
// 这可能会导致不可预料的异常,例如:一个损坏的DB表项,可能造成大量的DB表项不可读
55+
// 甚至导致整个数据库不可打开
6456
bool paranoid_checks = false;
6557

6658
// Use the specified object to interact with the environment,

0 commit comments

Comments
 (0)