From 5b197bff41f14a0f34b5305e9014e8a80443ed95 Mon Sep 17 00:00:00 2001 From: krad Date: Tue, 7 Jun 2016 16:07:30 -0700 Subject: [PATCH] Enabled Windows build for volatile tier implementation Summary: Enabled build in Windows and corresponding fixes Test Plan: Compile and run persistent_cache_test in Windows and make check in Linux Reviewers: sdong Subscribers: andrewkr, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D59307 --- CMakeLists.txt | 2 ++ .../persistent_cache/persistent_cache_test.h | 4 ++-- .../persistent_cache/volatile_tier_impl.cc | 21 +++++++++++-------- .../persistent_cache/volatile_tier_impl.h | 5 +++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b49a88be3..80cab6f91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,6 +266,7 @@ set(SOURCES utilities/merge_operators/uint64add.cc utilities/options/options_util.cc utilities/persistent_cache/persistent_cache_tier.cc + utilities/persistent_cache/volatile_tier_impl.cc utilities/redis/redis_lists.cc utilities/spatialdb/spatial_db.cc utilities/table_properties_collectors/compact_on_deletion_collector.cc @@ -429,6 +430,7 @@ set(TESTS utilities/merge_operators/string_append/stringappend_test.cc utilities/options/options_util_test.cc utilities/persistent_cache/hash_table_test.cc + utilities/persistent_cache/persistent_cache_test.cc utilities/redis/redis_lists_test.cc utilities/spatialdb/spatial_db_test.cc utilities/table_properties_collectors/compact_on_deletion_collector_test.cc diff --git a/utilities/persistent_cache/persistent_cache_test.h b/utilities/persistent_cache/persistent_cache_test.h index 4659b728c..cf97796d6 100644 --- a/utilities/persistent_cache/persistent_cache_test.h +++ b/utilities/persistent_cache/persistent_cache_test.h @@ -135,7 +135,7 @@ class PersistentCacheTierTest : public testing::Test { auto k = prefix + PaddedNumber(i, /*count=*/8); Slice key(k); while (!cache_->Insert(key, data, sizeof(data)).ok()) { - /* sleep override */ sleep(1); + Env::Default()->SleepForMicroseconds(1 * 1000 * 1000); } } } @@ -230,7 +230,7 @@ class PersistentCacheDBTest : public DBTestBase { return std::make_shared(); } - static uint32_t TestGetTickerCount(const Options& options, + static uint64_t TestGetTickerCount(const Options& options, Tickers ticker_type) { return static_cast( options.statistics->getTickerCount(ticker_type)); diff --git a/utilities/persistent_cache/volatile_tier_impl.cc b/utilities/persistent_cache/volatile_tier_impl.cc index 5bc6fe9b4..aca9fcaf5 100644 --- a/utilities/persistent_cache/volatile_tier_impl.cc +++ b/utilities/persistent_cache/volatile_tier_impl.cc @@ -20,15 +20,18 @@ VolatileCacheTier::~VolatileCacheTier() { index_.Clear(&DeleteCacheData); } std::vector VolatileCacheTier::Stats() { PersistentCacheTier::TierStats stat; - stat.insert({"persistent_cache.volatile_cache.hits", stats_.cache_hits_}); - stat.insert({"persistent_cache.volatile_cache.misses", stats_.cache_misses_}); - stat.insert( - {"persistent_cache.volatile_cache.inserts", stats_.cache_inserts_}); - stat.insert({"persistent_cache.volatile_cache.evicts", stats_.cache_evicts_}); - stat.insert( - {"persistent_cache.volatile_cache.hit_pct", stats_.CacheHitPct()}); - stat.insert( - {"persistent_cache.volatile_cache.miss_pct", stats_.CacheMissPct()}); + stat.insert({"persistent_cache.volatile_cache.hits", + static_cast(stats_.cache_hits_)}); + stat.insert({"persistent_cache.volatile_cache.misses", + static_cast(stats_.cache_misses_)}); + stat.insert({"persistent_cache.volatile_cache.inserts", + static_cast(stats_.cache_inserts_)}); + stat.insert({"persistent_cache.volatile_cache.evicts", + static_cast(stats_.cache_evicts_)}); + stat.insert({"persistent_cache.volatile_cache.hit_pct", + static_cast(stats_.CacheHitPct())}); + stat.insert({"persistent_cache.volatile_cache.miss_pct", + static_cast(stats_.CacheMissPct())}); std::vector tier_stats; if (next_tier()) { diff --git a/utilities/persistent_cache/volatile_tier_impl.h b/utilities/persistent_cache/volatile_tier_impl.h index fbd63a0d0..a29c4ac30 100644 --- a/utilities/persistent_cache/volatile_tier_impl.h +++ b/utilities/persistent_cache/volatile_tier_impl.h @@ -73,8 +73,9 @@ class VolatileCacheTier : public PersistentCacheTier { // Cache data abstraction // struct CacheData : LRUElement { - explicit CacheData(CacheData&& rhs) noexcept - : key(std::move(rhs.key)), value(std::move(rhs.value)) {} + explicit CacheData(CacheData&& rhs) ROCKSDB_NOEXCEPT + : key(std::move(rhs.key)), + value(std::move(rhs.value)) {} explicit CacheData(const std::string& _key, const std::string& _value = "") : key(_key), value(_value) {}