fix some trifling points
This commit is contained in:
parent
c5d5174a66
commit
d7da5d9d35
13
doc/index.md
13
doc/index.md
@ -345,7 +345,7 @@ non-NULL, it is used to cache frequently used uncompressed block contents.
|
|||||||
#include "leveldb/cache.h"
|
#include "leveldb/cache.h"
|
||||||
|
|
||||||
leveldb::Options options;
|
leveldb::Options options;
|
||||||
options.block_cache = leveldb::NewLRUCache(100 * 1048576); // 100MB cache
|
options.block_cache = leveldb::NewLRUCache(100 * 1048576); // 100M cache capacity
|
||||||
leveldb::DB* db;
|
leveldb::DB* db;
|
||||||
leveldb::DB::Open(options, name, &db);
|
leveldb::DB::Open(options, name, &db);
|
||||||
... use the db ...
|
... use the db ...
|
||||||
@ -369,6 +369,7 @@ leveldb::Iterator* it = db->NewIterator(options);
|
|||||||
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
for (it->SeekToFirst(); it->Valid(); it->Next()) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
delete it;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Key Layout
|
### Key Layout
|
||||||
@ -424,21 +425,21 @@ spaces. For example:
|
|||||||
```c++
|
```c++
|
||||||
class CustomFilterPolicy : public leveldb::FilterPolicy {
|
class CustomFilterPolicy : public leveldb::FilterPolicy {
|
||||||
private:
|
private:
|
||||||
FilterPolicy* builtin_policy_;
|
leveldb::FilterPolicy* builtin_policy_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CustomFilterPolicy() : builtin_policy_(NewBloomFilterPolicy(10)) {}
|
CustomFilterPolicy() : builtin_policy_(leveldb::NewBloomFilterPolicy(10)) {}
|
||||||
~CustomFilterPolicy() { delete builtin_policy_; }
|
~CustomFilterPolicy() { delete builtin_policy_; }
|
||||||
|
|
||||||
const char* Name() const { return "IgnoreTrailingSpacesFilter"; }
|
const char* Name() const { return "IgnoreTrailingSpacesFilter"; }
|
||||||
|
|
||||||
void CreateFilter(const Slice* keys, int n, std::string* dst) const {
|
void CreateFilter(const leveldb::Slice* keys, int n, std::string* dst) const {
|
||||||
// Use builtin bloom filter code after removing trailing spaces
|
// Use builtin bloom filter code after removing trailing spaces
|
||||||
std::vector<Slice> trimmed(n);
|
std::vector<leveldb::Slice> trimmed(n);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
trimmed[i] = RemoveTrailingSpaces(keys[i]);
|
trimmed[i] = RemoveTrailingSpaces(keys[i]);
|
||||||
}
|
}
|
||||||
return builtin_policy_->CreateFilter(trimmed.data(), n, dst);
|
builtin_policy_->CreateFilter(trimmed.data(), n, dst);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user