Skip to content

Commit 199a5d5

Browse files
andrewgithubandrewgithub
andrewgithub
authored and
andrewgithub
committed
添加文件头文件目录说明
1 parent 228d8f2 commit 199a5d5

File tree

1 file changed

+17
-212
lines changed

1 file changed

+17
-212
lines changed

doc/instruction/readme.adoc

Lines changed: 17 additions & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ endif::rootpath[]
2222

2323
== 引言
2424

25-
2625
=== 特性
2726

2827
* Keys 和 values 可以是任意长度的数组
@@ -33,225 +32,31 @@ endif::rootpath[]
3332
* 用户可以创建快照
3433
* 支持按照迭代器遍历数据
3534
* https://google.github.io/snappy[数据库会自动使用Snappy库对数据进行压缩]
36-
*
37-
* External activity (file system operations etc.) is relayed through a virtual interface so users can customize the operating system interactions.
38-
39-
# Documentation
40-
41-
[LevelDB library documentation](https://github.com/google/leveldb/blob/master/doc/index.md) is online and bundled with the source code.
42-
43-
# Limitations
44-
45-
* This is not a SQL database. It does not have a relational data model, it does not support SQL queries, and it has no support for indexes.
46-
* Only a single process (possibly multi-threaded) can access a particular database at a time.
47-
* There is no client-server support builtin to the library. An application that needs such support will have to wrap their own server around the library.
48-
49-
# Getting the Source
50-
51-
```bash
52-
git clone --recurse-submodules https://github.com/google/leveldb.git
53-
```
54-
55-
# Building
56-
57-
This project supports [CMake](https://cmake.org/) out of the box.
58-
59-
### Build for POSIX
60-
61-
Quick start:
62-
63-
```bash
64-
mkdir -p build && cd build
65-
cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .
66-
```
67-
68-
### Building for Windows
69-
70-
First generate the Visual Studio 2017 project/solution files:
71-
72-
```cmd
73-
mkdir build
74-
cd build
75-
cmake -G "Visual Studio 15" ..
76-
```
77-
The default default will build for x86. For 64-bit run:
78-
79-
```cmd
80-
cmake -G "Visual Studio 15 Win64" ..
81-
```
82-
83-
To compile the Windows solution from the command-line:
84-
85-
```cmd
86-
devenv /build Debug leveldb.sln
87-
```
88-
89-
or open leveldb.sln in Visual Studio and build from within.
90-
91-
Please see the CMake documentation and `CMakeLists.txt` for more advanced usage.
92-
93-
# Contributing to the leveldb Project
94-
95-
The leveldb project welcomes contributions. leveldb's primary goal is to be
96-
a reliable and fast key/value store. Changes that are in line with the
97-
features/limitations outlined above, and meet the requirements below,
98-
will be considered.
99-
100-
Contribution requirements:
101-
102-
1. **Tested platforms only**. We _generally_ will only accept changes for
103-
platforms that are compiled and tested. This means POSIX (for Linux and
104-
macOS) or Windows. Very small changes will sometimes be accepted, but
105-
consider that more of an exception than the rule.
106-
107-
2. **Stable API**. We strive very hard to maintain a stable API. Changes that
108-
require changes for projects using leveldb _might_ be rejected without
109-
sufficient benefit to the project.
110-
111-
3. **Tests**: All changes must be accompanied by a new (or changed) test, or
112-
a sufficient explanation as to why a new (or changed) test is not required.
113-
114-
4. **Consistent Style**: This project conforms to the
115-
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
116-
To ensure your changes are properly formatted please run:
117-
118-
```
119-
clang-format -i --style=file <file>
120-
```
121-
122-
## Submitting a Pull Request
123-
124-
Before any pull request will be accepted the author must first sign a
125-
Contributor License Agreement (CLA) at https://cla.developers.google.com/.
126-
127-
In order to keep the commit timeline linear
128-
[squash](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Squashing-Commits)
129-
your changes down to a single commit and [rebase](https://git-scm.com/docs/git-rebase)
130-
on google/leveldb/master. This keeps the commit timeline linear and more easily sync'ed
131-
with the internal repository at Google. More information at GitHub's
132-
[About Git rebase](https://help.github.com/articles/about-git-rebase/) page.
133-
134-
# Performance
135-
136-
Here is a performance report (with explanations) from the run of the
137-
included db_bench program. The results are somewhat noisy, but should
138-
be enough to get a ballpark performance estimate.
139-
140-
## Setup
141-
142-
We use a database with a million entries. Each entry has a 16 byte
143-
key, and a 100 byte value. Values used by the benchmark compress to
144-
about half their original size.
145-
146-
LevelDB: version 1.1
147-
Date: Sun May 1 12:11:26 2011
148-
CPU: 4 x Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz
149-
CPUCache: 4096 KB
150-
Keys: 16 bytes each
151-
Values: 100 bytes each (50 bytes after compression)
152-
Entries: 1000000
153-
Raw Size: 110.6 MB (estimated)
154-
File Size: 62.9 MB (estimated)
155-
156-
## Write performance
157-
158-
The "fill" benchmarks create a brand new database, in either
159-
sequential, or random order. The "fillsync" benchmark flushes data
160-
from the operating system to the disk after every operation; the other
161-
write operations leave the data sitting in the operating system buffer
162-
cache for a while. The "overwrite" benchmark does random writes that
163-
update existing keys in the database.
164-
165-
fillseq : 1.765 micros/op; 62.7 MB/s
166-
fillsync : 268.409 micros/op; 0.4 MB/s (10000 ops)
167-
fillrandom : 2.460 micros/op; 45.0 MB/s
168-
overwrite : 2.380 micros/op; 46.5 MB/s
169-
170-
Each "op" above corresponds to a write of a single key/value pair.
171-
I.e., a random write benchmark goes at approximately 400,000 writes per second.
172-
173-
Each "fillsync" operation costs much less (0.3 millisecond)
174-
than a disk seek (typically 10 milliseconds). We suspect that this is
175-
because the hard disk itself is buffering the update in its memory and
176-
responding before the data has been written to the platter. This may
177-
or may not be safe based on whether or not the hard disk has enough
178-
power to save its memory in the event of a power failure.
179-
180-
## Read performance
181-
182-
We list the performance of reading sequentially in both the forward
183-
and reverse direction, and also the performance of a random lookup.
184-
Note that the database created by the benchmark is quite small.
185-
Therefore the report characterizes the performance of leveldb when the
186-
working set fits in memory. The cost of reading a piece of data that
187-
is not present in the operating system buffer cache will be dominated
188-
by the one or two disk seeks needed to fetch the data from disk.
189-
Write performance will be mostly unaffected by whether or not the
190-
working set fits in memory.
191-
192-
readrandom : 16.677 micros/op; (approximately 60,000 reads per second)
193-
readseq : 0.476 micros/op; 232.3 MB/s
194-
readreverse : 0.724 micros/op; 152.9 MB/s
195-
196-
LevelDB compacts its underlying storage data in the background to
197-
improve read performance. The results listed above were done
198-
immediately after a lot of random writes. The results after
199-
compactions (which are usually triggered automatically) are better.
200-
201-
readrandom : 11.602 micros/op; (approximately 85,000 reads per second)
202-
readseq : 0.423 micros/op; 261.8 MB/s
203-
readreverse : 0.663 micros/op; 166.9 MB/s
204-
205-
Some of the high cost of reads comes from repeated decompression of blocks
206-
read from disk. If we supply enough cache to the leveldb so it can hold the
207-
uncompressed blocks in memory, the read performance improves again:
208-
209-
readrandom : 9.775 micros/op; (approximately 100,000 reads per second before compaction)
210-
readrandom : 5.215 micros/op; (approximately 190,000 reads per second after compaction)
211-
212-
## Repository contents
213-
214-
See [doc/index.md](doc/index.md) for more explanation. See
215-
[doc/impl.md](doc/impl.md) for a brief overview of the implementation.
216-
217-
The public interface is in include/leveldb/*.h. Callers should not include or
218-
rely on the details of any other header files in this package. Those
219-
internal APIs may be changed without warning.
220-
221-
Guide to header files:
222-
223-
* **include/leveldb/db.h**: Main interface to the DB: Start here.
224-
225-
* **include/leveldb/options.h**: Control over the behavior of an entire database,
226-
and also control over the behavior of individual reads and writes.
227-
228-
* **include/leveldb/comparator.h**: Abstraction for user-specified comparison function.
229-
If you want just bytewise comparison of keys, you can use the default
230-
comparator, but clients can write their own comparator implementations if they
231-
want custom ordering (e.g. to handle different character encodings, etc.).
232-
233-
* **include/leveldb/iterator.h**: Interface for iterating over data. You can get
234-
an iterator from a DB object.
35+
* 很多接口都是提供的虚函数,用户可以根据自己的需要进行替换
23536

236-
* **include/leveldb/write_batch.h**: Interface for atomically applying multiple
237-
updates to a database.
37+
=== 限制
23838

239-
* **include/leveldb/slice.h**: A simple module for maintaining a pointer and a
240-
length into some other byte array.
39+
- 请注意,levelDB并不是一个SQL数据库,并不对外提供关系型数据模型,也不支持SQL语句,也同样不支持索引
40+
- 在多线程程序中数据库不支持并发操作,同一时间只支持一个线程进行访问
41+
- 数据库不支持cs模型,如果用户需要使用cs模型,需要用户自行进行封装。
24142

242-
* **include/leveldb/status.h**: Status is returned from many of the public interfaces
243-
and is used to report success and various kinds of errors.
24443

245-
* **include/leveldb/env.h**:
246-
Abstraction of the OS environment. A posix implementation of this interface is
247-
in util/env_posix.cc.
44+
=== 文件说明
24845

249-
* **include/leveldb/table.h, include/leveldb/table_builder.h**: Lower-level modules that most
250-
clients probably won't use directly.
46+
对外提供的文件全部都在 `include/leveldb/` 里面,用户不应该使用除了该目录之外的任何头文件
25147

48+
* **include/leveldb/db.h**: 主头文件,使用levelDB必不可少
49+
* **include/leveldb/options.h**: 数据库操作选项,用来控制整个数据库或者数据库的读写过程
50+
* **include/leveldb/comparator.h**: 比较器抽象接口,默认按照字节序进行对比,用户可以根据需要编写自己的比较器。
51+
* **include/leveldb/iterator.h**: 用于迭代数据的迭代器,该迭代器可以在DB对象中获取
52+
* **include/leveldb/write_batch.h**: 原子操作接口,用来实现数据库对事务的支持。
53+
* **include/leveldb/slice.h**: 一个数据切片的简单实现
54+
* **include/leveldb/status.h**: 状态对象,用于对外接口返回,可以通过状态查看返回状态是成功、失败或者是其他错误
55+
* **include/leveldb/env.h**: 系统环境抽象接口
56+
* **include/leveldb/table.h, include/leveldb/table_builder.h**: 数据库底层接口,大部分用户基本上用不到该功能。
25257

58+
=== 打开一个数据库
25359

254-
## Opening A Database
25560

25661
A leveldb database has a name which corresponds to a file system directory. All
25762
of the contents of database are stored in this directory. The following example

0 commit comments

Comments
 (0)