55 *
66 * The MIT License
77 *
8- * @copyright Copyright (c) 2017-2021 TileDB, Inc.
8+ * @copyright Copyright (c) 2024 TileDB, Inc.
99 *
1010 * Permission is hereby granted, free of charge, to any person obtaining a copy
1111 * of this software and associated documentation files (the "Software"), to deal
3636#include < vector>
3737
3838#include " tiledb/common/common.h"
39+ #include " tiledb/common/pmr.h"
3940#include " tiledb/common/status.h"
4041#include " tiledb/sm/array_schema/domain.h"
4142#include " tiledb/sm/misc/tile_overlap.h"
@@ -48,6 +49,7 @@ namespace sm {
4849
4950class Buffer ;
5051class ConstBuffer ;
52+ class MemoryTracker ;
5153
5254enum class Datatype : uint8_t ;
5355enum class Layout : uint8_t ;
@@ -62,27 +64,19 @@ class RTree {
6264 /* ********************************* */
6365 /* CONSTRUCTORS & DESTRUCTORS */
6466 /* ********************************* */
67+ RTree () = delete ;
6568
6669 /* * Constructor. */
67- RTree ();
68-
69- /* * Constructor. */
70- RTree ( const Domain* domain, unsigned fanout );
70+ RTree (
71+ const Domain* domain,
72+ unsigned fanout,
73+ shared_ptr<MemoryTracker> memory_tracker );
7174
7275 /* * Destructor. */
7376 ~RTree ();
7477
75- /* * Copy constructor. This performs a deep copy. */
76- RTree (const RTree& rtree);
77-
78- /* * Move constructor. */
79- RTree (RTree&& rtree) noexcept ;
80-
81- /* * Copy-assign operator. This performs a deep copy. */
82- RTree& operator =(const RTree& rtree);
83-
84- /* * Move-assign operator. */
85- RTree& operator =(RTree&& rtree) noexcept ;
78+ DISABLE_COPY_AND_COPY_ASSIGN (RTree);
79+ DISABLE_MOVE_AND_MOVE_ASSIGN (RTree);
8680
8781 /* ********************************* */
8882 /* API */
@@ -125,7 +119,7 @@ class RTree {
125119 const NDRange& leaf (uint64_t leaf_idx) const ;
126120
127121 /* * Returns the leaves of the tree. */
128- const std ::vector<NDRange>& leaves () const ;
122+ const tdb::pmr ::vector<NDRange>& leaves () const ;
129123
130124 /* *
131125 * Returns the number of leaves that are stored in a (full) subtree
@@ -158,7 +152,7 @@ class RTree {
158152 * Sets the input MBRs as leaves. This will destroy the existing
159153 * RTree.
160154 */
161- Status set_leaves (const std ::vector<NDRange>& mbrs);
155+ Status set_leaves (const tdb::pmr ::vector<NDRange>& mbrs);
162156
163157 /* *
164158 * Resizes the leaf level. It destroys the upper levels
@@ -176,6 +170,14 @@ class RTree {
176170 void deserialize (
177171 Deserializer& deserializer, const Domain* domain, uint32_t version);
178172
173+ /* *
174+ * Resets the RTree with the input domain and fanout.
175+ *
176+ * @param domain The domain to use for the RTree.
177+ * @param fanout The fanout of the RTree.
178+ */
179+ void reset (const Domain* domain, unsigned fanout);
180+
179181 private:
180182 /* ********************************* */
181183 /* PRIVATE TYPE DEFINITIONS */
@@ -203,7 +205,7 @@ class RTree {
203205 * `levels_`, where the first level is the root. This is how
204206 * we can infer which tree level each `Level` object corresponds to.
205207 */
206- typedef std ::vector<NDRange> Level;
208+ typedef tdb::pmr ::vector<NDRange> Level;
207209
208210 /* *
209211 * Defines an R-Tree level entry, which corresponds to a node
@@ -222,6 +224,9 @@ class RTree {
222224 /* PRIVATE ATTRIBUTES */
223225 /* ********************************* */
224226
227+ /* * Memory tracker for the RTree. */
228+ shared_ptr<MemoryTracker> memory_tracker_;
229+
225230 /* *
226231 * The domain for which this R-tree provides an index.
227232 *
@@ -237,7 +242,7 @@ class RTree {
237242 * The tree levels. The first level is the root. Note that the root
238243 * always consists of a single MBR.
239244 */
240- std ::vector<Level> levels_;
245+ tdb::pmr ::vector<Level> levels_;
241246
242247 /* *
243248 * Stores the size of the buffer used to deserialize the data, used for
@@ -252,9 +257,6 @@ class RTree {
252257 /* * Builds a single tree level on top of the input level. */
253258 Level build_level (const Level& level);
254259
255- /* * Returns a deep copy of this RTree. */
256- RTree clone () const ;
257-
258260 /* *
259261 * Deserializes the contents of the object from the input buffer based
260262 * on the format version.
@@ -272,12 +274,6 @@ class RTree {
272274 * Applicable to versions >= 5
273275 */
274276 void deserialize_v5 (Deserializer& deserializer, const Domain* domain);
275-
276- /* *
277- * Swaps the contents (all field values) of this RTree with the
278- * given ``rtree``.
279- */
280- void swap (RTree& rtree);
281277};
282278
283279} // namespace sm
0 commit comments