summaryrefslogtreecommitdiff
path: root/db/dbformat.h
diff options
context:
space:
mode:
authorSanjay Ghemawat <sanjay@google.com>2012-04-17 08:36:46 -0700
committerSanjay Ghemawat <sanjay@google.com>2012-04-17 08:36:46 -0700
commit85584d497e7b354853b72f450683d59fcf6b9c5c (patch)
treeb6aad4f973f87487c3caa5600e7596219c79f645 /db/dbformat.h
parentbc1ee4d25e09b04e074db330a41f54ef4af0e31b (diff)
downloadleveldb-85584d497e7b354853b72f450683d59fcf6b9c5c.tar.gz
Added bloom filter support.v1.4
In particular, we add a new FilterPolicy class. An instance of this class can be supplied in Options when opening a database. If supplied, the instance is used to generate summaries of keys (e.g., a bloom filter) which are placed in sstables. These summaries are consulted by DB::Get() so we can avoid reading sstable blocks that are guaranteed to not contain the key we are looking for. This change provides one implementation of FilterPolicy based on bloom filters. Other changes: - Updated version number to 1.4. - Some build tweaks. - C binding for CompactRange. - A few more benchmarks: deleteseq, deleterandom, readmissing, seekrandom. - Minor .gitignore update.
Diffstat (limited to 'db/dbformat.h')
-rw-r--r--db/dbformat.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/dbformat.h b/db/dbformat.h
index 044717d..f7f64da 100644
--- a/db/dbformat.h
+++ b/db/dbformat.h
@@ -8,6 +8,7 @@
#include <stdio.h>
#include "leveldb/comparator.h"
#include "leveldb/db.h"
+#include "leveldb/filter_policy.h"
#include "leveldb/slice.h"
#include "leveldb/table_builder.h"
#include "util/coding.h"
@@ -123,6 +124,17 @@ class InternalKeyComparator : public Comparator {
int Compare(const InternalKey& a, const InternalKey& b) const;
};
+// Filter policy wrapper that converts from internal keys to user keys
+class InternalFilterPolicy : public FilterPolicy {
+ private:
+ const FilterPolicy* const user_policy_;
+ public:
+ explicit InternalFilterPolicy(const FilterPolicy* p) : user_policy_(p) { }
+ virtual const char* Name() const;
+ virtual void CreateFilter(const Slice* keys, int n, std::string* dst) const;
+ virtual bool KeyMayMatch(const Slice& key, const Slice& filter) const;
+};
+
// Modules in this directory should keep internal keys wrapped inside
// the following class instead of plain strings so that we do not
// incorrectly use string comparisons instead of an InternalKeyComparator.