MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
ob_comparator.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11#pragma once
12
13#include "common/lang/string_view.h"
14
15namespace oceanbase {
16
21{
22public:
23 virtual ~ObComparator() = default;
24
31 virtual int compare(const string_view &a, const string_view &b) const = 0;
32};
33
38{
39public:
40 explicit ObDefaultComparator() = default;
41 int compare(const string_view &a, const string_view &b) const override;
42};
43
49{
50public:
51 explicit ObInternalKeyComparator() = default;
52
53 int compare(const string_view &a, const string_view &b) const override;
54 const ObComparator *user_comparator() const { return &default_comparator_; }
55
56private:
57 ObDefaultComparator default_comparator_;
58};
59
60} // namespace oceanbase
base class of all comparators
Definition: ob_comparator.h:21
virtual int compare(const string_view &a, const string_view &b) const =0
Three-way comparison.
comparator with lexicographical order
Definition: ob_comparator.h:38
int compare(const string_view &a, const string_view &b) const override
Three-way comparison.
Definition: ob_comparator.cpp:16
internal key comparator
Definition: ob_comparator.h:49
int compare(const string_view &a, const string_view &b) const override
Three-way comparison.
Definition: ob_comparator.cpp:18