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