|
|
|
@ -5891,12 +5891,82 @@ TEST_F(DBTest2, BottommostTemperature) { |
|
|
|
|
ASSERT_OK(Flush()); |
|
|
|
|
ASSERT_OK(dbfull()->TEST_WaitForCompact()); |
|
|
|
|
|
|
|
|
|
ColumnFamilyMetaData metadata; |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
ASSERT_EQ(1, metadata.file_count); |
|
|
|
|
ASSERT_EQ(Temperature::kWarm, metadata.levels[1].files[0].temperature); |
|
|
|
|
|
|
|
|
|
// non-bottommost file still has unknown temperature
|
|
|
|
|
ASSERT_OK(Put("foo", "bar")); |
|
|
|
|
ASSERT_OK(Put("bar", "bar")); |
|
|
|
|
ASSERT_OK(Flush()); |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
ASSERT_EQ(2, metadata.file_count); |
|
|
|
|
ASSERT_EQ(Temperature::kUnknown, metadata.levels[0].files[0].temperature); |
|
|
|
|
|
|
|
|
|
// reopen and check the information is persisted
|
|
|
|
|
Reopen(options); |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
ASSERT_EQ(2, metadata.file_count); |
|
|
|
|
ASSERT_EQ(Temperature::kUnknown, metadata.levels[0].files[0].temperature); |
|
|
|
|
ASSERT_EQ(Temperature::kWarm, metadata.levels[1].files[0].temperature); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_F(DBTest2, BottommostTemperatureUniversal) { |
|
|
|
|
const int kTriggerNum = 3; |
|
|
|
|
const int kNumLevels = 5; |
|
|
|
|
const int kBottommostLevel = kNumLevels - 1; |
|
|
|
|
Options options = CurrentOptions(); |
|
|
|
|
options.compaction_style = kCompactionStyleUniversal; |
|
|
|
|
options.level0_file_num_compaction_trigger = kTriggerNum; |
|
|
|
|
options.num_levels = kNumLevels; |
|
|
|
|
|
|
|
|
|
DestroyAndReopen(options); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < kTriggerNum; i++) { |
|
|
|
|
ASSERT_OK(Put("foo", "bar")); |
|
|
|
|
ASSERT_OK(Put("bar", "bar")); |
|
|
|
|
ASSERT_OK(Flush()); |
|
|
|
|
} |
|
|
|
|
ASSERT_OK(dbfull()->TEST_WaitForCompact()); |
|
|
|
|
|
|
|
|
|
ColumnFamilyMetaData metadata; |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
ASSERT_EQ(1, metadata.file_count); |
|
|
|
|
ASSERT_EQ(Temperature::kWarm, metadata.levels[1].files[0].temperature); |
|
|
|
|
ASSERT_EQ(Temperature::kUnknown, |
|
|
|
|
metadata.levels[kBottommostLevel].files[0].temperature); |
|
|
|
|
|
|
|
|
|
ASSERT_OK(Put("foo", "bar")); |
|
|
|
|
ASSERT_OK(Put("bar", "bar")); |
|
|
|
|
ASSERT_OK(Flush()); |
|
|
|
|
ASSERT_OK(dbfull()->TEST_WaitForCompact()); |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
ASSERT_EQ(2, metadata.file_count); |
|
|
|
|
ASSERT_EQ(Temperature::kUnknown, metadata.levels[0].files[0].temperature); |
|
|
|
|
|
|
|
|
|
// Update bottommost temperature
|
|
|
|
|
options.bottommost_temperature = Temperature::kWarm; |
|
|
|
|
Reopen(options); |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
// Should not impact existing ones
|
|
|
|
|
ASSERT_EQ(Temperature::kUnknown, |
|
|
|
|
metadata.levels[kBottommostLevel].files[0].temperature); |
|
|
|
|
|
|
|
|
|
// new generated file should have the new settings
|
|
|
|
|
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr)); |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
ASSERT_EQ(1, metadata.file_count); |
|
|
|
|
ASSERT_EQ(Temperature::kWarm, |
|
|
|
|
metadata.levels[kBottommostLevel].files[0].temperature); |
|
|
|
|
|
|
|
|
|
// non-bottommost file still has unknown temperature
|
|
|
|
|
ASSERT_OK(Put("foo", "bar")); |
|
|
|
|
ASSERT_OK(Put("bar", "bar")); |
|
|
|
|
ASSERT_OK(Flush()); |
|
|
|
|
ASSERT_OK(dbfull()->TEST_WaitForCompact()); |
|
|
|
|
db_->GetColumnFamilyMetaData(&metadata); |
|
|
|
|
ASSERT_EQ(2, metadata.file_count); |
|
|
|
|
ASSERT_EQ(Temperature::kUnknown, metadata.levels[0].files[0].temperature); |
|
|
|
|
} |
|
|
|
|
#endif // ROCKSDB_LITE
|
|
|
|
|
|
|
|
|
|