c abi: allow compaction filter ignore snapshot (#1268)

close #1262
main
Jay 8 years ago committed by Siying Dong
parent 0b63f51fbc
commit 49d88be021
  1. 10
      db/c.cc
  2. 2
      include/rocksdb/c.h
  3. 2
      include/rocksdb/compaction_filter.h

@ -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;
}

@ -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*);

@ -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

Loading…
Cancel
Save