8000 fixes · lethalbrains/arangodb@f347483 · GitHub
[go: up one dir, main page]

Skip to content

Commit f347483

Browse files
committed
fixes
1 parent b26aa2a commit f347483

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

arangod/Indexes/RocksDBFeature.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ int RocksDBFeature::initialize(std::string const& path) {
7777
rocksdb::BlockBasedTableOptions tableOptions;
7878
tableOptions.cache_index_and_filter_blocks = true;
7979
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+
8386
_options.create_if_missing = true;
8487
_options.max_open_files = -1;
8588
_options.comparator = _comparator;
@@ -199,14 +202,23 @@ int RocksDBFeature::dropPrefix(std::string const& prefix) {
199202
// go on and delete the remaining keys (delete files in range does not necessarily
200203
// find them all, just complete files
201204

205+
auto comparator = RocksDBFeature::instance()->comparator();
202206
rocksdb::DB* db = _db->GetBaseDB();
203207

204208
rocksdb::WriteBatch batch;
205209

206210
std::unique_ptr<rocksdb::Iterator> it(db->NewIterator(rocksdb::ReadOptions()));
207211

212+
it->Seek(lower);
208213
while (it->Valid()) {
209214
batch.Delete(it->key());
215+
216+
int res = comparator->Compare(it->key(), upper);
217+
218+
if (res >= 0) {
219+
break;
220+
}
221+
210222
it->Next();
211223
}
212224

arangod/Indexes/RocksDBIndex.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ RocksDBIterator::RocksDBIterator(arangodb::Transaction* trx,
9494

9595
TRI_idx_iid_t const id = index->id();
9696
std::string const prefix = RocksDBIndex::buildPrefix(trx->vocbase()->_id, _primaryIndex->collection()->_info.id(), id);
97+
TRI_ASSERT(prefix.size() == RocksDBIndex::keyPrefixSize());
9798

9899
_leftEndpoint.reset(new arangodb::velocypack::Buffer<char>());
99100
_leftEndpoint->reserve(RocksDBIndex::keyPrefixSize() + left.byteSize());
@@ -104,6 +105,9 @@ RocksDBIterator::RocksDBIterator(arangodb::Transaction* trx,
104105
_rightEndpoint->reserve(RocksDBIndex::keyPrefixSize() + right.byteSize());
105106
_rightEndpoint->append(prefix.c_str(), prefix.size());
106107
_rightEndpoint->append(right.startAs<char const>(), right.byteSize());
108+
109+
TRI_ASSERT(_leftEndpoint->size() > 8);
110+
TRI_ASSERT(_rightEndpoint->size() > 8);
107111

108112
// LOG(TRACE) << "iterator left key: " << left.toJson();
109113
// LOG(TRACE) << "iterator right key: " << right.toJson();
3610

0 commit comments

Comments
 (0)
0