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_F(BlockBasedTableTest, BasicBlockBasedTableProperties) {
  TableConstructor c(BytewiseComparator());
  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");
  std::vector<std::string> keys;
  KVMap kvmap;
  Options options;
  options.compression = kNoCompression;
  BlockBasedTableOptions table_options;
  table_options.block_restart_interval = 1;
  options.table_factory.reset(NewBlockBasedTableFactory(table_options));
  const ImmutableCFOptions ioptions(options);
  c.Finish(options, ioptions, table_options,
           GetPlainInternalComparator(options.comparator), &keys, &kvmap);
  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, 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, props.data_size);
}
TEST_F ( BlockBasedTableTest , BasicBlockBasedTableProperties ) { TableConstructor c ( BytewiseComparator ( ) ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; std :: vector < std :: string > keys ; KVMap kvmap ; Options options ; options . compression = kNoCompression ; BlockBasedTableOptions table_options ; table_options . block_restart_interval = 1 ; options . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; const ImmutableCFOptions ioptions ( options ) ; c . Finish ( options , ioptions , table_options , GetPlainInternalComparator ( options . comparator ) , & keys , & kvmap ) ; 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 , 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 , props . data_size ) ; }
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 .
// no filter policy is used // Verify data size.