Skip to content

Commit

Permalink
fix rangedelete error
Browse files Browse the repository at this point in the history
  • Loading branch information
Or Friedmann committed Feb 7, 2024
1 parent 80e4140 commit eca6858
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions db/db_impl/db_impl_write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ bool DBImpl::DeleteRangeSeek(const WriteOptions& options,
std::cout << "missed seq" << std::endl;
return false;
}
std::cout << "begin_key: " << begin_key.ToString(true) << " end_key: " << end_key.ToString(true) << " end key size: " << end_key.size() << std::endl;
auto cfh = GetColumnFamilyHandle(column_family->GetID());
Status s = DeleteRange(options, cfh, begin_key, end_key);
assert(s.ok());
Expand Down
6 changes: 4 additions & 2 deletions db/db_iter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1511,8 +1511,10 @@ void DBIter::Seek(const Slice& target) {
}
PERF_COUNTER_ADD(iter_read_bytes, key().size() + value().size());
if(able_to_optimize && cfd_->is_delete_range_supported()) {
if(target != iter_.key() && (num_internal_keys_skipped_ + local_stats_.skip_count_) > 1) {
able_to_optimize = db_impl_->DeleteRangeSeek(WriteOptions(), cfd_, target, iter_.key(), sequence_);
ParsedInternalKey ikey;
bool check = ParseKey(&ikey);
if(check && target != ikey.user_key && (num_internal_keys_skipped_ + local_stats_.skip_count_) > 1) {
able_to_optimize = db_impl_->DeleteRangeSeek(WriteOptions(), cfd_, target, ikey.user_key, sequence_);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions examples/simple_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ int main() {
}
printf ("insert completed %lu micros\n", clock->NowMicros() - t);
t = clock->NowMicros();
// disable the auto compaction
options.disable_auto_compactions=true;

// now the delete (10% we delete using a normal delete)
for (uint32_t i = 0; i < prime/10 ; ++i) {
Expand All @@ -81,8 +79,12 @@ int main() {
for (size_t i = 0; i < 10000 ; i++) {
auto iter = db->NewIterator(ReadOptions());
iter->Seek(std::string((char *)&key, 8));
if(!iter->Valid()) {
printf("Invalid\n");
}
delete iter;
}

printf("time to get 10000 keys after delete is %lu micros\n", clock->NowMicros() - t);
t = clock->NowMicros();

Expand Down
5 changes: 4 additions & 1 deletion table/merging_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1039,15 +1039,18 @@ bool MergingIterator::SkipNextDeleted() {
// range tombstone is from the same level as current, check sequence
// number. By `active_` we know current key is between start key and end
// key.
// Enter here!
assert(comparator_->Compare(range_tombstone_iters_[i]->start_key(),
pik) <= 0);
assert(comparator_->Compare(pik, range_tombstone_iters_[i]->end_key()) <
0);
if (pik.sequence < range_tombstone_iters_[current->level]->seq()) {
// covered by range tombstone
// Enter here!
current->iter.Next();
// Invariant (children_)
if (current->iter.Valid()) {
if (false && current->iter.Valid()) {
// Enter here!
minHeap_.replace_top(current);
} else {
considerStatus(current->iter.status());
Expand Down

0 comments on commit eca6858

Please sign in to comment.