From 1cac89c9b1931a3f37608305cbd0dd8cc2841f14 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Thu, 20 Aug 2015 14:08:24 -0700 Subject: [PATCH] Address windows build issues Intro SubCompactionState move functionality =delete copy functionality #ifdef SyncPoint in tests for Windows Release builds --- db/compaction_job.cc | 31 ++++++++++++++++++++++++++++-- db/db_compaction_test.cc | 9 +++++---- db/db_universal_compaction_test.cc | 7 ++----- db/fault_injection_test.cc | 8 ++++++++ 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/db/compaction_job.cc b/db/compaction_job.cc index cad3f1bb3..7a5752cb7 100644 --- a/db/compaction_job.cc +++ b/db/compaction_job.cc @@ -59,7 +59,7 @@ namespace rocksdb { // Maintains state for each sub-compaction struct CompactionJob::SubCompactionState { - Compaction* const compaction; + Compaction* compaction; // The boundaries of the key-range this compaction is interested in. No two // subcompactions may have overlapping key-ranges. @@ -113,7 +113,7 @@ struct CompactionJob::SubCompactionState { // is in or beyond the last file checked during the previous call std::vector level_ptrs; - explicit SubCompactionState(Compaction* c, Slice* _start, Slice* _end, + SubCompactionState(Compaction* c, Slice* _start, Slice* _end, SequenceNumber earliest, SequenceNumber visible, SequenceNumber latest) : compaction(c), @@ -130,6 +130,33 @@ struct CompactionJob::SubCompactionState { assert(compaction != nullptr); level_ptrs = std::vector(compaction->number_levels(), 0); } + + SubCompactionState(SubCompactionState&& o) { + *this = std::move(o); + } + + SubCompactionState& operator=(SubCompactionState&& o) { + compaction = std::move(o.compaction); + start = std::move(o.start); + end = std::move(o.end); + status = std::move(o.status); + outputs = std::move(o.outputs); + outfile = std::move(o.outfile); + builder = std::move(o.builder); + total_bytes = std::move(o.total_bytes); + num_input_records = std::move(o.num_input_records); + num_output_records = std::move(o.num_output_records); + earliest_snapshot = std::move(o.earliest_snapshot); + visible_at_tip = std::move(o.visible_at_tip); + latest_snapshot = std::move(o.latest_snapshot); + level_ptrs = std::move(o.level_ptrs); + return *this; + } + + // Because member unique_ptrs do not have these. + SubCompactionState(const SubCompactionState&) = delete; + + SubCompactionState& operator=(const SubCompactionState&) = delete; }; // Maintains state for the entire compaction diff --git a/db/db_compaction_test.cc b/db/db_compaction_test.cc index a8aaea097..7385b399c 100644 --- a/db/db_compaction_test.cc +++ b/db/db_compaction_test.cc @@ -13,6 +13,10 @@ #include "util/sync_point.h" namespace rocksdb { +// SYNC_POINT is not supported in released Windows mode. +#if !(defined NDEBUG) || !defined(OS_WIN) + + class DBCompactionTest : public DBTestBase { public: DBCompactionTest() : DBTestBase("/db_compaction_test") {} @@ -1647,8 +1651,6 @@ TEST_P(DBCompactionTestWithParam, CompressLevelCompaction) { Destroy(options); } -// SYNC_POINT is not supported in released Windows mode. -#if !(defined NDEBUG) || !defined(OS_WIN) // This tests for a bug that could cause two level0 compactions running // concurrently TEST_P(DBCompactionTestWithParam, SuggestCompactRangeNoTwoLevel0Compactions) { @@ -1705,7 +1707,6 @@ TEST_P(DBCompactionTestWithParam, SuggestCompactRangeNoTwoLevel0Compactions) { dbfull()->TEST_WaitForCompact(); } -#endif // !(defined NDEBUG) || !defined(OS_WIN) TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) { int32_t trivial_move = 0; @@ -1792,7 +1793,7 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) { INSTANTIATE_TEST_CASE_P(DBCompactionTestWithParam, DBCompactionTestWithParam, ::testing::Values(1, 4)); - +#endif // !(defined NDEBUG) || !defined(OS_WIN) } // namespace rocksdb int main(int argc, char** argv) { diff --git a/db/db_universal_compaction_test.cc b/db/db_universal_compaction_test.cc index c788157bc..16d758b00 100644 --- a/db/db_universal_compaction_test.cc +++ b/db/db_universal_compaction_test.cc @@ -11,7 +11,6 @@ #include "util/db_test_util.h" #if !(defined NDEBUG) || !defined(OS_WIN) #include "util/sync_point.h" -#endif namespace rocksdb { @@ -113,9 +112,6 @@ class DelayFilterFactory : public CompactionFilterFactory { }; } // namespace -// SyncPoint is not supported in released Windows mode. -#if !(defined NDEBUG) || !defined(OS_WIN) - // TODO(kailiu) The tests on UniversalCompaction has some issues: // 1. A lot of magic numbers ("11" or "12"). // 2. Made assumption on the memtable flush conditions, which may change from @@ -257,7 +253,6 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrigger) { rocksdb::SyncPoint::GetInstance()->DisableProcessing(); } -#endif // !(defined NDEBUG) || !defined(OS_WIN) TEST_P(DBTestUniversalCompaction, UniversalCompactionSizeAmplification) { Options options; @@ -1241,6 +1236,8 @@ INSTANTIATE_TEST_CASE_P(DBTestUniversalManualCompactionOutputPathId, } // namespace rocksdb +#endif // !(defined NDEBUG) || !defined(OS_WIN) + int main(int argc, char** argv) { #if !(defined NDEBUG) || !defined(OS_WIN) rocksdb::port::InstallStackTraceHandler(); diff --git a/db/fault_injection_test.cc b/db/fault_injection_test.cc index 2d7ccccac..87028e381 100644 --- a/db/fault_injection_test.cc +++ b/db/fault_injection_test.cc @@ -11,6 +11,8 @@ // the last "sync". It then checks for data loss errors by purposely dropping // file data (or entire files) not protected by a "sync". +#if !(defined NDEBUG) || !defined(OS_WIN) + #include #include #include "db/db_impl.h" @@ -931,7 +933,13 @@ INSTANTIATE_TEST_CASE_P(FaultTest, FaultInjectionTest, ::testing::Bool()); } // namespace rocksdb +#endif // #if !(defined NDEBUG) || !defined(OS_WIN) + int main(int argc, char** argv) { +#if !(defined NDEBUG) || !defined(OS_WIN) ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); +#else + return 0; +#endif } -- GitLab