3rdParty/rocksdb/6.8/table/table_test.cc
// This test include all the basic checks except those for index size and block
// size, which will be conducted in separated unit tests.
This test include all the basic checks except those for index size and block
size, which will be conducted in separated unit tests.
This test include all the basic checks except those for index size and block size which will be conducted in separated unit tests .
TEST_P(BlockBasedTableTest, BasicBlockBasedTableProperties) {
  TableConstructor c(BytewiseComparator(), true );
  c.Add("a1", "val1");
  c.Add("b2", "val2");
  c.Add("c3", "val3");
  c.Add("d4", "val4");
  c.Add("e5", "val5");
  c.Add("f6", "val6");
  c.Add("g7", "val7");
  c.Add("h8", "val8");
  c.Add("j9", "val9");
  uint64_t diff_internal_user_bytes = 9 * 8;  
  std::vector<std::string> keys;
  stl_wrappers::KVMap kvmap;
  Options options;
  options.compression = kNoCompression;
  options.statistics = CreateDBStatistics();
  options.statistics->set_stats_level(StatsLevel::kAll);
  BlockBasedTableOptions table_options = GetBlockBasedTableOptions();
  table_options.block_restart_interval = 1;
  options.table_factory.reset(NewBlockBasedTableFactory(table_options));
  ImmutableCFOptions ioptions(options);
  MutableCFOptions moptions(options);
  ioptions.statistics = options.statistics.get();
  c.Finish(options, ioptions, moptions, table_options,
           GetPlainInternalComparator(options.comparator), &keys, &kvmap);
  ASSERT_EQ(options.statistics->getTickerCount(NUMBER_BLOCK_NOT_COMPRESSED), 0);
  auto& props = *c.GetTableReader()->GetTableProperties();
  ASSERT_EQ(kvmap.size(), props.num_entries);
  auto raw_key_size = kvmap.size() * 2ul;
  auto raw_value_size = kvmap.size() * 4ul;
  ASSERT_EQ(raw_key_size + diff_internal_user_bytes, props.raw_key_size);
  ASSERT_EQ(raw_value_size, props.raw_value_size);
  ASSERT_EQ(1ul, props.num_data_blocks);
  ASSERT_EQ("", props.filter_policy_name);  
  BlockBuilder block_builder(1);
  for (const auto& item : kvmap) {
    block_builder.Add(item.first, item.second);
  }
  Slice content = block_builder.Finish();
  ASSERT_EQ(content.size() + kBlockTrailerSize + diff_internal_user_bytes,
            props.data_size);
  c.ResetTableReader();
}
TEST_P ( BlockBasedTableTest , BasicBlockBasedTableProperties ) { TableConstructor c ( BytewiseComparator ( ) , true ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; uint64_t diff_internal_user_bytes = 9 * 8 ; std :: vector < std :: string > keys ; stl_wrappers :: KVMap kvmap ; Options options ; options . compression = kNoCompression ; options . statistics = CreateDBStatistics ( ) ; options . statistics -> set_stats_level ( StatsLevel :: kAll ) ; BlockBasedTableOptions table_options = GetBlockBasedTableOptions ( ) ; table_options . block_restart_interval = 1 ; options . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; ImmutableCFOptions ioptions ( options ) ; MutableCFOptions moptions ( options ) ; ioptions . statistics = options . statistics . get ( ) ; c . Finish ( options , ioptions , moptions , table_options , GetPlainInternalComparator ( options . comparator ) , & keys , & kvmap ) ; ASSERT_EQ ( options . statistics -> getTickerCount ( NUMBER_BLOCK_NOT_COMPRESSED ) , 0 ) ; auto & props = * c . GetTableReader ( ) -> GetTableProperties ( ) ; ASSERT_EQ ( kvmap . size ( ) , props . num_entries ) ; auto raw_key_size = kvmap . size ( ) * 2ul ; auto raw_value_size = kvmap . size ( ) * 4ul ; ASSERT_EQ ( raw_key_size + diff_internal_user_bytes , props . raw_key_size ) ; ASSERT_EQ ( raw_value_size , props . raw_value_size ) ; ASSERT_EQ ( 1ul , props . num_data_blocks ) ; ASSERT_EQ ( " " , props . filter_policy_name ) ; BlockBuilder block_builder ( 1 ) ; for ( const auto & item : kvmap ) { block_builder . Add ( item . first , item . second ) ; } Slice content = block_builder . Finish ( ) ; ASSERT_EQ ( content . size ( ) + kBlockTrailerSize + diff_internal_user_bytes , props . data_size ) ; c . ResetTableReader ( ) ; }
This test include all the basic checks except those for index size and block
size, which will be conducted in separated unit tests.
This test include all the basic checks except those for index size and block size which will be conducted in separated unit tests .
/* convert_to_internal_key_ */ // 8 is seq size, 9 k-v totally // no filter policy is used // Verify data size.