From 811e403f57cd833a4b2d363dca695229096be1f2 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 16 Sep 2019 20:40:44 -0700 Subject: [PATCH] Dedup IsFileSectorAligned() to fix unity build. (#5812) Summary: Unity build fails because of name conflict of IsFileSectorAligned() after recent refactoring. Consolidate the function. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5812 Test Plan: make unity. At least the failure goes away. Also "make all", "make release" and see no regression in normal cases. Differential Revision: D17411403 fbshipit-source-id: 09d5653471ae2c3a4d898e120a024f7dd08d9c9d --- file/read_write_util.cc | 5 +++++ file/read_write_util.h | 3 +++ file/readahead_raf.cc | 10 +--------- file/sequence_file_reader.cc | 10 +--------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/file/read_write_util.cc b/file/read_write_util.cc index 8614fcaa8..892499b8c 100644 --- a/file/read_write_util.cc +++ b/file/read_write_util.cc @@ -58,4 +58,9 @@ bool ReadOneLine(std::istringstream* iss, SequentialFile* seq_file, return *has_data || has_complete_line; } +#ifndef NDEBUG +bool IsFileSectorAligned(const size_t off, size_t sector_size) { + return off % sector_size == 0; +} +#endif // NDEBUG } // namespace rocksdb diff --git a/file/read_write_util.h b/file/read_write_util.h index 7c344728f..be975e854 100644 --- a/file/read_write_util.h +++ b/file/read_write_util.h @@ -26,4 +26,7 @@ extern Status NewWritableFile(Env* env, const std::string& fname, bool ReadOneLine(std::istringstream* iss, SequentialFile* seq_file, std::string* output, bool* has_data, Status* result); +#ifndef NDEBUG +bool IsFileSectorAligned(const size_t off, size_t sector_size); +#endif // NDEBUG } // namespace rocksdb diff --git a/file/readahead_raf.cc b/file/readahead_raf.cc index 5c5582d14..dc005b900 100644 --- a/file/readahead_raf.cc +++ b/file/readahead_raf.cc @@ -11,19 +11,11 @@ #include #include +#include "file/read_write_util.h" #include "util/aligned_buffer.h" #include "util/rate_limiter.h" namespace rocksdb { - -#ifndef NDEBUG -namespace { -bool IsFileSectorAligned(const size_t off, size_t sector_size) { - return off % sector_size == 0; -} -} // namespace -#endif - namespace { class ReadaheadRandomAccessFile : public RandomAccessFile { public: diff --git a/file/sequence_file_reader.cc b/file/sequence_file_reader.cc index f9b20d067..be766a68b 100644 --- a/file/sequence_file_reader.cc +++ b/file/sequence_file_reader.cc @@ -12,6 +12,7 @@ #include #include +#include "file/read_write_util.h" #include "monitoring/histogram.h" #include "monitoring/iostats_context_imp.h" #include "port/port.h" @@ -21,15 +22,6 @@ #include "util/rate_limiter.h" namespace rocksdb { - -#ifndef NDEBUG -namespace { -bool IsFileSectorAligned(const size_t off, size_t sector_size) { - return off % sector_size == 0; -} -} // namespace -#endif - Status SequentialFileReader::Read(size_t n, Slice* result, char* scratch) { Status s; if (use_direct_io()) {