rocksdb/util/kv_map.h
Andrew Kryczka 4e20c5da20 Store internal keys in TombstoneMap
Summary:
This fixes a correctness issue where ranges with same begin key would overwrite each other.

This diff uses InternalKey as TombstoneMap's key such that all tombstones have unique keys even when their start keys overlap. We also update TombstoneMap to use an internal key comparator.

End-to-end tests pass and are here (https://gist.github.com/ajkr/851ffe4c1b8a15a68d33025be190a7d9) but cannot be included yet since the DeleteRange() API is yet to be checked in. Note both tests failed before this fix.
Closes https://github.com/facebook/rocksdb/pull/1484

Differential Revision: D4155248

Pulled By: ajkr

fbshipit-source-id: 304b4b9
2016-11-09 15:09:18 -08:00

35 lines
947 B
C++

// Copyright (c) 2011-present, 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.
#pragma once
#include <map>
#include <string>
#include "rocksdb/comparator.h"
#include "rocksdb/slice.h"
#include "util/coding.h"
#include "util/murmurhash.h"
namespace rocksdb {
namespace stl_wrappers {
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;
}
bool operator()(const Slice& a, const Slice& b) const {
return cmp->Compare(a, b) < 0;
}
const Comparator* cmp;
};
typedef std::map<std::string, std::string, LessOfComparator> KVMap;
}
}