diff --git a/db/c.cc b/db/c.cc index 05802aa21..35114406b 100644 --- a/db/c.cc +++ b/db/c.cc @@ -123,6 +123,7 @@ struct rocksdb_compactionfilter_t : public CompactionFilter { char** new_value, size_t *new_value_length, unsigned char* value_changed); const char* (*name_)(void*); + unsigned char ignore_snapshots_; virtual ~rocksdb_compactionfilter_t() { (*destructor_)(state_); @@ -148,6 +149,8 @@ struct rocksdb_compactionfilter_t : public CompactionFilter { } virtual const char* Name() const override { return (*name_)(state_); } + + virtual bool IgnoreSnapshots() const override { return ignore_snapshots_; } }; struct rocksdb_compactionfilterfactory_t : public CompactionFilterFactory { @@ -1919,10 +1922,17 @@ rocksdb_compactionfilter_t* rocksdb_compactionfilter_create( result->state_ = state; result->destructor_ = destructor; result->filter_ = filter; + result->ignore_snapshots_ = false; result->name_ = name; return result; } +void rocksdb_compactionfilter_set_ignore_snapshots( + rocksdb_compactionfilter_t* filter, + unsigned char whether_ignore) { + filter->ignore_snapshots_ = whether_ignore; +} + void rocksdb_compactionfilter_destroy(rocksdb_compactionfilter_t* filter) { delete filter; } diff --git a/include/rocksdb/c.h b/include/rocksdb/c.h index e269aa9b4..1cc09dbeb 100644 --- a/include/rocksdb/c.h +++ b/include/rocksdb/c.h @@ -729,6 +729,8 @@ rocksdb_compactionfilter_create( size_t* new_value_length, unsigned char* value_changed), const char* (*name)(void*)); +extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilter_set_ignore_snapshots( + rocksdb_compactionfilter_t*, unsigned char); extern ROCKSDB_LIBRARY_API void rocksdb_compactionfilter_destroy( rocksdb_compactionfilter_t*); diff --git a/include/rocksdb/compaction_filter.h b/include/rocksdb/compaction_filter.h index acdc3aa1b..d32f37b26 100644 --- a/include/rocksdb/compaction_filter.h +++ b/include/rocksdb/compaction_filter.h @@ -106,7 +106,7 @@ class CompactionFilter { // By default, compaction will only call Filter() on keys written after the // most recent call to GetSnapshot(). However, if the compaction filter - // overrides IgnoreSnapshots to make it return false, the compaction filter + // overrides IgnoreSnapshots to make it return true, the compaction filter // will be called even if the keys were written before the last snapshot. // This behavior is to be used only when we want to delete a set of keys // irrespective of snapshots. In particular, care should be taken