2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2013-10-16 21:59:46 +00:00
|
|
|
//
|
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
|
|
|
|
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
|
|
|
|
2015-07-06 11:24:09 +00:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the max/largest key on top.
|
2012-12-26 19:51:36 +00:00
|
|
|
class MaxIteratorComparator {
|
|
|
|
public:
|
|
|
|
MaxIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
2015-07-06 11:24:09 +00:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
|
|
|
return comparator_->Compare(a->key(), b->key()) < 0;
|
2012-12-26 19:51:36 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
2015-07-06 11:24:09 +00:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the min/smallest key on top.
|
2012-12-26 19:51:36 +00:00
|
|
|
class MinIteratorComparator {
|
|
|
|
public:
|
|
|
|
MinIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
2015-07-06 11:24:09 +00:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
2012-12-26 19:51:36 +00:00
|
|
|
return comparator_->Compare(a->key(), b->key()) > 0;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
2013-10-04 04:49:15 +00:00
|
|
|
} // namespace rocksdb
|