2013-10-16 21:59:46 +00: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.
|
|
|
|
//
|
2012-12-26 19:51:36 +00:00
|
|
|
|
2013-10-05 05:32:05 +00:00
|
|
|
#pragma once
|
2012-12-26 19:51:36 +00:00
|
|
|
#include <queue>
|
|
|
|
|
2013-08-23 15:38:13 +00:00
|
|
|
#include "rocksdb/comparator.h"
|
2012-12-26 19:51:36 +00:00
|
|
|
#include "table/iterator_wrapper.h"
|
|
|
|
|
2013-10-04 04:49:15 +00:00
|
|
|
namespace rocksdb {
|
2012-12-26 19:51:36 +00:00
|
|
|
|
|
|
|
// Return the max of two keys.
|
|
|
|
class MaxIteratorComparator {
|
|
|
|
public:
|
|
|
|
MaxIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) {
|
|
|
|
return comparator_->Compare(a->key(), b->key()) <= 0;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Return the max of two keys.
|
|
|
|
class MinIteratorComparator {
|
|
|
|
public:
|
|
|
|
// if maxHeap is set comparator returns the max value.
|
|
|
|
// else returns the min Value.
|
|
|
|
// Can use to create a minHeap or a maxHeap.
|
|
|
|
MinIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) {
|
|
|
|
return comparator_->Compare(a->key(), b->key()) > 0;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
2013-10-04 04:49:15 +00:00
|
|
|
} // namespace rocksdb
|