|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| benchmarks/ | H | 25-Apr-2025 | - | 2,350 | 1,893 |
| cmake/ | H | 25-Apr-2025 | - | 9 | 6 |
| db/ | H | 25-Apr-2025 | - | 13,964 | 10,639 |
| doc/ | H | 25-Apr-2025 | - | 1,341 | 1,099 |
| helpers/memenv/ | H | 25-Apr-2025 | - | 679 | 504 |
| include/leveldb/ | H | 25-Apr-2025 | - | 1,972 | 807 |
| issues/ | H | 25-Apr-2025 | - | 283 | 201 |
| port/ | H | 25-Apr-2025 | - | 426 | 262 |
| table/ | H | 25-Apr-2025 | - | 3,005 | 2,255 |
| util/ | H | 25-Apr-2025 | - | 6,049 | 4,412 |
| AUTHORS | H A D | 25-Apr-2025 | 293 | 13 | 9 |
| Android.bp | H A D | 25-Apr-2025 | 3.7 KiB | 140 | 134 |
| CMakeLists.txt | H A D | 25-Apr-2025 | 15.2 KiB | 496 | 436 |
| CONTRIBUTING.md | H A D | 25-Apr-2025 | 1.6 KiB | 37 | 27 |
| LICENSE | H A D | 25-Apr-2025 | 1.4 KiB | 28 | 24 |
| METADATA | H A D | 25-Apr-2025 | 434 | 19 | 17 |
| MODULE_LICENSE_BSD | HD | 25-Apr-2025 | 1 | | |
| NEWS | H A D | 25-Apr-2025 | 509 | 18 | 12 |
| OWNERS | H A D | 25-Apr-2025 | 71 | 3 | 1 |
| README.md | H A D | 25-Apr-2025 | 9.3 KiB | 232 | 167 |
| TEST_MAPPING | H A D | 25-Apr-2025 | 305 | 18 | 17 |
| TODO | H A D | 25-Apr-2025 | 535 | 15 | 12 |
README.md
1**LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.**
2
3[](https://travis-ci.org/google/leveldb)
4[](https://ci.appveyor.com/project/pwnall/leveldb)
5
6Authors: Sanjay Ghemawat ([email protected]) and Jeff Dean ([email protected])
7
8# Features
9
10 * Keys and values are arbitrary byte arrays.
11 * Data is stored sorted by key.
12 * Callers can provide a custom comparison function to override the sort order.
13 * The basic operations are `Put(key,value)`, `Get(key)`, `Delete(key)`.
14 * Multiple changes can be made in one atomic batch.
15 * Users can create a transient snapshot to get a consistent view of data.
16 * Forward and backward iteration is supported over the data.
17 * Data is automatically compressed using the [Snappy compression library](https://google.github.io/snappy/).
18 * External activity (file system operations etc.) is relayed through a virtual interface so users can customize the operating system interactions.
19
20# Documentation
21
22 [LevelDB library documentation](https://github.com/google/leveldb/blob/master/doc/index.md) is online and bundled with the source code.
23
24# Limitations
25
26 * 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.
27 * Only a single process (possibly multi-threaded) can access a particular database at a time.
28 * 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.
29
30# Getting the Source
31
32```bash
33git clone --recurse-submodules https://github.com/google/leveldb.git
34```
35
36# Building
37
38This project supports [CMake](https://cmake.org/) out of the box.
39
40### Build for POSIX
41
42Quick start:
43
44```bash
45mkdir -p build && cd build
46cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .
47```
48
49### Building for Windows
50
51First generate the Visual Studio 2017 project/solution files:
52
53```cmd
54mkdir build
55cd build
56cmake -G "Visual Studio 15" ..
57```
58The default default will build for x86. For 64-bit run:
59
60```cmd
61cmake -G "Visual Studio 15 Win64" ..
62```
63
64To compile the Windows solution from the command-line:
65
66```cmd
67devenv /build Debug leveldb.sln
68```
69
70or open leveldb.sln in Visual Studio and build from within.
71
72Please see the CMake documentation and `CMakeLists.txt` for more advanced usage.
73
74# Contributing to the leveldb Project
75
76The leveldb project welcomes contributions. leveldb's primary goal is to be
77a reliable and fast key/value store. Changes that are in line with the
78features/limitations outlined above, and meet the requirements below,
79will be considered.
80
81Contribution requirements:
82
831. **Tested platforms only**. We _generally_ will only accept changes for
84 platforms that are compiled and tested. This means POSIX (for Linux and
85 macOS) or Windows. Very small changes will sometimes be accepted, but
86 consider that more of an exception than the rule.
87
882. **Stable API**. We strive very hard to maintain a stable API. Changes that
89 require changes for projects using leveldb _might_ be rejected without
90 sufficient benefit to the project.
91
923. **Tests**: All changes must be accompanied by a new (or changed) test, or
93 a sufficient explanation as to why a new (or changed) test is not required.
94
954. **Consistent Style**: This project conforms to the
96 [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
97 To ensure your changes are properly formatted please run:
98
99 ```
100 clang-format -i --style=file <file>
101 ```
102
103## Submitting a Pull Request
104
105Before any pull request will be accepted the author must first sign a
106Contributor License Agreement (CLA) at https://cla.developers.google.com/.
107
108In order to keep the commit timeline linear
109[squash](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Squashing-Commits)
110your changes down to a single commit and [rebase](https://git-scm.com/docs/git-rebase)
111on google/leveldb/master. This keeps the commit timeline linear and more easily sync'ed
112with the internal repository at Google. More information at GitHub's
113[About Git rebase](https://help.github.com/articles/about-git-rebase/) page.
114
115# Performance
116
117Here is a performance report (with explanations) from the run of the
118included db_bench program. The results are somewhat noisy, but should
119be enough to get a ballpark performance estimate.
120
121## Setup
122
123We use a database with a million entries. Each entry has a 16 byte
124key, and a 100 byte value. Values used by the benchmark compress to
125about half their original size.
126
127 LevelDB: version 1.1
128 Date: Sun May 1 12:11:26 2011
129 CPU: 4 x Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz
130 CPUCache: 4096 KB
131 Keys: 16 bytes each
132 Values: 100 bytes each (50 bytes after compression)
133 Entries: 1000000
134 Raw Size: 110.6 MB (estimated)
135 File Size: 62.9 MB (estimated)
136
137## Write performance
138
139The "fill" benchmarks create a brand new database, in either
140sequential, or random order. The "fillsync" benchmark flushes data
141from the operating system to the disk after every operation; the other
142write operations leave the data sitting in the operating system buffer
143cache for a while. The "overwrite" benchmark does random writes that
144update existing keys in the database.
145
146 fillseq : 1.765 micros/op; 62.7 MB/s
147 fillsync : 268.409 micros/op; 0.4 MB/s (10000 ops)
148 fillrandom : 2.460 micros/op; 45.0 MB/s
149 overwrite : 2.380 micros/op; 46.5 MB/s
150
151Each "op" above corresponds to a write of a single key/value pair.
152I.e., a random write benchmark goes at approximately 400,000 writes per second.
153
154Each "fillsync" operation costs much less (0.3 millisecond)
155than a disk seek (typically 10 milliseconds). We suspect that this is
156because the hard disk itself is buffering the update in its memory and
157responding before the data has been written to the platter. This may
158or may not be safe based on whether or not the hard disk has enough
159power to save its memory in the event of a power failure.
160
161## Read performance
162
163We list the performance of reading sequentially in both the forward
164and reverse direction, and also the performance of a random lookup.
165Note that the database created by the benchmark is quite small.
166Therefore the report characterizes the performance of leveldb when the
167working set fits in memory. The cost of reading a piece of data that
168is not present in the operating system buffer cache will be dominated
169by the one or two disk seeks needed to fetch the data from disk.
170Write performance will be mostly unaffected by whether or not the
171working set fits in memory.
172
173 readrandom : 16.677 micros/op; (approximately 60,000 reads per second)
174 readseq : 0.476 micros/op; 232.3 MB/s
175 readreverse : 0.724 micros/op; 152.9 MB/s
176
177LevelDB compacts its underlying storage data in the background to
178improve read performance. The results listed above were done
179immediately after a lot of random writes. The results after
180compactions (which are usually triggered automatically) are better.
181
182 readrandom : 11.602 micros/op; (approximately 85,000 reads per second)
183 readseq : 0.423 micros/op; 261.8 MB/s
184 readreverse : 0.663 micros/op; 166.9 MB/s
185
186Some of the high cost of reads comes from repeated decompression of blocks
187read from disk. If we supply enough cache to the leveldb so it can hold the
188uncompressed blocks in memory, the read performance improves again:
189
190 readrandom : 9.775 micros/op; (approximately 100,000 reads per second before compaction)
191 readrandom : 5.215 micros/op; (approximately 190,000 reads per second after compaction)
192
193## Repository contents
194
195See [doc/index.md](doc/index.md) for more explanation. See
196[doc/impl.md](doc/impl.md) for a brief overview of the implementation.
197
198The public interface is in include/leveldb/*.h. Callers should not include or
199rely on the details of any other header files in this package. Those
200internal APIs may be changed without warning.
201
202Guide to header files:
203
204* **include/leveldb/db.h**: Main interface to the DB: Start here.
205
206* **include/leveldb/options.h**: Control over the behavior of an entire database,
207and also control over the behavior of individual reads and writes.
208
209* **include/leveldb/comparator.h**: Abstraction for user-specified comparison function.
210If you want just bytewise comparison of keys, you can use the default
211comparator, but clients can write their own comparator implementations if they
212want custom ordering (e.g. to handle different character encodings, etc.).
213
214* **include/leveldb/iterator.h**: Interface for iterating over data. You can get
215an iterator from a DB object.
216
217* **include/leveldb/write_batch.h**: Interface for atomically applying multiple
218updates to a database.
219
220* **include/leveldb/slice.h**: A simple module for maintaining a pointer and a
221length into some other byte array.
222
223* **include/leveldb/status.h**: Status is returned from many of the public interfaces
224and is used to report success and various kinds of errors.
225
226* **include/leveldb/env.h**:
227Abstraction of the OS environment. A posix implementation of this interface is
228in util/env_posix.cc.
229
230* **include/leveldb/table.h, include/leveldb/table_builder.h**: Lower-level modules that most
231clients probably won't use directly.
232