From 2754ec9994304116d6c0e3a04b6280a74ed0b4d8 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 21 Sep 2015 16:21:01 -0700 Subject: [PATCH 1/3] Fix Windows constexpr issue and '#ifdef' column_family_test in Release. --- db/column_family_test.cc | 7 +++++++ .../write_batch_with_index_internal.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 938c4121a..a258b83df 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -23,6 +23,8 @@ #include "util/sync_point.h" #include "utilities/merge_operators.h" +#if !(defined NDEBUG) || !defined(OS_WIN) + namespace rocksdb { namespace { @@ -1260,8 +1262,13 @@ TEST_F(ColumnFamilyTest, FlushAndDropRaceCondition) { } } // namespace rocksdb +#endif int main(int argc, char** argv) { +#if !(defined NDEBUG) || !defined(OS_WIN) ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); +#else + return 0; +#endif } diff --git a/utilities/write_batch_with_index/write_batch_with_index_internal.h b/utilities/write_batch_with_index/write_batch_with_index_internal.h index 3c894ebbb..5fdb9035a 100644 --- a/utilities/write_batch_with_index/write_batch_with_index_internal.h +++ b/utilities/write_batch_with_index/write_batch_with_index_internal.h @@ -30,7 +30,7 @@ struct WriteBatchIndexEntry { // If this flag appears in the offset, it indicates a key that is smaller // than any other entry for the same column family - static const size_t kFlagMin = std::numeric_limits::max(); + static const size_t kFlagMin = UINT64_MAX; size_t offset; // offset of an entry in write batch's string buffer. uint32_t column_family; // column family of the entry From 5e8f0a66db9da5f1cc4353b08df2793b0a4789bb Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 21 Sep 2015 16:56:47 -0700 Subject: [PATCH 2/3] Use port::constant for std::muneric_limtis<>::max() --- .../write_batch_with_index/write_batch_with_index_internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utilities/write_batch_with_index/write_batch_with_index_internal.h b/utilities/write_batch_with_index/write_batch_with_index_internal.h index 5fdb9035a..f3ccf40ae 100644 --- a/utilities/write_batch_with_index/write_batch_with_index_internal.h +++ b/utilities/write_batch_with_index/write_batch_with_index_internal.h @@ -15,6 +15,7 @@ #include "rocksdb/slice.h" #include "rocksdb/status.h" #include "rocksdb/utilities/write_batch_with_index.h" +#include "port/port.h" namespace rocksdb { @@ -30,7 +31,7 @@ struct WriteBatchIndexEntry { // If this flag appears in the offset, it indicates a key that is smaller // than any other entry for the same column family - static const size_t kFlagMin = UINT64_MAX; + static const size_t kFlagMin = port::kMaxUint64; size_t offset; // offset of an entry in write batch's string buffer. uint32_t column_family; // column family of the entry From 489a3e95d4a002bde63566778f248af320f28a92 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Tue, 22 Sep 2015 10:34:21 -0700 Subject: [PATCH 3/3] Re-work to support size_t max constant for 32/64-bit. --- port/port_posix.h | 1 + port/win/port_win.h | 7 +++++++ .../write_batch_with_index_internal.h | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/port/port_posix.h b/port/port_posix.h index bf3fd5b46..efb72ee10 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -82,6 +82,7 @@ namespace port { // For use at db/file_indexer.h kLevelMaxIndex const int kMaxInt32 = std::numeric_limits::max(); const uint64_t kMaxUint64 = std::numeric_limits::max(); +const size_t kMaxSizet = std::numeric_limits::max(); static const bool kLittleEndian = PLATFORM_IS_LITTLE_ENDIAN; #undef PLATFORM_IS_LITTLE_ENDIAN diff --git a/port/win/port_win.h b/port/win/port_win.h index c861c45af..1f517fb78 100644 --- a/port/win/port_win.h +++ b/port/win/port_win.h @@ -99,6 +99,13 @@ namespace port { // For use at db/file_indexer.h kLevelMaxIndex const int kMaxInt32 = INT32_MAX; const uint64_t kMaxUint64 = UINT64_MAX; +// std::numeric_limits::max() is not constexpr just yet +// therefore, use the same limits +#ifdef _WIN64 +const size_t kMaxSizet = UINT64_MAX; +#else +const size_t kMaxSizet = UINT_MAX; +#endif const bool kLittleEndian = true; diff --git a/utilities/write_batch_with_index/write_batch_with_index_internal.h b/utilities/write_batch_with_index/write_batch_with_index_internal.h index f3ccf40ae..b9d7e0fb7 100644 --- a/utilities/write_batch_with_index/write_batch_with_index_internal.h +++ b/utilities/write_batch_with_index/write_batch_with_index_internal.h @@ -31,7 +31,7 @@ struct WriteBatchIndexEntry { // If this flag appears in the offset, it indicates a key that is smaller // than any other entry for the same column family - static const size_t kFlagMin = port::kMaxUint64; + static const size_t kFlagMin = port::kMaxSizet; size_t offset; // offset of an entry in write batch's string buffer. uint32_t column_family; // column family of the entry