Address windows build issues

Intro SubCompactionState move functionality
  =delete copy functionality
  #ifdef SyncPoint in tests for Windows Release builds
This commit is contained in:
Dmitri Smirnov 2015-08-20 13:43:07 -07:00
parent b604d2562f
commit f25f06ddd2
4 changed files with 44 additions and 11 deletions

View File

@ -59,7 +59,7 @@ namespace rocksdb {
// Maintains state for each sub-compaction // Maintains state for each sub-compaction
struct CompactionJob::SubCompactionState { struct CompactionJob::SubCompactionState {
Compaction* const compaction; Compaction* compaction;
// The boundaries of the key-range this compaction is interested in. No two // The boundaries of the key-range this compaction is interested in. No two
// subcompactions may have overlapping key-ranges. // 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 // is in or beyond the last file checked during the previous call
std::vector<size_t> level_ptrs; std::vector<size_t> level_ptrs;
explicit SubCompactionState(Compaction* c, Slice* _start, Slice* _end, SubCompactionState(Compaction* c, Slice* _start, Slice* _end,
SequenceNumber earliest, SequenceNumber visible, SequenceNumber earliest, SequenceNumber visible,
SequenceNumber latest) SequenceNumber latest)
: compaction(c), : compaction(c),
@ -130,6 +130,33 @@ struct CompactionJob::SubCompactionState {
assert(compaction != nullptr); assert(compaction != nullptr);
level_ptrs = std::vector<size_t>(compaction->number_levels(), 0); level_ptrs = std::vector<size_t>(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 // Maintains state for the entire compaction

View File

@ -13,6 +13,10 @@
#include "util/sync_point.h" #include "util/sync_point.h"
namespace rocksdb { namespace rocksdb {
// SYNC_POINT is not supported in released Windows mode.
#if !(defined NDEBUG) || !defined(OS_WIN)
class DBCompactionTest : public DBTestBase { class DBCompactionTest : public DBTestBase {
public: public:
DBCompactionTest() : DBTestBase("/db_compaction_test") {} DBCompactionTest() : DBTestBase("/db_compaction_test") {}
@ -1647,8 +1651,6 @@ TEST_P(DBCompactionTestWithParam, CompressLevelCompaction) {
Destroy(options); 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 // This tests for a bug that could cause two level0 compactions running
// concurrently // concurrently
TEST_P(DBCompactionTestWithParam, SuggestCompactRangeNoTwoLevel0Compactions) { TEST_P(DBCompactionTestWithParam, SuggestCompactRangeNoTwoLevel0Compactions) {
@ -1705,7 +1707,6 @@ TEST_P(DBCompactionTestWithParam, SuggestCompactRangeNoTwoLevel0Compactions) {
dbfull()->TEST_WaitForCompact(); dbfull()->TEST_WaitForCompact();
} }
#endif // !(defined NDEBUG) || !defined(OS_WIN)
TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) { TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
int32_t trivial_move = 0; int32_t trivial_move = 0;
@ -1792,7 +1793,7 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
INSTANTIATE_TEST_CASE_P(DBCompactionTestWithParam, DBCompactionTestWithParam, INSTANTIATE_TEST_CASE_P(DBCompactionTestWithParam, DBCompactionTestWithParam,
::testing::Values(1, 4)); ::testing::Values(1, 4));
#endif // !(defined NDEBUG) || !defined(OS_WIN)
} // namespace rocksdb } // namespace rocksdb
int main(int argc, char** argv) { int main(int argc, char** argv) {

View File

@ -11,7 +11,6 @@
#include "util/db_test_util.h" #include "util/db_test_util.h"
#if !(defined NDEBUG) || !defined(OS_WIN) #if !(defined NDEBUG) || !defined(OS_WIN)
#include "util/sync_point.h" #include "util/sync_point.h"
#endif
namespace rocksdb { namespace rocksdb {
@ -113,9 +112,6 @@ class DelayFilterFactory : public CompactionFilterFactory {
}; };
} // namespace } // namespace
// SyncPoint is not supported in released Windows mode.
#if !(defined NDEBUG) || !defined(OS_WIN)
// TODO(kailiu) The tests on UniversalCompaction has some issues: // TODO(kailiu) The tests on UniversalCompaction has some issues:
// 1. A lot of magic numbers ("11" or "12"). // 1. A lot of magic numbers ("11" or "12").
// 2. Made assumption on the memtable flush conditions, which may change from // 2. Made assumption on the memtable flush conditions, which may change from
@ -257,7 +253,6 @@ TEST_P(DBTestUniversalCompaction, UniversalCompactionTrigger) {
rocksdb::SyncPoint::GetInstance()->DisableProcessing(); rocksdb::SyncPoint::GetInstance()->DisableProcessing();
} }
#endif // !(defined NDEBUG) || !defined(OS_WIN)
TEST_P(DBTestUniversalCompaction, UniversalCompactionSizeAmplification) { TEST_P(DBTestUniversalCompaction, UniversalCompactionSizeAmplification) {
Options options; Options options;
@ -1241,6 +1236,8 @@ INSTANTIATE_TEST_CASE_P(DBTestUniversalManualCompactionOutputPathId,
} // namespace rocksdb } // namespace rocksdb
#endif // !(defined NDEBUG) || !defined(OS_WIN)
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if !(defined NDEBUG) || !defined(OS_WIN) #if !(defined NDEBUG) || !defined(OS_WIN)
rocksdb::port::InstallStackTraceHandler(); rocksdb::port::InstallStackTraceHandler();

View File

@ -11,6 +11,8 @@
// the last "sync". It then checks for data loss errors by purposely dropping // the last "sync". It then checks for data loss errors by purposely dropping
// file data (or entire files) not protected by a "sync". // file data (or entire files) not protected by a "sync".
#if !(defined NDEBUG) || !defined(OS_WIN)
#include <map> #include <map>
#include <set> #include <set>
#include "db/db_impl.h" #include "db/db_impl.h"
@ -931,7 +933,13 @@ INSTANTIATE_TEST_CASE_P(FaultTest, FaultInjectionTest, ::testing::Bool());
} // namespace rocksdb } // namespace rocksdb
#endif // #if !(defined NDEBUG) || !defined(OS_WIN)
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if !(defined NDEBUG) || !defined(OS_WIN)
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
#else
return 0;
#endif
} }