Incorrect Universal Compaction reason

Summary:
While writing tests for dynamic Universal Compaction options, I found that the compaction reasons we set for size-ratio based and sorted-run based universal compactions are swapped with each other. Fixed it.
Closes https://github.com/facebook/rocksdb/pull/3412

Differential Revision: D6820540

Pulled By: sagar0

fbshipit-source-id: 270a188968ba25b2c96a8339904416c4c87ff5b3
This commit is contained in:
Sagar Vemuri 2018-01-26 11:01:54 -08:00 committed by Facebook Github Bot
parent 0e6e405fec
commit 7fcc1d0ddf
2 changed files with 3 additions and 3 deletions

View File

@ -603,9 +603,9 @@ Compaction* UniversalCompactionPicker::PickCompactionToReduceSortedRuns(
CompactionReason compaction_reason; CompactionReason compaction_reason;
if (max_number_of_files_to_compact == UINT_MAX) { if (max_number_of_files_to_compact == UINT_MAX) {
compaction_reason = CompactionReason::kUniversalSortedRunNum;
} else {
compaction_reason = CompactionReason::kUniversalSizeRatio; compaction_reason = CompactionReason::kUniversalSizeRatio;
} else {
compaction_reason = CompactionReason::kUniversalSortedRunNum;
} }
return new Compaction( return new Compaction(
vstorage, ioptions_, mutable_cf_options, std::move(inputs), output_level, vstorage, ioptions_, mutable_cf_options, std::move(inputs), output_level,

View File

@ -528,7 +528,7 @@ TEST_F(EventListenerTest, CompactionReasonUniversal) {
ASSERT_GT(listener->compaction_reasons_.size(), 0); ASSERT_GT(listener->compaction_reasons_.size(), 0);
for (auto compaction_reason : listener->compaction_reasons_) { for (auto compaction_reason : listener->compaction_reasons_) {
ASSERT_EQ(compaction_reason, CompactionReason::kUniversalSortedRunNum); ASSERT_EQ(compaction_reason, CompactionReason::kUniversalSizeRatio);
} }
options.level0_file_num_compaction_trigger = 8; options.level0_file_num_compaction_trigger = 8;