deps/rocksdb/table/table_test.cc
// Make sure, by default, index/filter blocks were pre-loaded (meaning we won't
// use block cache to store them).
Make sure, by default, index/filter blocks were pre-loaded (meaning we won't
use block cache to store them).
Make sure by default index / filter blocks were pre - loaded ( meaning we won ' t use block cache to store them ) .
TEST_P(BlockBasedTableTest, BlockCacheDisabledTest) {
  Options options;
  options.create_if_missing = true;
  options.statistics = CreateDBStatistics();
  BlockBasedTableOptions table_options = GetBlockBasedTableOptions();
  table_options.block_cache = NewLRUCache(1024, 4);
  table_options.filter_policy.reset(NewBloomFilterPolicy(10));
  options.table_factory.reset(new BlockBasedTableFactory(table_options));
  std::vector<std::string> keys;
  stl_wrappers::KVMap kvmap;
  TableConstructor c(BytewiseComparator(), true );
  c.Add("key", "value");
  const ImmutableCFOptions ioptions(options);
  const MutableCFOptions moptions(options);
  c.Finish(options, ioptions, moptions, table_options,
           GetPlainInternalComparator(options.comparator), &keys, &kvmap);
  auto reader = dynamic_cast<BlockBasedTable*>(c.GetTableReader());
  ASSERT_TRUE(reader->TEST_filter_block_preloaded());
  ASSERT_FALSE(reader->TEST_IndexBlockInCache());
  {
    BlockCachePropertiesSnapshot props(options.statistics.get());
    props.AssertIndexBlockStat(0, 0);
    props.AssertFilterBlockStat(0, 0);
  }
  {
    GetContext get_context(options.comparator, nullptr, nullptr, nullptr,
                           GetContext::kNotFound, Slice(), nullptr, nullptr,
                           nullptr, nullptr, nullptr);
    reader->Get(ReadOptions(), "non-exist-key", &get_context,
                moptions.prefix_extractor.get());
    BlockCachePropertiesSnapshot props(options.statistics.get());
    props.AssertIndexBlockStat(0, 0);
    props.AssertFilterBlockStat(0, 0);
  }
}
TEST_P ( BlockBasedTableTest , BlockCacheDisabledTest ) { Options options ; options . create_if_missing = true ; options . statistics = CreateDBStatistics ( ) ; BlockBasedTableOptions table_options = GetBlockBasedTableOptions ( ) ; table_options . block_cache = NewLRUCache ( 1024 , 4 ) ; table_options . filter_policy . reset ( NewBloomFilterPolicy ( 10 ) ) ; options . table_factory . reset ( new BlockBasedTableFactory ( table_options ) ) ; std :: vector < std :: string > keys ; stl_wrappers :: KVMap kvmap ; TableConstructor c ( BytewiseComparator ( ) , true ) ; c . Add ( " " , " " ) ; const ImmutableCFOptions ioptions ( options ) ; const MutableCFOptions moptions ( options ) ; c . Finish ( options , ioptions , moptions , table_options , GetPlainInternalComparator ( options . comparator ) , & keys , & kvmap ) ; auto reader = dynamic_cast < BlockBasedTable * > ( c . GetTableReader ( ) ) ; ASSERT_TRUE ( reader -> TEST_filter_block_preloaded ( ) ) ; ASSERT_FALSE ( reader -> TEST_IndexBlockInCache ( ) ) ; { BlockCachePropertiesSnapshot props ( options . statistics . get ( ) ) ; props . AssertIndexBlockStat ( 0 , 0 ) ; props . AssertFilterBlockStat ( 0 , 0 ) ; } { GetContext get_context ( options . comparator , nullptr , nullptr , nullptr , GetContext :: kNotFound , Slice ( ) , nullptr , nullptr , nullptr , nullptr , nullptr ) ; reader -> Get ( ReadOptions ( ) , " " , & get_context , moptions . prefix_extractor . get ( ) ) ; BlockCachePropertiesSnapshot props ( options . statistics . get ( ) ) ; props . AssertIndexBlockStat ( 0 , 0 ) ; props . AssertFilterBlockStat ( 0 , 0 ) ; } }
Make sure, by default, index/filter blocks were pre-loaded (meaning we won't
use block cache to store them).
Make sure by default index / filter blocks were pre - loaded ( meaning we won ' t use block cache to store them ) .
/* convert_to_internal_key_ */ // preloading filter/index blocks is enabled. // nothing happens in the beginning // a hack that just to trigger BlockBasedTable::GetFilter.