MySQL 26.10.0
Source Code Documentation
log0parsed_index_lru_cache.h
Go to the documentation of this file.
1/* Copyright (c) 2026, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify it under
4the terms of the GNU General Public License, version 2.0, as published by the
5Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
18for more details.
19
20You should have received a copy of the GNU General Public License along with
21this program; if not, write to the Free Software Foundation, Inc.,
2251 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#include <memory>
26#include <string>
27#include <string_view>
28
29#include "dict0mem.h"
30#include "ut0prefix_cache.h"
31
32/** Parsed index cache for redo parsing.
33
34This wrapper binds ut::prefix_cache<byte, Value> to the redo parsing use
35case where Value is a unique_ptr owning dict_index_t with custom cleanup. */
37 public:
38 /** A single dict_index_t + dict_table_t takes several kilobytes.
39 InnoDB recovery logic needs one cache for the main thread doing the parsing,
40 and one for each of srv_n_read_io_threads. */
41 static constexpr size_t k_capacity = 100;
42
43 using sequence = std::basic_string<byte>;
44 using sequence_view = std::basic_string_view<byte>;
45
49
51 Value *cached = m_cache.find_value_for_prefix_of(buffer);
52 if (cached == nullptr) {
53 return nullptr;
54 }
55 return cached->get();
56 }
57
59 return m_cache.insert(key, Value(index));
60 }
61
62 private:
64 void operator()(dict_index_t *idx) const {
65 if (idx == nullptr) {
66 return;
67 }
68
69 dict_table_t *table = idx->table;
72 }
73 };
74
75 using Value = std::unique_ptr<dict_index_t, Index_deleter>;
76
77 private:
79};
Parsed index cache for redo parsing.
Definition: log0parsed_index_lru_cache.h:36
std::unique_ptr< dict_index_t, Index_deleter > Value
Definition: log0parsed_index_lru_cache.h:75
Parsed_index_lru_cache(const Parsed_index_lru_cache &)=delete
ut::prefix_cache< byte, Value > m_cache
Definition: log0parsed_index_lru_cache.h:78
static constexpr size_t k_capacity
A single dict_index_t + dict_table_t takes several kilobytes.
Definition: log0parsed_index_lru_cache.h:41
bool insert_mru(sequence_view key, dict_index_t *index)
Definition: log0parsed_index_lru_cache.h:58
std::basic_string< byte > sequence
Definition: log0parsed_index_lru_cache.h:43
Parsed_index_lru_cache()
Definition: log0parsed_index_lru_cache.h:46
std::basic_string_view< byte > sequence_view
Definition: log0parsed_index_lru_cache.h:44
Parsed_index_lru_cache & operator=(const Parsed_index_lru_cache &)=delete
dict_index_t * lookup(sequence_view &buffer)
Definition: log0parsed_index_lru_cache.h:50
Bounded cache for prefix lookups with MRU/LRU recency tracking.
Definition: ut0prefix_cache.h:51
void dict_mem_index_free(dict_index_t *index)
Frees an index memory object.
Definition: dict0mem.cc:778
Data dictionary memory object creation.
void dict_mem_table_free(dict_table_t *table)
Free a table memory object.
Definition: mem.cc:92
static PFS_engine_table_share_proxy table
Definition: pfs.cc:61
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
required string key
Definition: replication_asynchronous_connection_failover.proto:60
Definition: log0parsed_index_lru_cache.h:63
void operator()(dict_index_t *idx) const
Definition: log0parsed_index_lru_cache.h:64
Data structure for an index.
Definition: dict0mem.h:1069
dict_table_t * table
back pointer to table
Definition: dict0mem.h:1083
Data structure for a database table.
Definition: dict0mem.h:1927
static double cached
Definition: xcom_statistics.cc:101