@@ -39,8 +39,8 @@ void LogicalCreateRTreeIndex::ResolveColumnBindings(ColumnBindingResolver &res,
3939 [&](unique_ptr<Expression> *child) { res.VisitExpression (child); });
4040}
4141
42- static unique_ptr< PhysicalOperator> CreateNullFilter (const LogicalOperator &op , const vector<LogicalType> &types ,
43- ClientContext &context) {
42+ static PhysicalOperator & CreateNullFilter (PhysicalPlanGenerator &generator , const LogicalOperator &op ,
43+ const vector<LogicalType> &types, ClientContext &context) {
4444 vector<unique_ptr<Expression>> filter_select_list;
4545
4646 // Filter NOT NULL on the GEOMETRY column
@@ -66,14 +66,13 @@ static unique_ptr<PhysicalOperator> CreateNullFilter(const LogicalOperator &op,
6666 // Combine into an AND
6767 auto and_expr = make_uniq_base<Expression, BoundConjunctionExpression>(
6868 ExpressionType::CONJUNCTION_AND, std::move (is_not_null_expr), std::move (is_not_empty_expr));
69-
7069 filter_select_list.push_back (std::move (and_expr));
7170
72- return make_uniq <PhysicalFilter>(types, std::move (filter_select_list), op.estimated_cardinality );
71+ return generator. Make <PhysicalFilter>(types, std::move (filter_select_list), op.estimated_cardinality );
7372}
7473
75- static unique_ptr< PhysicalOperator>
76- CreateBoundingBoxProjection ( const LogicalOperator &op, const vector<LogicalType> &types, ClientContext &context) {
74+ static PhysicalOperator & CreateBoundingBoxProjection (PhysicalPlanGenerator &planner, const LogicalOperator &op,
75+ const vector<LogicalType> &types, ClientContext &context) {
7776 auto &catalog = Catalog::GetSystemCatalog (context);
7877
7978 // Get the bounding box function
@@ -96,11 +95,11 @@ CreateBoundingBoxProjection(const LogicalOperator &op, const vector<LogicalType>
9695 select_list.push_back (std::move (bbox_expr));
9796 select_list.push_back (std::move (rowid_expr));
9897
99- return make_uniq <PhysicalProjection>(types, std::move (select_list), op.estimated_cardinality );
98+ return planner. Make <PhysicalProjection>(types, std::move (select_list), op.estimated_cardinality );
10099}
101100
102- static unique_ptr< PhysicalOperator> CreateOrderByMinX (const LogicalOperator &op , const vector<LogicalType> &types ,
103- ClientContext &context) {
101+ static PhysicalOperator & CreateOrderByMinX (PhysicalPlanGenerator &planner , const LogicalOperator &op ,
102+ const vector<LogicalType> &types, ClientContext &context) {
104103 auto &catalog = Catalog::GetSystemCatalog (context);
105104
106105 // Get the centroid value function
@@ -130,14 +129,15 @@ static unique_ptr<PhysicalOperator> CreateOrderByMinX(const LogicalOperator &op,
130129 vector<BoundOrderByNode> orders;
131130 orders.emplace_back (OrderType::ASCENDING, OrderByNullType::NULLS_FIRST, std::move (xmin_expr));
132131 vector<idx_t > projections = {0 , 1 };
133- return make_uniq <PhysicalOrder>(types, std::move (orders), projections, op.estimated_cardinality );
132+ return planner. Make <PhysicalOrder>(types, std::move (orders), projections, op.estimated_cardinality );
134133}
135134
136- unique_ptr< PhysicalOperator> RTreeIndex::CreatePlan (PlanIndexInput &input) {
135+ PhysicalOperator & RTreeIndex::CreatePlan (PlanIndexInput &input) {
137136
138137 auto &op = input.op ;
139138 auto &table_scan = input.table_scan ;
140139 auto &context = input.context ;
140+ auto &planner = input.planner ;
141141
142142 // generate a physical plan for the parallel index creation which consists of the following operators
143143 // table scan - projection (for expression execution) - filter (NOT NULL) - order - create index
@@ -175,38 +175,35 @@ unique_ptr<PhysicalOperator> RTreeIndex::CreatePlan(PlanIndexInput &input) {
175175 select_list.push_back (make_uniq<BoundReferenceExpression>(LogicalType::ROW_TYPE, op.info ->scan_types .size () - 1 ));
176176
177177 // Project the expressions
178- auto projection = make_uniq<PhysicalProjection>(new_column_types, std::move (select_list), op.estimated_cardinality );
179- projection->children .push_back (std::move (table_scan));
178+ auto &projection =
179+ planner.Make <PhysicalProjection>(new_column_types, std::move (select_list), op.estimated_cardinality );
180+ projection.children .push_back (table_scan);
180181
181182 // Filter operator for (IS_NOT_NULL) and (NOT ST_IsEmpty) on the geometry column
182- auto null_filter = CreateNullFilter (op, new_column_types, context);
183- null_filter-> children .push_back (std::move ( projection) );
183+ auto & null_filter = CreateNullFilter (planner, op, new_column_types, context);
184+ null_filter. children .push_back (projection);
184185
185186 // Project the bounding box and the row ID
186187 vector<LogicalType> projected_types = {GeoTypes::BOX_2DF (), LogicalType::ROW_TYPE};
187- auto bbox_proj = CreateBoundingBoxProjection (op, projected_types, context);
188- bbox_proj-> children .push_back (std::move ( null_filter) );
188+ auto & bbox_proj = CreateBoundingBoxProjection (planner, op, projected_types, context);
189+ bbox_proj. children .push_back (null_filter);
189190
190191 // Create an ORDER_BY operator to sort the bounding boxes by the xmin value
191- auto physical_order = CreateOrderByMinX (op, projected_types, context);
192- physical_order-> children .push_back (std::move ( bbox_proj) );
192+ auto & physical_order = CreateOrderByMinX (planner, op, projected_types, context);
193+ physical_order. children .push_back (bbox_proj);
193194
194195 // Now finally create the actual physical create index operator
195- auto physical_create_index =
196- make_uniq<PhysicalCreateRTreeIndex>(op, op.table , op.info ->column_ids , std::move (op.info ),
197- std::move (op.unbound_expressions ), op.estimated_cardinality );
198-
199- physical_create_index->children .push_back (std::move (physical_order));
200-
201- return std::move (physical_create_index);
196+ auto &physical_create_index =
197+ planner.Make <PhysicalCreateRTreeIndex>(op, op.table , op.info ->column_ids , std::move (op.info ),
198+ std::move (op.unbound_expressions ), op.estimated_cardinality );
199+ physical_create_index.children .push_back (physical_order);
200+ return physical_create_index;
202201}
203202
204203// TODO: Remove this
205- unique_ptr<PhysicalOperator> LogicalCreateRTreeIndex::CreatePlan (ClientContext &context,
206- PhysicalPlanGenerator &generator) {
207-
208- auto table_scan = generator.CreatePlan (std::move (children[0 ]));
204+ PhysicalOperator &LogicalCreateRTreeIndex::CreatePlan (ClientContext &context, PhysicalPlanGenerator &planner) {
209205
206+ auto &table_scan = planner.CreatePlan (*children[0 ]);
210207 auto &op = *this ;
211208
212209 // generate a physical plan for the parallel index creation which consists of the following operators
@@ -235,7 +232,7 @@ unique_ptr<PhysicalOperator> LogicalCreateRTreeIndex::CreatePlan(ClientContext &
235232 D_ASSERT (op.info ->index_type == RTreeIndex::TYPE_NAME);
236233
237234 // table scan operator for index key columns and row IDs
238- generator .dependencies .AddDependency (op.table );
235+ planner .dependencies .AddDependency (op.table );
239236
240237 D_ASSERT (op.info ->scan_types .size () - 1 <= op.info ->names .size ());
241238 D_ASSERT (op.info ->scan_types .size () - 1 <= op.info ->column_ids .size ());
@@ -255,30 +252,29 @@ unique_ptr<PhysicalOperator> LogicalCreateRTreeIndex::CreatePlan(ClientContext &
255252 select_list.push_back (make_uniq<BoundReferenceExpression>(LogicalType::ROW_TYPE, op.info ->scan_types .size () - 1 ));
256253
257254 // Project the expressions
258- auto projection = make_uniq<PhysicalProjection>(new_column_types, std::move (select_list), op.estimated_cardinality );
259- projection->children .push_back (std::move (table_scan));
255+ auto &projection =
256+ planner.Make <PhysicalProjection>(new_column_types, std::move (select_list), op.estimated_cardinality );
257+ projection.children .push_back (table_scan);
260258
261259 // Filter operator for (IS_NOT_NULL) and (NOT ST_IsEmpty) on the geometry column
262- auto null_filter = CreateNullFilter (op, new_column_types, context);
263- null_filter-> children .push_back (std::move ( projection) );
260+ auto & null_filter = CreateNullFilter (planner, op, new_column_types, context);
261+ null_filter. children .push_back (projection);
264262
265263 // Project the bounding box and the row ID
266264 vector<LogicalType> projected_types = {GeoTypes::BOX_2DF (), LogicalType::ROW_TYPE};
267- auto bbox_proj = CreateBoundingBoxProjection (op, projected_types, context);
268- bbox_proj-> children .push_back (std::move ( null_filter) );
265+ auto & bbox_proj = CreateBoundingBoxProjection (planner, op, projected_types, context);
266+ bbox_proj. children .push_back (null_filter);
269267
270268 // Create an ORDER_BY operator to sort the bounding boxes by the xmin value
271- auto physical_order = CreateOrderByMinX (op, projected_types, context);
272- physical_order-> children .push_back (std::move ( bbox_proj) );
269+ auto & physical_order = CreateOrderByMinX (planner, op, projected_types, context);
270+ physical_order. children .push_back (bbox_proj);
273271
274272 // Now finally create the actual physical create index operator
275- auto physical_create_index =
276- make_uniq<PhysicalCreateRTreeIndex>(op, op.table , op.info ->column_ids , std::move (op.info ),
277- std::move (op.unbound_expressions ), op.estimated_cardinality );
278-
279- physical_create_index->children .push_back (std::move (physical_order));
280-
281- return std::move (physical_create_index);
273+ auto &physical_create_index =
274+ planner.Make <PhysicalCreateRTreeIndex>(op, op.table , op.info ->column_ids , std::move (op.info ),
275+ std::move (op.unbound_expressions ), op.estimated_cardinality );
276+ physical_create_index.children .push_back (physical_order);
277+ return physical_create_index;
282278}
283279
284280} // namespace duckdb
0 commit comments