const size_t kNumBlocks = 5;
const size_t kValueSize = 1000;
- SimCacheTest() : DBTestBase("/sim_cache_test") {}
+ SimCacheTest() : DBTestBase("/sim_cache_test", /*env_do_fsync=*/true) {}
BlockBasedTableOptions GetTableOptions() {
BlockBasedTableOptions table_options;
options.create_if_missing = true;
// options.compression = kNoCompression;
options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
- options.table_factory.reset(new BlockBasedTableFactory(table_options));
+ options.table_factory.reset(NewBlockBasedTableFactory(table_options));
return options;
}
co.metadata_charge_policy = kDontChargeCacheMetadata;
std::shared_ptr<SimCache> simCache = NewSimCache(NewLRUCache(co), 20000, 0);
table_options.block_cache = simCache;
- options.table_factory.reset(new BlockBasedTableFactory(table_options));
+ options.table_factory.reset(NewBlockBasedTableFactory(table_options));
Reopen(options);
RecordCacheCounters(options);
co.metadata_charge_policy = kDontChargeCacheMetadata;
std::shared_ptr<SimCache> sim_cache = NewSimCache(NewLRUCache(co), 20000, 0);
table_options.block_cache = sim_cache;
- options.table_factory.reset(new BlockBasedTableFactory(table_options));
+ options.table_factory.reset(NewBlockBasedTableFactory(table_options));
Reopen(options);
int num_block_entries = 20;
for (int i = 0; i < num_block_entries; i++) {
- Put(Key(i), "val");
- Flush();
+ ASSERT_OK(Put(Key(i), "val"));
+ ASSERT_OK(Flush());
}
std::string log_file = test::PerThreadDBPath(env_, "cache_log.txt");
ASSERT_OK(sim_cache->GetActivityLoggingStatus());
std::string file_contents = "";
- ReadFileToString(env_, log_file, &file_contents);
+ ASSERT_OK(ReadFileToString(env_, log_file, &file_contents));
int lookup_num = 0;
int add_num = 0;
ASSERT_EQ(add_num, num_block_entries);
// Log things again but stop logging automatically after reaching 512 bytes
- // @lint-ignore TXT2 T25377293 Grandfathered in
- int max_size = 512;
+ int max_size = 512;
ASSERT_OK(sim_cache->StartActivityLogging(log_file, env_, max_size));
for (int it = 0; it < 10; it++) {
for (int i = 0; i < num_block_entries; i++) {
uint64_t fsize = 0;
ASSERT_OK(env_->GetFileSize(log_file, &fsize));
- // error margin of 100 bytes
+ // error margin of 100 bytes
ASSERT_LT(fsize, max_size + 100);
- ASSERT_GT(fsize, max_size - 100);
+ ASSERT_GT(fsize, max_size - 100);
}
} // namespace ROCKSDB_NAMESPACE