Revert "Minor fixes found while trying to compile it using clang on Mac OS X"

This reverts commit 5f2c136c32.
This commit is contained in:
Rajat Goel 2013-09-15 23:01:26 -07:00
parent 1d8c57db23
commit 11c65021fb
9 changed files with 24 additions and 22 deletions

View File

@ -15,7 +15,7 @@ struct Options;
struct FileMetaData; struct FileMetaData;
class Env; class Env;
struct EnvOptions; class EnvOptions;
class Iterator; class Iterator;
class TableCache; class TableCache;
class VersionEdit; class VersionEdit;

View File

@ -421,6 +421,18 @@ 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) { static void AppendWithSpace(std::string* str, Slice msg) {
if (msg.empty()) return; if (msg.empty()) return;
if (!str->empty()) { if (!str->empty()) {

View File

@ -83,6 +83,7 @@ class MergeHelper {
const Comparator* user_comparator_; const Comparator* user_comparator_;
const MergeOperator* user_merge_operator_; const MergeOperator* user_merge_operator_;
Logger* logger_; Logger* logger_;
Iterator* iter_; // in: the internal iterator, positioned at the first merge entry
bool assert_valid_internal_key_; // enforce no internal key corruption? bool assert_valid_internal_key_; // enforce no internal key corruption?
// the scratch area that holds the result of MergeUntil // the scratch area that holds the result of MergeUntil

View File

@ -97,6 +97,7 @@ class Repairer {
InternalKeyComparator const icmp_; InternalKeyComparator const icmp_;
InternalFilterPolicy const ipolicy_; InternalFilterPolicy const ipolicy_;
Options const options_; Options const options_;
bool owns_cache_;
TableCache* table_cache_; TableCache* table_cache_;
VersionEdit* edit_; VersionEdit* edit_;

View File

@ -18,13 +18,8 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <stdint.h> #include <stdint.h>
#include <sys/types.h>
#include "rocksdb/status.h" #include "rocksdb/status.h"
#ifdef __APPLE__
typedef off_t off64_t;
#endif
namespace leveldb { namespace leveldb {
class FileLock; class FileLock;
@ -33,7 +28,7 @@ class RandomAccessFile;
class SequentialFile; class SequentialFile;
class Slice; class Slice;
class WritableFile; class WritableFile;
struct Options; class Options;
using std::unique_ptr; using std::unique_ptr;
using std::shared_ptr; using std::shared_ptr;

View File

@ -159,6 +159,7 @@ class LRUCache {
// mutex_ protects the following state. // mutex_ protects the following state.
port::Mutex mutex_; port::Mutex mutex_;
size_t usage_; size_t usage_;
uint64_t last_id_;
// Dummy head of LRU list. // Dummy head of LRU list.
// lru.prev is newest entry, lru.next is oldest entry. // lru.prev is newest entry, lru.next is oldest entry.
@ -168,7 +169,8 @@ class LRUCache {
}; };
LRUCache::LRUCache() LRUCache::LRUCache()
: usage_(0) { : usage_(0),
last_id_(0) {
// Make empty circular linked list // Make empty circular linked list
lru_.next = &lru_; lru_.next = &lru_;
lru_.prev = &lru_; lru_.prev = &lru_;
@ -331,7 +333,7 @@ class ShardedLRUCache : public Cache {
MutexLock l(&id_mutex_); MutexLock l(&id_mutex_);
return ++(last_id_); return ++(last_id_);
} }
virtual size_t GetCapacity() { virtual uint64_t GetCapacity() {
return capacity_; return capacity_;
} }
}; };

View File

@ -14,15 +14,10 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __APPLE__
#include <sys/param.h>
#include <sys/mount.h>
#else
#include <sys/statfs.h> #include <sys/statfs.h>
#include <sys/vfs.h>
#endif
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/vfs.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#if defined(OS_LINUX) #if defined(OS_LINUX)
@ -131,9 +126,7 @@ class PosixSequentialFile: public SequentialFile {
if (!use_os_buffer_) { if (!use_os_buffer_) {
// we need to fadvise away the entire range of pages because // we need to fadvise away the entire range of pages because
// we do not want readahead pages to be cached. // we do not want readahead pages to be cached.
#ifndef __APPLE__
posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages
#endif
} }
return s; return s;
} }
@ -173,9 +166,7 @@ class PosixRandomAccessFile: public RandomAccessFile {
if (!use_os_buffer_) { if (!use_os_buffer_) {
// we need to fadvise away the entire range of pages because // we need to fadvise away the entire range of pages because
// we do not want readahead pages to be cached. // we do not want readahead pages to be cached.
#ifndef __APPLE__
posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages posix_fadvise(fd_, 0, 0, POSIX_FADV_DONTNEED); // free OS pages
#endif
} }
return s; return s;
} }
@ -210,7 +201,6 @@ class PosixRandomAccessFile: public RandomAccessFile {
#endif #endif
virtual void Hint(AccessPattern pattern) { virtual void Hint(AccessPattern pattern) {
#ifndef __APPLE__
switch(pattern) { switch(pattern) {
case NORMAL: case NORMAL:
posix_fadvise(fd_, 0, 0, POSIX_FADV_NORMAL); posix_fadvise(fd_, 0, 0, POSIX_FADV_NORMAL);
@ -231,7 +221,6 @@ class PosixRandomAccessFile: public RandomAccessFile {
assert(false); assert(false);
break; break;
} }
#endif
} }
}; };

View File

@ -16,7 +16,8 @@ DBWithTTL::DBWithTTL(const int32_t ttl,
const std::string& dbname, const std::string& dbname,
Status& st, Status& st,
bool read_only) bool read_only)
: StackableDB(nullptr) { : StackableDB(nullptr),
ttl_(ttl) {
Options options_to_open = options; Options options_to_open = options;
if (options.compaction_filter) { if (options.compaction_filter) {

View File

@ -111,6 +111,7 @@ class DBWithTTL : public StackableDB {
private: private:
DB* db_; DB* db_;
int32_t ttl_;
unique_ptr<CompactionFilter> ttl_comp_filter_; unique_ptr<CompactionFilter> ttl_comp_filter_;
}; };