@@ -77,9 +77,12 @@ int RocksDBFeature::initialize(std::string const& path) {
77
77
rocksdb::BlockBasedTableOptions tableOptions;
78
78
tableOptions.cache_index_and_filter_blocks = true ;
79
79
tableOptions.filter_policy .reset (rocksdb::NewBloomFilterPolicy (12 , false ));
80
-
81
- _options.prefix_extractor .reset (rocksdb::NewFixedPrefixTransform (RocksDBIndex::minimalPrefixSize ()));
82
- _options.table_factory .reset (rocksdb::NewBlockBasedTableFactory (tableOptions));
80
+
81
+ // TODO: using the prefix extractor will lead to the comparator being
82
+ // called with just the key prefix (which the comparator currently cannot handle)
83
+ // _options.prefix_extractor.reset(rocksdb::NewFixedPrefixTransform(RocksDBIndex::minimalPrefixSize()));
84
+ // _options.table_factory.reset(rocksdb::NewBlockBasedTableFactory(tableOptions));
85
+
83
86
_options.create_if_missing = true ;
84
87
_options.max_open_files = -1 ;
85
88
_options.comparator = _comparator;
@@ -199,14 +202,23 @@ int RocksDBFeature::dropPrefix(std::string const& prefix) {
199
202
// go on and delete the remaining keys (delete files in range does not necessarily
200
203
// find them all, just complete files
201
204
205
+ auto comparator = RocksDBFeature::instance ()->comparator ();
202
206
rocksdb::DB* db = _db->GetBaseDB ();
203
207
204
208
rocksdb::WriteBatch batch;
205
209
206
210
std::unique_ptr<rocksdb::Iterator> it (db->NewIterator (rocksdb::ReadOptions ()));
207
211
212
+ it->Seek (lower);
208
213
while (it->Valid ()) {
209
214
batch.Delete (it->key ());
215
+
216
+ int res = comparator->Compare (it->key (), upper);
217
+
218
+ if (res >= 0 ) {
219
+ break ;
220
+ }
221
+
210
222
it->Next ();
211
223
}
212
224
0 commit comments