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
ad8d3aa8
Commit
ad8d3aa8
authored
3 years ago
by
Denis Smirnov
Browse files
Options
Downloads
Patches
Plain Diff
refactoring: make "add_ref" plan Nodes method
parent
f953e9e4
No related branches found
No related tags found
1 merge request
!1414
sbroad import
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/ir/expression.rs
+17
-20
17 additions, 20 deletions
src/ir/expression.rs
src/ir/operator.rs
+1
-2
1 addition, 2 deletions
src/ir/operator.rs
src/ir/operator/tests.rs
+1
-5
1 addition, 5 deletions
src/ir/operator/tests.rs
with
19 additions
and
27 deletions
src/ir/expression.rs
+
17
−
20
View file @
ad8d3aa8
...
...
@@ -98,16 +98,6 @@ impl Expression {
Err
(
QueryPlannerError
::
InvalidRow
)
}
/// Reference expression constructor.
#[must_use]
pub
fn
new_ref
(
parent
:
usize
,
targets
:
Option
<
Vec
<
usize
>>
,
position
:
usize
)
->
Self
{
Expression
::
Reference
{
parent
,
targets
,
position
,
}
}
// TODO: check that doesn't contain top-level aliases with the same names
/// Row expression constructor.
#[must_use]
...
...
@@ -146,6 +136,21 @@ impl Nodes {
pub
fn
add_const
(
&
mut
self
,
value
:
Value
)
->
usize
{
self
.push
(
Node
::
Expression
(
Expression
::
Constant
{
value
}))
}
/// Reference expression constructor.
pub
fn
add_ref
(
&
mut
self
,
parent
:
usize
,
targets
:
Option
<
Vec
<
usize
>>
,
position
:
usize
,
)
->
usize
{
let
r
=
Expression
::
Reference
{
parent
,
targets
,
position
,
};
self
.push
(
Node
::
Expression
(
r
))
}
}
impl
Plan
{
...
...
@@ -219,11 +224,7 @@ impl Plan {
};
let
new_targets
:
Vec
<
usize
>
=
targets
.iter
()
.copied
()
.collect
();
// Create new references and aliases. Save them to the plan nodes arena.
let
r_id
=
self
.nodes
.push
(
Node
::
Expression
(
Expression
::
new_ref
(
rel_node_id
,
Some
(
new_targets
),
pos
,
)));
let
r_id
=
self
.nodes
.add_ref
(
rel_node_id
,
Some
(
new_targets
),
pos
);
let
a_id
=
self
.nodes
.add_alias
(
&
name
,
r_id
)
?
;
aliases
.push
(
a_id
);
}
...
...
@@ -246,11 +247,7 @@ impl Plan {
map
.get
(
*
col
)
.map_or
(
false
,
|
pos
|
{
let
new_targets
:
Vec
<
usize
>
=
targets
.iter
()
.copied
()
.collect
();
// Create new references and aliases. Save them to the plan nodes arena.
let
r_id
=
self
.nodes
.push
(
Node
::
Expression
(
Expression
::
new_ref
(
rel_node_id
,
Some
(
new_targets
),
*
pos
,
)));
let
r_id
=
self
.nodes
.add_ref
(
rel_node_id
,
Some
(
new_targets
),
*
pos
);
if
let
Ok
(
a_id
)
=
self
.nodes
.add_alias
(
col
,
r_id
)
{
aliases
.push
(
a_id
);
true
...
...
This diff is collapsed.
Click to expand it.
src/ir/operator.rs
+
1
−
2
View file @
ad8d3aa8
...
...
@@ -327,8 +327,7 @@ impl Plan {
let
mut
refs
:
Vec
<
usize
>
=
Vec
::
new
();
for
(
pos
,
col
)
in
columns
.iter
()
.enumerate
()
{
let
r_id
=
nodes
.push
(
Node
::
Expression
(
Expression
::
new_ref
(
logical_id
,
None
,
pos
)));
let
r_id
=
nodes
.add_ref
(
logical_id
,
None
,
pos
);
let
alias_id
=
nodes
.add_alias
(
&
col
.name
,
r_id
)
?
;
refs
.push
(
alias_id
);
}
...
...
This diff is collapsed.
Click to expand it.
src/ir/operator/tests.rs
+
1
−
5
View file @
ad8d3aa8
...
...
@@ -150,11 +150,7 @@ fn selection() {
let
scan_id
=
plan
.add_scan
(
"t"
)
.unwrap
();
let
ref_a_id
=
plan
.nodes
.push
(
Node
::
Expression
(
Expression
::
new_ref
(
scan_id
+
1
,
Some
(
vec!
[
0
]),
0
,
)));
let
ref_a_id
=
plan
.nodes
.add_ref
(
scan_id
+
1
,
Some
(
vec!
[
0
]),
0
);
let
a_id
=
plan
.nodes
.add_alias
(
"a"
,
ref_a_id
)
.unwrap
();
let
const_id
=
plan
.nodes
.add_const
(
Value
::
number_from_str
(
"10"
)
.unwrap
());
let
gt_id
=
plan
.nodes
.push
(
Node
::
Expression
(
Expression
::
new_bool
(
...
...
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