deps/rocksdb/table/table_test.cc
// It's very hard to figure out the index block size of a block accurately.
// To make sure we get the index size, we just make sure as key number
// grows, the filter block size also grows.
It's very hard to figure out the index block size of a block accurately.
To make sure we get the index size, we just make sure as key number
grows, the filter block size also grows.
It ' s very hard to figure out the index block size of a block accurately . To make sure we get the index size we just make sure as key number grows the filter block size also grows .
TEST_P(BlockBasedTableTest, IndexSizeStat) {
  uint64_t last_index_size = 0;
  Random rnd(test::RandomSeed());
  std::vector<std::string> keys;
  for (int i = 0; i < 100; ++i) {
    keys.push_back(RandomString(&rnd, 10000));
  }
  for (size_t i = 1; i < keys.size(); ++i) {
    TableConstructor c(BytewiseComparator(),
                       true );
    for (size_t j = 0; j < i; ++j) {
      c.Add(keys[j], "val");
    }
    std::vector<std::string> ks;
    stl_wrappers::KVMap kvmap;
    Options options;
    options.compression = kNoCompression;
    BlockBasedTableOptions table_options = GetBlockBasedTableOptions();
    table_options.block_restart_interval = 1;
    options.table_factory.reset(NewBlockBasedTableFactory(table_options));
    const ImmutableCFOptions ioptions(options);
    const MutableCFOptions moptions(options);
    c.Finish(options, ioptions, moptions, table_options,
             GetPlainInternalComparator(options.comparator), &ks, &kvmap);
    auto index_size = c.GetTableReader()->GetTableProperties()->index_size;
    ASSERT_GT(index_size, last_index_size);
    last_index_size = index_size;
    c.ResetTableReader();
  }
}
TEST_P ( BlockBasedTableTest , IndexSizeStat ) { uint64_t last_index_size = 0 ; Random rnd ( test :: RandomSeed ( ) ) ; std :: vector < std :: string > keys ; for ( int i = 0 ; i < 100 ; ++ i ) { keys . push_back ( RandomString ( & rnd , 10000 ) ) ; } for ( size_t i = 1 ; i < keys . size ( ) ; ++ i ) { TableConstructor c ( BytewiseComparator ( ) , true ) ; for ( size_t j = 0 ; j < i ; ++ j ) { c . Add ( keys [ j ] , " " ) ; } std :: vector < std :: string > ks ; stl_wrappers :: KVMap kvmap ; Options options ; options . compression = kNoCompression ; BlockBasedTableOptions table_options = GetBlockBasedTableOptions ( ) ; table_options . block_restart_interval = 1 ; options . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; const ImmutableCFOptions ioptions ( options ) ; const MutableCFOptions moptions ( options ) ; c . Finish ( options , ioptions , moptions , table_options , GetPlainInternalComparator ( options . comparator ) , & ks , & kvmap ) ; auto index_size = c . GetTableReader ( ) -> GetTableProperties ( ) -> index_size ; ASSERT_GT ( index_size , last_index_size ) ; last_index_size = index_size ; c . ResetTableReader ( ) ; } }
It's very hard to figure out the index block size of a block accurately.
It ' s very hard to figure out the index block size of a block accurately .
// we need to use random keys since the pure human readable texts // may be well compressed, resulting insignifcant change of index // block size. // Each time we load one more key to the table. the table index block // size is expected to be larger than last time's. /* convert_to_internal_key_ */