MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
ob_lsm_wal.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2 miniob is licensed under Mulan PSL v2.
3 You can use this software according to the terms and conditions of the Mulan PSL v2.
4 You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7 EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8 MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9 See the Mulan PSL v2 for more details. */
10
11//
12// Created by Ping Xu(haibarapink@gmail.com) on 2025/2/9.
13//
14#pragma once
15
16#include "common/lang/mutex.h"
17#include "common/sys/rc.h"
18#include "oblsm/util/ob_file_writer.h"
19
20namespace oceanbase {
21
28{
30 uint64_t seq;
32 std::string key;
34 std::string val;
35
43 WalRecord(uint64_t s, std::string k, std::string v) : seq(s), key(std::move(k)), val(std::move(v)) {}
44};
45
66class WAL
67{
68public:
72 WAL() {}
73
78 ~WAL() = default;
79
88 RC open(const std::string &filename) { return RC::UNIMPLEMENTED; }
89
100 RC recover(const std::string &wal_file, std::vector<WalRecord> &wal_records);
101
112 RC put(uint64_t seq, std::string_view key, std::string_view val);
113
120 RC sync() { return RC::UNIMPLEMENTED; }
121
122 const string &filename() const { return filename_; }
123
124private:
125 string filename_;
126};
127} // namespace oceanbase
Definition: ob_lsm_wal.h:67
RC put(uint64_t seq, std::string_view key, std::string_view val)
Writes a key-value pair to the WAL.
Definition: ob_lsm_wal.cpp:21
RC sync()
Synchronizes the WAL to disk. Forces any buffered data in the WAL to be written to the underlying sto...
Definition: ob_lsm_wal.h:120
WAL()
Default constructor for the Wal class.
Definition: ob_lsm_wal.h:72
RC open(const std::string &filename)
Opens the WAL file for writing. This function initializes the file writer and prepares the WAL file f...
Definition: ob_lsm_wal.h:88
RC recover(const std::string &wal_file, std::vector< WalRecord > &wal_records)
Recovers data from a specified WAL file.
Definition: ob_lsm_wal.cpp:16
~WAL()=default
Destructor for the Wal class. Ensures that the file writer is closed when the Wal object is destroyed...
A structure representing a record in the Write-Ahead Log (WAL). Each record contains a sequence numbe...
Definition: ob_lsm_wal.h:28
uint64_t seq
Definition: ob_lsm_wal.h:30
WalRecord(uint64_t s, std::string k, std::string v)
Parameterized constructor to create a new WalRecord object.
Definition: ob_lsm_wal.h:43
std::string key
Definition: ob_lsm_wal.h:32
std::string val
Definition: ob_lsm_wal.h:34