@@ -10733,6 +10733,42 @@ TEST_F(DBCompactionTest, RecordNewestKeyTimeForTtlCompaction) {
10733
10733
ASSERT_OK (dbfull ()->TEST_WaitForCompact ());
10734
10734
ASSERT_EQ (NumTableFilesAtLevel (0 ), 0 );
10735
10735
}
10736
+
10737
+ TEST_F (DBCompactionTest, RecordNumberCompactionInputIterators) {
10738
+ Options options;
10739
+ SetTimeElapseOnlySleepOnReopen (&options);
10740
+ options.env = CurrentOptions ().env ;
10741
+ options.compaction_style = kCompactionStyleFIFO ;
10742
+ options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics ();
10743
+ options.write_buffer_size = 10 << 10 ; // 10KB
10744
+ options.arena_block_size = 4096 ;
10745
+ options.compression = kNoCompression ;
10746
+ options.create_if_missing = true ;
10747
+ options.compaction_options_fifo .allow_compaction = true ;
10748
+ options.num_levels = 1 ;
10749
+ env_->SetMockSleep ();
10750
+ options.env = env_;
10751
+ options.ttl = 1 * 60 * 60 ; // 1 hour
10752
+ ASSERT_OK (TryReopen (options));
10753
+
10754
+ // Generate and flush 4 files, each about 10KB
10755
+ Random rnd (301 );
10756
+ for (int i = 0 ; i < 4 ; i++) {
10757
+ for (int j = 0 ; j < 10 ; j++) {
10758
+ ASSERT_OK (Put (std::to_string (i * 20 + j), rnd.RandomString (980 )));
10759
+ }
10760
+ ASSERT_OK (Flush ());
10761
+ env_->MockSleepForSeconds (5 );
10762
+ }
10763
+ ASSERT_OK (dbfull ()->TEST_WaitForCompact ());
10764
+ ASSERT_EQ (NumTableFilesAtLevel (0 ), 1 );
10765
+ HistogramData num_compaction_input_iterators;
10766
+ options.statistics ->histogramData (NUM_COMPACTION_INPUT_ITERATORS,
10767
+ &num_compaction_input_iterators);
10768
+ ASSERT_EQ (num_compaction_input_iterators.sum , 4 );
10769
+
10770
+ ASSERT_OK (options.statistics ->Reset ());
10771
+ }
10736
10772
} // namespace ROCKSDB_NAMESPACE
10737
10773
10738
10774
int main (int argc, char ** argv) {
0 commit comments