MySQL 8.0.40
Source Code Documentation
ddl0impl-rtree.h
Go to the documentation of this file.
1
2/*****************************************************************************
3
4Copyright (c) 2020, 2024, Oracle and/or its affiliates.
5
6This program is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License, version 2.0, as published by the
8Free Software Foundation.
9
10This program is designed to work with certain software (including
11but not limited to OpenSSL) that is licensed under separate terms,
12as designated in a particular file or component or in included license
13documentation. The authors of MySQL hereby grant you an additional
14permission to link the program and your derivative works with the
15separately licensed software that they have either included with
16the program or referenced in the documentation.
17
18This program is distributed in the hope that it will be useful, but WITHOUT
19ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
21for more details.
22
23You should have received a copy of the GNU General Public License along with
24this program; if not, write to the Free Software Foundation, Inc.,
2551 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
27*****************************************************************************/
28
29/** @file include/ddl0impl-rtree.h
30 DDL RTree insert interface.
31 Created 2020-11-01 by Sunny Bains. */
32
33#ifndef ddl0impl_rtree_h
34#define ddl0impl_rtree_h
35
36#include "ddl0fts.h"
37#include "ddl0impl.h"
38#include "row0pread.h"
39
40namespace ddl {
41
42/** Class that caches RTree index tuples made from a single cluster
43index page scan, and then insert into corresponding index tree. */
45 public:
46 /** Constructor.
47 @param[in,out] ctx DDL context.
48 @param[in] index Index to be created */
49 RTree_inserter(Context &ctx, dict_index_t *index) noexcept;
50
51 /** Destructor */
52 ~RTree_inserter() noexcept;
53
54 /** @return true if initialization succeeded . */
55 [[nodiscard]] bool is_initialized() noexcept {
56 return m_dtuple_heap != nullptr && m_dml_heap != nullptr;
57 }
58
59 /** Get the index instance.
60 @return the index instance. */
61 [[nodiscard]] dict_index_t *get_index() noexcept { return m_index; }
62
63 /** Caches an index row into index tuple vector
64 @param[in] row Table row
65 @param[in] ext Externally stored column
66 prefixes, or nullptr */
67 void add_to_batch(const dtuple_t *row, const row_ext_t *ext) noexcept;
68
69 /** Insert the rows cached in the batch (m_dtuples).
70 @param[in] trx_id Transaction id.
71 @param[in,out] latch_release Called when a log free check is required.
72 @return DB_SUCCESS if successful, else error number */
73 [[nodiscard]] dberr_t batch_insert(trx_id_t trx_id,
74 Latch_release &&latch_release) noexcept;
75
76 /** Deep copy the fields pointing to the clustered index record. */
77 void deep_copy_tuples() noexcept { deep_copy_tuples(m_dtuples->begin()); }
78
79 private:
80 /** Cache index rows made from a cluster index scan. Usually
81 for rows on single cluster index page */
82 using Tuples = std::vector<dtuple_t *, ut::allocator<dtuple_t *>>;
83
84 /** Deep copy the fields pointing to the clustered index record.
85 @param[in] it Deep copy from this tuple onwards. */
86 void deep_copy_tuples(Tuples::iterator it) noexcept;
87
88 private:
89 /** vector used to cache index rows made from cluster index scan */
91
92 /** Memory heap for creating index tuples */
94
95 /** Memory heap for inserting the tuples */
97
98 /** the index being built */
100
101 /** Iterator to process m_dtuples */
102 Tuples::iterator m_iter{};
103
104 /** DDL context. */
106};
107
108} // namespace ddl
109
110#endif /* !ddl0impl-rtree_h */
Class that caches RTree index tuples made from a single cluster index page scan, and then insert into...
Definition: ddl0impl-rtree.h:44
std::vector< dtuple_t *, ut::allocator< dtuple_t * > > Tuples
Cache index rows made from a cluster index scan.
Definition: ddl0impl-rtree.h:82
Context & m_ctx
DDL context.
Definition: ddl0impl-rtree.h:105
mem_heap_t * m_dml_heap
Memory heap for inserting the tuples.
Definition: ddl0impl-rtree.h:96
dberr_t batch_insert(trx_id_t trx_id, Latch_release &&latch_release) noexcept
Insert the rows cached in the batch (m_dtuples).
Definition: ddl0rtree.cc:82
dict_index_t * get_index() noexcept
Get the index instance.
Definition: ddl0impl-rtree.h:61
Tuples * m_dtuples
vector used to cache index rows made from cluster index scan
Definition: ddl0impl-rtree.h:90
dict_index_t * m_index
the index being built
Definition: ddl0impl-rtree.h:99
void deep_copy_tuples() noexcept
Deep copy the fields pointing to the clustered index record.
Definition: ddl0impl-rtree.h:77
mem_heap_t * m_dtuple_heap
Memory heap for creating index tuples.
Definition: ddl0impl-rtree.h:93
Tuples::iterator m_iter
Iterator to process m_dtuples.
Definition: ddl0impl-rtree.h:102
~RTree_inserter() noexcept
Destructor.
Definition: ddl0rtree.cc:48
RTree_inserter(Context &ctx, dict_index_t *index) noexcept
Constructor.
Definition: ddl0rtree.cc:40
bool is_initialized() noexcept
Definition: ddl0impl-rtree.h:55
void add_to_batch(const dtuple_t *row, const row_ext_t *ext) noexcept
Caches an index row into index tuple vector.
Definition: ddl0rtree.cc:75
dberr_t
Definition: db0err.h:39
Create Full Text Index with (parallel) merge sort.
DDL implementation include file.
The general architecture is that the work is done in two phases, roughly the read and write phase.
Definition: btr0load.cc:42
std::function< dberr_t()> Latch_release
Called when a log free check is required.
Definition: ddl0impl.h:50
Json_data_extension ext
Definition: backend.cc:51
Parallel read interface.
DDL context/configuration.
Definition: ddl0ddl.h:321
Data structure for an index.
Definition: dict0mem.h:1046
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:694
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:302
Prefixes of externally stored columns.
Definition: row0ext.h:95
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:138