1414 * limitations under the License.
1515 */
1616
17+ #include < fmt/format.h>
1718#include < folly/Random.h>
1819#include < gtest/gtest.h>
1920
@@ -195,7 +196,7 @@ TEST_F(NvmCacheTest, EvictToNvmGet) {
195196 const int nKeys = 1024 ;
196197
197198 for (unsigned int i = 0 ; i < nKeys; i++) {
198- auto key = folly::sformat (" key{}" , i);
199+ auto key = fmt::format (" key{}" , i);
199200 auto it = nvm.allocate (pid, key, 15 * 1024 );
200201 ASSERT_NE (nullptr , it);
201202 nvm.insertOrReplace (it);
@@ -221,7 +222,7 @@ TEST_F(NvmCacheTest, EvictToNvmGet) {
221222 // reading items from navy.
222223 for (unsigned int i = nKeys + 100 ; i-- > 0 ;) {
223224 unsigned int index = i;
224- auto key = folly::sformat (" key{}" , index);
225+ auto key = fmt::format (" key{}" , index);
225226 auto hdl = this ->fetch (key, false /* ramOnly */ );
226227 hdl.wait ();
227228 if (index < nKeys) {
@@ -234,14 +235,14 @@ TEST_F(NvmCacheTest, EvictToNvmGet) {
234235 // associated with it on the local thread. It is adjusted at destruction
235236 // time to be net-zero for handle count (first an Inc, and then a Dec).
236237 EXPECT_EQ (0 , nvm.getHandleCountForThread ())
237- << folly::sformat (" key: {} was read from Navy" , key);
238+ << fmt::format (" key: {} was read from Navy" , key);
238239 ASSERT_TRUE (isClean);
239240 ASSERT_TRUE (hdl.wentToNvm ());
240241 } else {
241242 // A handle read from ram-cache will have incremented the thread-local
242243 // handle count when we have acquired the handle.
243244 EXPECT_EQ (1 , nvm.getHandleCountForThread ())
244- << folly::sformat (" key: {} was read from RAM cache" , key);
245+ << fmt::format (" key: {} was read from RAM cache" , key);
245246 ASSERT_FALSE (isClean);
246247 }
247248 } else {
@@ -1922,7 +1923,7 @@ TEST_F(NvmCacheTest, NavyStats) {
19221923TEST_F (NvmCacheTest, Raid0Basic) {
19231924 auto & config = getConfig ();
19241925 auto & navyConfig = config.nvmConfig ->navyConfig ;
1925- auto filePath = folly::sformat (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
1926+ auto filePath = fmt::format (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
19261927 util::makeDir (filePath);
19271928 SCOPE_EXIT { util::removePath (filePath); };
19281929
@@ -1988,7 +1989,7 @@ TEST_F(NvmCacheTest, Raid0Basic) {
19881989TEST_F (NvmCacheTest, Raid0OrderChange) {
19891990 auto & config = getConfig ();
19901991 auto & navyConfig = config.nvmConfig ->navyConfig ;
1991- auto filePath = folly::sformat (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
1992+ auto filePath = fmt::format (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
19921993 util::makeDir (filePath);
19931994 SCOPE_EXIT { util::removePath (filePath); };
19941995
@@ -2001,7 +2002,7 @@ TEST_F(NvmCacheTest, Raid0OrderChange) {
20012002 // that everything is correct.
20022003 std::string val = " foobar" ;
20032004 int nKeys = 100 ;
2004- auto makeKey = [&](int i) { return folly::sformat (" blah-{}" , i); };
2005+ auto makeKey = [&](int i) { return fmt::format (" blah-{}" , i); };
20052006
20062007 this ->convertToShmCache ();
20072008 {
@@ -2062,7 +2063,7 @@ TEST_F(NvmCacheTest, Raid0OrderChange) {
20622063TEST_F (NvmCacheTest, Raid0NumFilesChange) {
20632064 auto & config = getConfig ();
20642065 auto & navyConfig = config.nvmConfig ->navyConfig ;
2065- auto filePath = folly::sformat (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
2066+ auto filePath = fmt::format (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
20662067 util::makeDir (filePath);
20672068 SCOPE_EXIT { util::removePath (filePath); };
20682069
@@ -2075,7 +2076,7 @@ TEST_F(NvmCacheTest, Raid0NumFilesChange) {
20752076 // that everything is correct.
20762077 std::string val = " foobar" ;
20772078 int nKeys = 100 ;
2078- auto makeKey = [&](int i) { return folly::sformat (" blah-{}" , i); };
2079+ auto makeKey = [&](int i) { return fmt::format (" blah-{}" , i); };
20792080
20802081 this ->convertToShmCache ();
20812082 {
@@ -2135,7 +2136,7 @@ TEST_F(NvmCacheTest, Raid0NumFilesChange) {
21352136TEST_F (NvmCacheTest, Raid0SizeChange) {
21362137 auto & config = getConfig ();
21372138 auto & navyConfig = config.nvmConfig ->navyConfig ;
2138- auto filePath = folly::sformat (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
2139+ auto filePath = fmt::format (" /tmp/nvmcache-navy-raid0/{}" , ::getpid ());
21392140 util::makeDir (filePath);
21402141 SCOPE_EXIT { util::removePath (filePath); };
21412142 std::vector<std::string> vec = {filePath + " /CACHE0" , filePath + " /CACHE1" ,
@@ -2147,7 +2148,7 @@ TEST_F(NvmCacheTest, Raid0SizeChange) {
21472148 // that everything is correct.
21482149 std::string val = " foobar" ;
21492150 int nKeys = 100 ;
2150- auto makeKey = [&](int i) { return folly::sformat (" blah-{}" , i); };
2151+ auto makeKey = [&](int i) { return fmt::format (" blah-{}" , i); };
21512152
21522153 this ->convertToShmCache ();
21532154 {
@@ -2473,7 +2474,7 @@ TEST_F(NvmCacheTest, testSampleItem) {
24732474 // Insert items until either RAM or NVM cache is full
24742475 for (; numEvicted == 0 && nKeys < numMax; nKeys++) {
24752476 unsigned ttl = nKeys % 2 == 0 ? kEvenKeyTTL : 0 ;
2476- auto key = folly::sformat (" key{}" , nKeys);
2477+ auto key = fmt::format (" key{}" , nKeys);
24772478 // the pool's allocsize is
24782479 auto it = cache.allocate (pid, key, 16 * 1024 , ttl);
24792480 ASSERT_NE (nullptr , it);
@@ -3033,7 +3034,7 @@ TEST_F(NvmCacheTest, AccessTimeMapPopulatedOnDramEviction) {
30333034 auto now = util::getCurrentTimeSec ();
30343035 int populated = 0 ;
30353036 for (int i = 0 ; i < nKeys; i++) {
3036- auto key = folly::sformat (" atm_multi_{}" , i);
3037+ auto key = fmt::format (" atm_multi_{}" , i);
30373038 HashedKey hk{key};
30383039 auto ts = atm->get (hk.keyHash ());
30393040 if (ts != std::nullopt ) {
@@ -3067,7 +3068,7 @@ TEST_F(NvmCacheTest, AccessTimeMapNotUpdatedForBigHashItems) {
30673068 // bit is not set for BigHash items, preventing updateAccessTime().
30683069 auto * atm = this ->getAccessTimeMap ();
30693070 for (int i = 0 ; i < nKeys; i++) {
3070- auto key = folly::sformat (" bh_{}" , i);
3071+ auto key = fmt::format (" bh_{}" , i);
30713072 HashedKey hk{key};
30723073 auto ts = atm->get (hk.keyHash ());
30733074 EXPECT_EQ (std::nullopt , ts)
@@ -3090,7 +3091,7 @@ TEST_F(NvmCacheTest, AccessTimeMapNotUpdatedOnRegularEviction) {
30903091 // Evictions of these items go through the NVM put path, not
30913092 // the updateAccessTime path.
30923093 for (int i = 0 ; i < 1024 ; i++) {
3093- auto key = folly::sformat (" regular_{}" , i);
3094+ auto key = fmt::format (" regular_{}" , i);
30943095 auto it = nvm.allocate (pid, key, allocSize);
30953096 ASSERT_NE (nullptr , it);
30963097 cache_->insertOrReplace (it);
@@ -3140,7 +3141,7 @@ TEST_F(NvmCacheTest, AccessTimeMapCleanupTest) {
31403141 constexpr int kNumGroups = 4 ;
31413142 std::array<std::vector<std::string>, kNumGroups > groups;
31423143 for (int i = 0 ; i < nKeys; i++) {
3143- auto key = folly::sformat (" atm_cl_{}" , i);
3144+ auto key = fmt::format (" atm_cl_{}" , i);
31443145 HashedKey hk{key};
31453146 if (atm->get (hk.keyHash ()) != std::nullopt ) {
31463147 groups[i % kNumGroups ].push_back (key);
@@ -3183,7 +3184,7 @@ TEST_F(NvmCacheTest, AccessTimeMapCleanupTest) {
31833184 const uint32_t numKeysPerRegion =
31843185 config_.blockCache ().getRegionSize () / allocSize;
31853186 for (int i = 0 ; i < 2048 ; i++) {
3186- auto key = folly::sformat (" nvm_evictor_{}" , i);
3187+ auto key = fmt::format (" nvm_evictor_{}" , i);
31873188 auto it = nvm.allocate (pid, key, allocSize);
31883189 ASSERT_NE (nullptr , it);
31893190 cache_->insertOrReplace (it);
@@ -3234,7 +3235,7 @@ TEST_F(NvmCacheTest, AccessTimeMapSurvivesWarmRoll) {
32343235 auto timeBefore = util::getCurrentTimeSec ();
32353236 auto evictBefore = this ->evictionCount ();
32363237 for (int i = 0 ; i < 1024 ; i++) {
3237- auto key = folly::sformat (" atm_warm_roll_filler_{}" , i);
3238+ auto key = fmt::format (" atm_warm_roll_filler_{}" , i);
32383239 auto it = nvm.allocate (pid, key, allocSize);
32393240 ASSERT_NE (nullptr , it);
32403241 cache_->insertOrReplace (it);
0 commit comments