Created
November 14, 2016 02:01
-
-
Save ajkr/efe3a1efe056df66c6aa287bfbb0a0a2 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, CompactionOutputFilesExactlyFilled) { | |
+ // regression test for exactly filled compaction output files. Previously | |
+ // another file would be generated containing all range deletions, which | |
+ // could invalidate the non-overlapping file boundary invariant. | |
+ const int kNumPerFile = 4, kNumFiles = 2, kFileBytes = 9 << 10; | |
+ Options options = CurrentOptions(); | |
+ options.disable_auto_compactions = true; | |
+ options.level0_file_num_compaction_trigger = kNumFiles; | |
+ options.memtable_factory.reset(new SpecialSkipListFactory(kNumPerFile)); | |
+ options.num_levels = 2; | |
+ options.target_file_size_base = kFileBytes; | |
+ BlockBasedTableOptions table_options; | |
+ table_options.block_size_deviation = 50; // each block holds two keys | |
+ options.table_factory.reset(NewBlockBasedTableFactory(table_options)); | |
+ Reopen(options); | |
+ | |
+ // snapshot protects range tombstone from dropping due to becoming obsolete. | |
+ const Snapshot* snapshot = db_->GetSnapshot(); | |
+ db_->DeleteRange(WriteOptions(), Key(0), Key(1)); | |
+ | |
+ Random rnd(301); | |
+ for (int i = 0; i < kNumFiles; ++i) { | |
+ std::vector<std::string> values; | |
+ // Write 12K (4 values, each 3K) | |
+ for (int j = 0; j < kNumPerFile; j++) { | |
+ values.push_back(RandomString(&rnd, 3 << 10)); | |
+ ASSERT_OK(Put(Key(i * kNumPerFile + j), values[j])); | |
+ if (j == 0 && i > 0) { | |
+ dbfull()->TEST_WaitForFlushMemTable(); | |
+ } | |
+ } | |
+ } | |
+ // put extra key to trigger final flush | |
+ ASSERT_OK(Put("", "")); | |
+ dbfull()->TEST_WaitForFlushMemTable(); | |
+ ASSERT_EQ(kNumFiles, NumTableFilesAtLevel(0)); | |
+ ASSERT_EQ(0, NumTableFilesAtLevel(1)); | |
+ | |
+ dbfull()->TEST_CompactRange(0, nullptr, nullptr, nullptr, | |
+ true /* disallow_trivial_move */); | |
+ ASSERT_EQ(0, NumTableFilesAtLevel(0)); | |
+ ASSERT_EQ(2, NumTableFilesAtLevel(1)); | |
+ db_->ReleaseSnapshot(snapshot); | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment