From 5f2c136c328a8dbb6c3cb3818881e30eeb916cd6 Mon Sep 17 00:00:00 2001 From: Rajat Goel Date: Sun, 15 Sep 2013 22:06:14 -0700 Subject: [PATCH] Minor fixes found while trying to compile it using clang on Mac OS X --- db/builder.h | 2 +- db/db_bench.cc | 12 ------------ db/merge_helper.h | 1 - db/repair.cc | 1 - include/rocksdb/env.h | 7 ++++++- util/cache.cc | 6 ++---- util/env_posix.cc | 13 ++++++++++++- utilities/ttl/db_ttl.cc | 3 +-- utilities/ttl/db_ttl.h | 1 - 9 files changed, 22 insertions(+), 24 deletions(-) diff --git a/db/builder.h b/db/builder.h index 8de5d43350..b8e6f485a8 100644 --- a/db/builder.h +++ b/db/builder.h @@ -15,7 +15,7 @@ struct Options; struct FileMetaData; class Env; -class EnvOptions; +struct EnvOptions; class Iterator; class TableCache; class VersionEdit; diff --git a/db/db_bench.cc b/db/db_bench.cc index 096b183772..2846f9e55d 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -421,18 +421,6 @@ class RandomGenerator { } }; -static Slice TrimSpace(Slice s) { - unsigned int start = 0; - while (start < s.size() && isspace(s[start])) { - start++; - } - unsigned int limit = s.size(); - while (limit > start && isspace(s[limit-1])) { - limit--; - } - return Slice(s.data() + start, limit - start); -} - static void AppendWithSpace(std::string* str, Slice msg) { if (msg.empty()) return; if (!str->empty()) { diff --git a/db/merge_helper.h b/db/merge_helper.h index b058f98692..6f89253a4d 100644 --- a/db/merge_helper.h +++ b/db/merge_helper.h @@ -83,7 +83,6 @@ class MergeHelper { const Comparator* user_comparator_; const MergeOperator* user_merge_operator_; Logger* logger_; - Iterator* iter_; // in: the internal iterator, positioned at the first merge entry bool assert_valid_internal_key_; // enforce no internal key corruption? // the scratch area that holds the result of MergeUntil diff --git a/db/repair.cc b/db/repair.cc index 23a2b79356..bbe558fd77 100644 --- a/db/repair.cc +++ b/db/repair.cc @@ -97,7 +97,6 @@ class Repairer { InternalKeyComparator const icmp_; InternalFilterPolicy const ipolicy_; Options const options_; - bool owns_cache_; TableCache* table_cache_; VersionEdit* edit_; diff --git a/include/rocksdb/env.h b/include/rocksdb/env.h index 50b29167ba..131951ce17 100644 --- a/include/rocksdb/env.h +++ b/include/rocksdb/env.h @@ -18,8 +18,13 @@ #include #include #include +#include #include "rocksdb/status.h" +#ifdef __APPLE__ +typedef off_t off64_t; +#endif + namespace leveldb { class FileLock; @@ -28,7 +33,7 @@ class RandomAccessFile; class SequentialFile; class Slice; class WritableFile; -class Options; +struct Options; using std::unique_ptr; using std::shared_ptr; diff --git a/util/cache.cc b/util/cache.cc index 5a2ce38a60..c823845818 100644 --- a/util/cache.cc +++ b/util/cache.cc @@ -159,7 +159,6 @@ class LRUCache { // mutex_ protects the following state. port::Mutex mutex_; size_t usage_; - uint64_t last_id_; // Dummy head of LRU list. // lru.prev is newest entry, lru.next is oldest entry. @@ -169,8 +168,7 @@ class LRUCache { }; LRUCache::LRUCache() - : usage_(0), - last_id_(0) { + : usage_(0) { // Make empty circular linked list lru_.next = &lru_; lru_.prev = &lru_; @@ -333,7 +331,7 @@ class ShardedLRUCache : public Cache { MutexLock l(&id_mutex_); return ++(last_id_); } - virtual uint64_t GetCapacity() { + virtual size_t GetCapacity() { return capacity_; } }; diff --git a/util/env_posix.cc b/util/env_posix.cc index 50f96e5074..91cc07b0ab 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -14,10 +14,15 @@ #include #include #include +#ifdef __APPLE__ +#include +#include +#else #include +#include +#endif #include #include -#include #include #include #if defined(OS_LINUX) @@ -126,7 +131,9 @@ class PosixSequentialFile: public SequentialFile { if (!use_os_buffer_) { // we need to fadvise away the entire range of pages because // we do not want readahead pages to be cached. +#ifndef __APPLE__ posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages +#endif } return s; } @@ -166,7 +173,9 @@ class PosixRandomAccessFile: public RandomAccessFile { if (!use_os_buffer_) { // we need to fadvise away the entire range of pages because // we do not want readahead pages to be cached. +#ifndef __APPLE__ posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages +#endif } return s; } @@ -201,6 +210,7 @@ class PosixRandomAccessFile: public RandomAccessFile { #endif virtual void Hint(AccessPattern pattern) { +#ifndef __APPLE__ switch(pattern) { case NORMAL: posix_fadvise(fd_, 0, 0, POSIX_FADV_NORMAL); @@ -221,6 +231,7 @@ class PosixRandomAccessFile: public RandomAccessFile { assert(false); break; } +#endif } }; diff --git a/utilities/ttl/db_ttl.cc b/utilities/ttl/db_ttl.cc index eb39267f85..f1ef1983de 100644 --- a/utilities/ttl/db_ttl.cc +++ b/utilities/ttl/db_ttl.cc @@ -16,8 +16,7 @@ DBWithTTL::DBWithTTL(const int32_t ttl, const std::string& dbname, Status& st, bool read_only) - : StackableDB(nullptr), - ttl_(ttl) { + : StackableDB(nullptr) { Options options_to_open = options; if (options.compaction_filter) { diff --git a/utilities/ttl/db_ttl.h b/utilities/ttl/db_ttl.h index f11f220cd6..d16aa1cc13 100644 --- a/utilities/ttl/db_ttl.h +++ b/utilities/ttl/db_ttl.h @@ -111,7 +111,6 @@ class DBWithTTL : public StackableDB { private: DB* db_; - int32_t ttl_; unique_ptr ttl_comp_filter_; };