2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02: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 23:59:46 +02:00
|
|
|
//
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2013-10-05 07:32:05 +02:00
|
|
|
#pragma once
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/comparator.h"
|
2012-12-26 20:51:36 +01:00
|
|
|
#include "table/iterator_wrapper.h"
|
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
namespace rocksdb {
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the max/largest key on top.
|
2012-12-26 20:51:36 +01:00
|
|
|
class MaxIteratorComparator {
|
|
|
|
public:
|
|
|
|
MaxIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
|
|
|
return comparator_->Compare(a->key(), b->key()) < 0;
|
2012-12-26 20:51:36 +01:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the min/smallest key on top.
|
2012-12-26 20:51:36 +01:00
|
|
|
class MinIteratorComparator {
|
|
|
|
public:
|
|
|
|
MinIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
2012-12-26 20:51:36 +01:00
|
|
|
return comparator_->Compare(a->key(), b->key()) > 0;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
} // namespace rocksdb
|