Created
November 13, 2016 23:51
-
-
Save ajkr/5a62af77c4ebe4052a1955c496d51fdb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+TEST_F(DBRangeDelTest, ValidUniversalSubcompactionBoundaries) { | |
+ const int kNumPerFile = 100, kFilesPerLevel = 4, kNumLevels = 4; | |
+ Options options = CurrentOptions(); | |
+ options.compaction_options_universal.min_merge_width = kFilesPerLevel; | |
+ options.compaction_options_universal.max_merge_width = kFilesPerLevel; | |
+ options.compaction_options_universal.size_ratio = 10; | |
+ options.compaction_style = kCompactionStyleUniversal; | |
+ options.level0_file_num_compaction_trigger = kFilesPerLevel; | |
+ options.max_subcompactions = 4; | |
+ options.memtable_factory.reset(new SpecialSkipListFactory(kNumPerFile)); | |
+ options.num_levels = kNumLevels; | |
+ options.target_file_size_base = kNumPerFile << 10; | |
+ options.target_file_size_multiplier = 1; | |
+ Reopen(options); | |
+ | |
+ Random rnd(301); | |
+ for (int i = 0; i < kNumLevels - 1; ++i) { | |
+ for (int j = 0; j < kFilesPerLevel; ++j) { | |
+ if (i == kNumLevels - 2) { | |
+ // insert range deletions [95,105) in two files, [295,305) in next two | |
+ // to prepare L1 for later manual compaction. | |
+ int mid = (j + (1 - j % 2)) * kNumPerFile; | |
+ db_->DeleteRange(WriteOptions(), Key(mid - 5), Key(mid + 5)); | |
+ } | |
+ std::vector<std::string> values; | |
+ // Write 100KB (100 values, each 1K) | |
+ for (int k = 0; k < kNumPerFile; k++) { | |
+ values.push_back(RandomString(&rnd, 990)); | |
+ ASSERT_OK(Put(Key(j * kNumPerFile + k), values[k])); | |
+ } | |
+ // put extra key to trigger flush | |
+ ASSERT_OK(Put("", "")); | |
+ dbfull()->TEST_WaitForFlushMemTable(); | |
+ ASSERT_EQ(NumTableFilesAtLevel(0), j + 1); | |
+ } | |
+ dbfull()->TEST_WaitForCompact(); | |
+ ASSERT_EQ(NumTableFilesAtLevel(0), 0); | |
+ ASSERT_GT(NumTableFilesAtLevel(kNumLevels - 1 - i), kFilesPerLevel - 1); | |
+ } | |
+ // Now L1-L3 are full, when we compact L1->L2 we should see (1) subcompactions | |
+ // happen since input level > 0; (2) range deletions are not dropped since | |
+ // output level is not bottommost. If no file boundary assertion fails, that | |
+ // probably means universal compaction + subcompaction + range deletion are | |
+ // compatible. | |
+ ASSERT_OK(dbfull()->RunManualCompaction( | |
+ reinterpret_cast<ColumnFamilyHandleImpl*>(db_->DefaultColumnFamily()) | |
+ ->cfd(), | |
+ 1 /* input_level */, 2 /* output_level */, 0 /* output_path_id */, | |
+ nullptr /* begin */, nullptr /* end */, true /* exclusive */, | |
+ true /* disallow_trivial_move */)); | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment