@@ -465,6 +465,85 @@ TEST_F(ExternalSSTFileTest, ParallelFileOpenWithFileOpeningThreads) {
465465 }
466466}
467467
468+ TEST_F (ExternalSSTFileTest, LmaxPrefetchSkipDoesNotDisableL0Prefetch) {
469+ LRUCacheOptions co;
470+ co.capacity = 32 << 20 ;
471+ std::shared_ptr<Cache> cache = NewLRUCache (co);
472+ BlockBasedTableOptions table_options;
473+ table_options.block_cache = cache;
474+ table_options.cache_index_and_filter_blocks = true ;
475+ table_options.filter_policy .reset (NewBloomFilterPolicy (10 ));
476+
477+ Options options = CurrentOptions ();
478+ options.disable_auto_compactions = true ;
479+ options.max_open_files = -1 ;
480+ options.num_levels = 2 ;
481+ options.optimize_filters_for_hits = false ;
482+ options.statistics = CreateDBStatistics ();
483+ options.table_factory .reset (NewBlockBasedTableFactory (table_options));
484+ DestroyAndReopen (options);
485+
486+ const auto write_file = [&](const std::string& file_path,
487+ const std::string& value,
488+ ExternalSstFileInfo* file_info) {
489+ SstFileWriter writer (EnvOptions (), options);
490+ ASSERT_OK (writer.Open (file_path));
491+ ASSERT_OK (writer.Put (Key (10 ), value));
492+ ASSERT_OK (writer.Finish (file_info));
493+ };
494+
495+ const auto ingest_file = [&](const std::string& file_path,
496+ const ExternalSstFileInfo& file_info,
497+ bool fail_if_not_bottommost_level) {
498+ IngestExternalFileArg arg;
499+ arg.column_family = db_->DefaultColumnFamily ();
500+ arg.external_files = {file_path};
501+ arg.file_infos = {file_info.prepared_file_info .get ()};
502+ arg.options .fail_if_not_bottommost_level = fail_if_not_bottommost_level;
503+ arg.options .verify_checksums_before_ingest = false ;
504+ arg.options .prefetch_lmax_index_and_filter_blocks = false ;
505+ ASSERT_OK (db_->IngestExternalFiles ({arg}));
506+ };
507+
508+ const std::string lmax_file_path = sst_files_dir_ + " lazy_lmax.sst" ;
509+ ExternalSstFileInfo lmax_file_info;
510+ write_file (lmax_file_path, " v10" , &lmax_file_info);
511+
512+ ASSERT_EQ (0 , options.statistics ->getAndResetTickerCount (
513+ Tickers::BLOCK_CACHE_INDEX_ADD ));
514+ ASSERT_EQ (0 , options.statistics ->getAndResetTickerCount (
515+ Tickers::BLOCK_CACHE_FILTER_ADD ));
516+
517+ ingest_file (lmax_file_path, lmax_file_info,
518+ true /* fail_if_not_bottommost_level */ );
519+ ASSERT_EQ (" 0,1" , FilesPerLevel ());
520+
521+ ASSERT_EQ (0 , options.statistics ->getAndResetTickerCount (
522+ Tickers::BLOCK_CACHE_INDEX_ADD ));
523+ ASSERT_EQ (0 , options.statistics ->getAndResetTickerCount (
524+ Tickers::BLOCK_CACHE_FILTER_ADD ));
525+
526+ const std::string l0_file_path = sst_files_dir_ + " l0.sst" ;
527+ ExternalSstFileInfo l0_file_info;
528+ write_file (l0_file_path, " v11" , &l0_file_info);
529+
530+ ASSERT_EQ (0 , options.statistics ->getAndResetTickerCount (
531+ Tickers::BLOCK_CACHE_INDEX_ADD ));
532+ ASSERT_EQ (0 , options.statistics ->getAndResetTickerCount (
533+ Tickers::BLOCK_CACHE_FILTER_ADD ));
534+
535+ ingest_file (l0_file_path, l0_file_info,
536+ false /* fail_if_not_bottommost_level */ );
537+ ASSERT_EQ (" 1,1" , FilesPerLevel ());
538+
539+ EXPECT_GT (options.statistics ->getAndResetTickerCount (
540+ Tickers::BLOCK_CACHE_INDEX_ADD ),
541+ 0 );
542+ EXPECT_GT (options.statistics ->getAndResetTickerCount (
543+ Tickers::BLOCK_CACHE_FILTER_ADD ),
544+ 0 );
545+ }
546+
468547TEST_F (ExternalSSTFileTest, AbortPreparedIngestion) {
469548 Options options = CurrentOptions ();
470549 DestroyAndReopen (options);
0 commit comments