Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
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
picodata
Commits
dbfcdbba
Verified
Commit
dbfcdbba
authored
2 years ago
by
Denis Smirnov
Browse files
Options
Downloads
Patches
Plain Diff
perf: improve performance in new_columns() function
parent
f9d584e9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1414
sbroad import
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ir/expression.rs
+12
-4
12 additions, 4 deletions
src/ir/expression.rs
with
12 additions
and
4 deletions
src/ir/expression.rs
+
12
−
4
View file @
dbfcdbba
...
...
@@ -318,8 +318,8 @@ impl Plan {
)));
}
}
let
mut
result
:
Vec
<
usize
>
=
Vec
::
with_capacity
(
col_names
.len
()
);
let
mut
result
:
Vec
<
usize
>
=
Vec
::
new
(
);
if
col_names
.is_empty
()
{
let
required_targets
=
if
is_join
{
targets
}
else
{
&
targets
[
0
..
1
]
};
...
...
@@ -353,7 +353,7 @@ impl Plan {
}
else
{
return
Err
(
QueryPlannerError
::
InvalidRelation
);
};
result
.reserve
(
child_row_list
.len
());
for
(
pos
,
alias_node
)
in
child_row_list
.iter
()
.enumerate
()
{
let
name
:
String
=
if
let
Node
::
Expression
(
Expression
::
Alias
{
ref
name
,
..
})
=
...
...
@@ -387,6 +387,7 @@ impl Plan {
return
Ok
(
result
);
}
result
.reserve
(
col_names
.len
());
let
target_child
:
usize
=
if
let
Some
(
target
)
=
targets
.get
(
0
)
{
*
target
}
else
{
...
...
@@ -400,6 +401,10 @@ impl Plan {
));
};
let
mut
col_names_set
:
HashSet
<&
str
>
=
HashSet
::
with_capacity
(
col_names
.len
());
for
col_name
in
col_names
{
col_names_set
.insert
(
col_name
);
}
let
map
:
HashMap
<&
str
,
usize
,
RandomState
>
=
if
let
Node
::
Relational
(
relational_op
)
=
self
.get_node
(
child_node
)
?
{
let
output_id
=
relational_op
.output
();
...
...
@@ -407,10 +412,13 @@ impl Plan {
if
let
Expression
::
Row
{
list
,
..
}
=
output
{
let
state
=
RandomState
::
new
();
let
mut
map
:
HashMap
<&
str
,
usize
,
RandomState
>
=
HashMap
::
with_capacity_and_hasher
(
list
.len
(),
state
);
HashMap
::
with_capacity_and_hasher
(
col_names
.len
(),
state
);
for
(
pos
,
col_id
)
in
list
.iter
()
.enumerate
()
{
let
alias
=
self
.get_expression_node
(
*
col_id
)
?
;
if
let
Expression
::
Alias
{
ref
name
,
..
}
=
alias
{
if
!
col_names_set
.contains
(
&
name
.as_str
())
{
continue
;
}
if
map
.insert
(
name
,
pos
)
.is_some
()
{
return
Err
(
QueryPlannerError
::
CustomError
(
format!
(
"Duplicate column name {} at position {}"
,
...
...
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