2013-10-16 23:59:46 +02:00
|
|
|
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
2013-10-05 07:32:05 +02:00
|
|
|
#pragma once
|
2013-08-23 08:10:02 +02:00
|
|
|
|
2015-09-02 22:58:22 +02:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2013-08-23 08:10:02 +02:00
|
|
|
|
2015-09-02 22:58:22 +02:00
|
|
|
#include "rocksdb/comparator.h"
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/memtablerep.h"
|
|
|
|
#include "rocksdb/slice.h"
|
2015-09-02 22:58:22 +02:00
|
|
|
#include "util/coding.h"
|
|
|
|
#include "util/murmurhash.h"
|
2013-08-23 08:10:02 +02:00
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
namespace rocksdb {
|
2013-08-23 08:10:02 +02:00
|
|
|
namespace stl_wrappers {
|
|
|
|
|
2015-09-02 22:58:22 +02:00
|
|
|
class Base {
|
|
|
|
protected:
|
|
|
|
const MemTableRep::KeyComparator& compare_;
|
|
|
|
explicit Base(const MemTableRep::KeyComparator& compare)
|
|
|
|
: compare_(compare) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Compare : private Base {
|
|
|
|
explicit Compare(const MemTableRep::KeyComparator& compare) : Base(compare) {}
|
|
|
|
inline bool operator()(const char* a, const char* b) const {
|
|
|
|
return compare_(a, b) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LessOfComparator {
|
|
|
|
explicit LessOfComparator(const Comparator* c = BytewiseComparator())
|
|
|
|
: cmp(c) {}
|
|
|
|
|
|
|
|
bool operator()(const std::string& a, const std::string& b) const {
|
|
|
|
return cmp->Compare(Slice(a), Slice(b)) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Comparator* cmp;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<std::string, std::string, LessOfComparator> KVMap;
|
2013-08-23 08:10:02 +02:00
|
|
|
}
|
|
|
|
}
|