MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
ob_lsm_iterator.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// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
12// Use of this source code is governed by a BSD-style license that can be
13// found in the LICENSE file. See the AUTHORS file for names of contributors.
14//
15// An iterator yields a sequence of key/value pairs from a source.
16// The following class defines the interface. Multiple implementations
17// are provided by this library. In particular, iterators are provided
18// to access the contents of a Table or a DB.
19//
20// Multiple threads can invoke const methods on an ObLsmIterator without
21// external synchronization, but if any of the threads may call a
22// non-const method, all threads accessing the same ObLsmIterator must use
23// external synchronization.
24
25#pragma once
26
27#include "common/lang/string_view.h"
28#include "common/sys/rc.h"
29
30namespace oceanbase {
31
41{
42public:
43 ObLsmIterator(){};
44
45 ObLsmIterator(const ObLsmIterator &) = delete;
46
47 ObLsmIterator &operator=(const ObLsmIterator &) = delete;
48
49 virtual ~ObLsmIterator(){};
50
56 virtual bool valid() const = 0;
57
61 virtual void next() = 0;
62
71 virtual string_view key() const = 0;
72
81 virtual string_view value() const = 0;
82
88 virtual void seek(const string_view &k) = 0;
89
94 virtual void seek_to_first() = 0;
95
100 virtual void seek_to_last() = 0;
101};
102
103} // namespace oceanbase
Abstract class for iterating over key-value pairs in an LSM-Tree.
Definition: ob_lsm_iterator.h:41
virtual void seek_to_first()=0
Positions the iterator at the first key-value pair in the source.
virtual string_view key() const =0
Returns the key of the current entry the iterator is positioned at.
virtual void seek_to_last()=0
Positions the iterator at the last key-value pair in the source.
virtual void next()=0
Moves the iterator to the next key-value pair in the source.
virtual void seek(const string_view &k)=0
Positions the iterator at the first entry with a key greater than or equal to the specified key.
virtual string_view value() const =0
Returns the value of the current entry the iterator is positioned at.
virtual bool valid() const =0
Checks if the iterator is currently positioned at a valid key-value pair.