2016-02-09 15:12:00 -08:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2013-10-16 14:59:46 -07:00
|
|
|
// 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.
|
2017-04-27 17:50:56 -07:00
|
|
|
// This source code is also licensed under the GPLv2 license found in the
|
|
|
|
// COPYING file in the root directory of this source tree.
|
2013-10-16 14:59:46 -07:00
|
|
|
//
|
2012-12-26 11:51:36 -08:00
|
|
|
|
2013-10-04 22:32:05 -07:00
|
|
|
#pragma once
|
2012-12-26 11:51:36 -08:00
|
|
|
|
2013-08-23 08:38:13 -07:00
|
|
|
#include "rocksdb/comparator.h"
|
2012-12-26 11:51:36 -08:00
|
|
|
#include "table/iterator_wrapper.h"
|
|
|
|
|
2013-10-03 21:49:15 -07:00
|
|
|
namespace rocksdb {
|
2012-12-26 11:51:36 -08:00
|
|
|
|
2015-07-06 04:24:09 -07:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the max/largest key on top.
|
2012-12-26 11:51:36 -08:00
|
|
|
class MaxIteratorComparator {
|
|
|
|
public:
|
|
|
|
MaxIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
2015-07-06 04:24:09 -07:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
|
|
|
return comparator_->Compare(a->key(), b->key()) < 0;
|
2012-12-26 11:51:36 -08:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
2015-07-06 04:24:09 -07:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the min/smallest key on top.
|
2012-12-26 11:51:36 -08:00
|
|
|
class MinIteratorComparator {
|
|
|
|
public:
|
|
|
|
MinIteratorComparator(const Comparator* comparator) :
|
|
|
|
comparator_(comparator) {}
|
|
|
|
|
2015-07-06 04:24:09 -07:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
2012-12-26 11:51:36 -08:00
|
|
|
return comparator_->Compare(a->key(), b->key()) > 0;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
const Comparator* comparator_;
|
|
|
|
};
|
|
|
|
|
2013-10-03 21:49:15 -07:00
|
|
|
} // namespace rocksdb
|