Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sbroad
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
sbroad
Commits
434969a9
Verified
Commit
434969a9
authored
1 year ago
by
Denis Smirnov
Browse files
Options
Downloads
Patches
Plain Diff
perf: improve take_subtree() pre-allocation accuracy
parent
0640b181
No related branches found
No related tags found
2 merge requests
!427
Re-implementation: backend syntax tree for local SQL
,
!421
support CTE
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sbroad-core/src/executor/ir.rs
+10
-10
10 additions, 10 deletions
sbroad-core/src/executor/ir.rs
with
10 additions
and
10 deletions
sbroad-core/src/executor/ir.rs
+
10
−
10
View file @
434969a9
...
...
@@ -369,21 +369,22 @@ impl ExecutionPlan {
/// - Plan is in invalid state
#[allow(clippy::too_many_lines)]
pub
fn
take_subtree
(
&
mut
self
,
top_id
:
usize
)
->
Result
<
Self
,
SbroadError
>
{
let
nodes_capacity
=
self
.get_ir_plan
()
.nodes
.len
();
// Get the subtree nodes indexes.
let
plan
=
self
.get_ir_plan
();
let
mut
subtree
=
PostOrder
::
with_capacity
(|
node
|
plan
.exec_plan_subtree_iter
(
node
),
plan
.next_id
());
subtree
.populate_nodes
(
top_id
);
let
nodes
=
subtree
.take_nodes
();
// Translates the original plan's node id to the new sub-plan one.
let
mut
translation
:
AHashMap
<
usize
,
usize
>
=
AHashMap
::
with_capacity
(
nodes
_capacity
);
let
mut
translation
:
AHashMap
<
usize
,
usize
>
=
AHashMap
::
with_capacity
(
nodes
.len
()
);
let
vtables_capacity
=
self
.get_vtables
()
.map_or_else
(||
1
,
HashMap
::
len
);
// Map of { plan node_id -> virtual table }.
let
mut
new_vtables
:
HashMap
<
usize
,
Rc
<
VirtualTable
>>
=
HashMap
::
with_capacity
(
vtables_capacity
);
let
mut
new_plan
=
Plan
::
new
();
new_plan
.nodes
.reserve
(
nodes_capacity
);
let
mut
subtree
=
PostOrder
::
with_capacity
(
|
node
|
self
.get_ir_plan
()
.exec_plan_subtree_iter
(
node
),
self
.get_ir_plan
()
.next_id
(),
);
subtree
.populate_nodes
(
top_id
);
let
nodes
=
subtree
.take_nodes
();
new_plan
.nodes
.reserve
(
nodes
.len
());
for
(
_
,
node_id
)
in
nodes
{
// We have already processed this node (sub-queries in BETWEEN
// and CTEs can be referred twice).
...
...
@@ -604,7 +605,6 @@ impl ExecutionPlan {
}
new_plan
.stash_constants
()
?
;
new_plan
.nodes
.shrink_to_fit
();
new_plan
.options
=
self
.get_ir_plan
()
.options
.clone
();
let
vtables
=
if
new_vtables
.is_empty
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment