deps/rocksdb/table/table_test.cc
// This test serves as the living tutorial for the prefix scan of user collected
// properties.
This test serves as the living tutorial for the prefix scan of user collected
properties.
This test serves as the living tutorial for the prefix scan of user collected properties .
TEST_F(TablePropertyTest, PrefixScanTest) {
  UserCollectedProperties props{{"num.111.1", "1"},
                                {"num.111.2", "2"},
                                {"num.111.3", "3"},
                                {"num.333.1", "1"},
                                {"num.333.2", "2"},
                                {"num.333.3", "3"},
                                {"num.555.1", "1"},
                                {"num.555.2", "2"},
                                {"num.555.3", "3"}, };
  for (const std::string& prefix : {"num.111", "num.333", "num.555"}) {
    int num = 0;
    for (auto pos = props.lower_bound(prefix);
         pos != props.end() &&
             pos->first.compare(0, prefix.size(), prefix) == 0;
         ++pos) {
      ++num;
      auto key = prefix + "." + ToString(num);
      ASSERT_EQ(key, pos->first);
      ASSERT_EQ(ToString(num), pos->second);
    }
    ASSERT_EQ(3, num);
  }
  for (const std::string& prefix :
       {"num.000", "num.222", "num.444", "num.666"}) {
    auto pos = props.lower_bound(prefix);
    ASSERT_TRUE(pos == props.end() ||
                pos->first.compare(0, prefix.size(), prefix) != 0);
  }
}
TEST_F ( TablePropertyTest , PrefixScanTest ) { UserCollectedProperties props { { " " , " " } , { " " , " " } , { " " , " " } , { " " , " " } , { " " , " " } , { " " , " " } , { " " , " " } , { " " , " " } , { " " , " " } , } ; for ( const std :: string & prefix : { " " , " " , " " } ) { int num = 0 ; for ( auto pos = props . lower_bound ( prefix ) ; pos != props . end ( ) && pos -> first . compare ( 0 , prefix . size ( ) , prefix ) == 0 ; ++ pos ) { ++ num ; auto key = prefix + " " + ToString ( num ) ; ASSERT_EQ ( key , pos -> first ) ; ASSERT_EQ ( ToString ( num ) , pos -> second ) ; } ASSERT_EQ ( 3 , num ) ; } for ( const std :: string & prefix : { " " , " " , " " , " " } ) { auto pos = props . lower_bound ( prefix ) ; ASSERT_TRUE ( pos == props . end ( ) || pos -> first . compare ( 0 , prefix . size ( ) , prefix ) != 0 ) ; } }
This test serves as the living tutorial for the prefix scan of user collected
properties.
This test serves as the living tutorial for the prefix scan of user collected properties .
// prefixes that exist // prefixes that don't exist