Skip to content

Commit 5e6aee4

Browse files
author
Lei Jin
committed
dont create backup_input if compaction filter v2 is not used
Summary: Compaction creates backup_input iterator even though it only needed when compaction filter v2 is enabled Test Plan: make all check Reviewers: sdong, yhchiang, igor Reviewed By: igor Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D23769
1 parent 49b5f94 commit 5e6aee4

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

db/db_impl.cc

+24-26
Original file line numberDiff line numberDiff line change
@@ -3117,9 +3117,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
31173117
const uint64_t start_micros = env_->NowMicros();
31183118
unique_ptr<Iterator> input(versions_->MakeInputIterator(compact->compaction));
31193119
input->SeekToFirst();
3120-
shared_ptr<Iterator> backup_input(
3121-
versions_->MakeInputIterator(compact->compaction));
3122-
backup_input->SeekToFirst();
31233120

31243121
Status status;
31253122
ParsedInternalKey ikey;
@@ -3132,14 +3129,30 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
31323129
auto compaction_filter_v2 =
31333130
compaction_filter_from_factory_v2.get();
31343131

3135-
// temp_backup_input always point to the start of the current buffer
3136-
// temp_backup_input = backup_input;
3137-
// iterate through input,
3138-
// 1) buffer ineligible keys and value keys into 2 separate buffers;
3139-
// 2) send value_buffer to compaction filter and alternate the values;
3140-
// 3) merge value_buffer with ineligible_value_buffer;
3141-
// 4) run the modified "compaction" using the old for loop.
3142-
if (compaction_filter_v2) {
3132+
if (!compaction_filter_v2) {
3133+
status = ProcessKeyValueCompaction(
3134+
is_snapshot_supported,
3135+
visible_at_tip,
3136+
earliest_snapshot,
3137+
latest_snapshot,
3138+
deletion_state,
3139+
bottommost_level,
3140+
imm_micros,
3141+
input.get(),
3142+
compact,
3143+
false,
3144+
log_buffer);
3145+
} else {
3146+
// temp_backup_input always point to the start of the current buffer
3147+
// temp_backup_input = backup_input;
3148+
// iterate through input,
3149+
// 1) buffer ineligible keys and value keys into 2 separate buffers;
3150+
// 2) send value_buffer to compaction filter and alternate the values;
3151+
// 3) merge value_buffer with ineligible_value_buffer;
3152+
// 4) run the modified "compaction" using the old for loop.
3153+
shared_ptr<Iterator> backup_input(
3154+
versions_->MakeInputIterator(compact->compaction));
3155+
backup_input->SeekToFirst();
31433156
while (backup_input->Valid() && !shutting_down_.Acquire_Load() &&
31443157
!cfd->IsDropped()) {
31453158
// FLUSH preempts compaction
@@ -3267,21 +3280,6 @@ Status DBImpl::DoCompactionWork(CompactionState* compact,
32673280
log_buffer);
32683281
} // checking for compaction filter v2
32693282

3270-
if (!compaction_filter_v2) {
3271-
status = ProcessKeyValueCompaction(
3272-
is_snapshot_supported,
3273-
visible_at_tip,
3274-
earliest_snapshot,
3275-
latest_snapshot,
3276-
deletion_state,
3277-
bottommost_level,
3278-
imm_micros,
3279-
input.get(),
3280-
compact,
3281-
false,
3282-
log_buffer);
3283-
}
3284-
32853283
if (status.ok() && (shutting_down_.Acquire_Load() || cfd->IsDropped())) {
32863284
status = Status::ShutdownInProgress(
32873285
"Database shutdown or Column family drop during compaction");

0 commit comments

Comments
 (0)