DeleteRange interface

Summary:
Expose DeleteRange() interface since we think the implementation is functionally correct now.
Closes https://github.com/facebook/rocksdb/pull/1503

Differential Revision: D4171921

Pulled By: ajkr

fbshipit-source-id: 5e21c98
This commit is contained in:
Andrew Kryczka 2016-11-15 15:06:03 -08:00 committed by Facebook Github Bot
parent eba99c28e4
commit 489d142808
3 changed files with 28 additions and 0 deletions

View File

@ -3,6 +3,7 @@
### Public API Change
* Options::max_bytes_for_level_multiplier is now a double along with all getters and setters.
* Support dynamically change `delayed_write_rate` and `max_total_wal_size` options via SetDBOptions().
* Introduce DB::DeleteRange for optimized deletion of large ranges of contiguous keys.
### New Features
* Add avoid_flush_during_shutdown option, which speeds up DB shutdown by not flushing unpersisted data (i.e. with disableWAL = true). Unpersisted data will be lost. The options is dynamically changeable via SetDBOptions().

View File

@ -5845,6 +5845,14 @@ Status DB::SingleDelete(const WriteOptions& opt,
return Write(opt, &batch);
}
Status DB::DeleteRange(const WriteOptions& opt,
ColumnFamilyHandle* column_family,
const Slice& begin_key, const Slice& end_key) {
WriteBatch batch;
batch.DeleteRange(column_family, begin_key, end_key);
return Write(opt, &batch);
}
Status DB::Merge(const WriteOptions& opt, ColumnFamilyHandle* column_family,
const Slice& key, const Slice& value) {
WriteBatch batch;

View File

@ -235,6 +235,25 @@ class DB {
return SingleDelete(options, DefaultColumnFamily(), key);
}
// Removes the database entries in the range ["begin_key", "end_key"), i.e.,
// including "begin_key" and excluding "end_key". Returns OK on success, and
// a non-OK status on error. It is not an error if no keys exist in the range
// ["begin_key", "end_key").
//
// This feature is currently an experimental performance optimization for
// deleting very large ranges of contiguous keys. Invoking it many times or on
// small ranges may severely degrade read performance; in particular, the
// resulting performance can be worse than calling Delete() for each key in
// the range. Note also the degraded read performance affects keys outside the
// deleted ranges, and affects database operations involving scans, like flush
// and compaction.
//
// Consider setting ReadOptions::ignore_range_deletions = true to speed
// up reads for key(s) that are known to be unaffected by range deletions.
virtual Status DeleteRange(const WriteOptions& options,
ColumnFamilyHandle* column_family,
const Slice& begin_key, const Slice& end_key);
// Merge the database entry for "key" with "value". Returns OK on success,
// and a non-OK status on error. The semantics of this operation is
// determined by the user provided merge_operator when opening DB.