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
e2bb7323
Verified
Commit
e2bb7323
authored
2 years ago
by
Denis Smirnov
Browse files
Options
Downloads
Patches
Plain Diff
refactoring: move duplicating code to a vtable method
parent
795ca021
Loading
Loading
1 merge request
!1414
sbroad import
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sbroad-core/src/backend/sql/ir.rs
+3
-34
3 additions, 34 deletions
sbroad-core/src/backend/sql/ir.rs
sbroad-core/src/executor/vtable.rs
+23
-0
23 additions, 0 deletions
sbroad-core/src/executor/vtable.rs
with
26 additions
and
34 deletions
sbroad-core/src/backend/sql/ir.rs
+
3
−
34
View file @
e2bb7323
...
...
@@ -10,7 +10,6 @@ use crate::debug;
use
crate
::
errors
::
QueryPlannerError
;
use
crate
::
executor
::
bucket
::
Buckets
;
use
crate
::
executor
::
ir
::
ExecutionPlan
;
use
crate
::
executor
::
vtable
::
VTableTuple
;
use
crate
::
ir
::
expression
::
Expression
;
use
crate
::
ir
::
operator
::
Relational
;
use
crate
::
ir
::
value
::{
EncodedValue
,
Value
};
...
...
@@ -163,22 +162,7 @@ impl ExecutionPlan {
}
SyntaxData
::
VTable
(
motion_id
)
=>
{
let
vtable
=
self
.get_motion_vtable
(
*
motion_id
)
?
;
let
tuples
:
Vec
<&
VTableTuple
>
=
match
buckets
{
Buckets
::
All
=>
vtable
.get_tuples
()
.iter
()
.collect
(),
Buckets
::
Filtered
(
bucket_ids
)
=>
{
if
vtable
.get_index
()
.is_empty
()
{
// TODO: Implement selection push-down (join_linker3_test).
vtable
.get_tuples
()
.iter
()
.collect
()
}
else
{
bucket_ids
.iter
()
.filter_map
(|
bucket_id
|
vtable
.get_index
()
.get
(
bucket_id
))
.flatten
()
.filter_map
(|
pos
|
vtable
.get_tuples
()
.get
(
*
pos
))
.collect
()
}
}
};
let
tuples
=
(
*
vtable
)
.get_tuples_with_buckets
(
buckets
);
for
t
in
tuples
{
for
v
in
t
{
params
.push
(
v
.clone
());
...
...
@@ -364,22 +348,7 @@ impl ExecutionPlan {
.join
(
","
)
};
let
tuples
:
Vec
<&
VTableTuple
>
=
match
buckets
{
Buckets
::
All
=>
vtable
.get_tuples
()
.iter
()
.collect
(),
Buckets
::
Filtered
(
bucket_ids
)
=>
{
if
vtable
.get_index
()
.is_empty
()
{
// TODO: Implement selection push-down (join_linker3_test).
vtable
.get_tuples
()
.iter
()
.collect
()
}
else
{
bucket_ids
.iter
()
.filter_map
(|
bucket_id
|
vtable
.get_index
()
.get
(
bucket_id
))
.flatten
()
.filter_map
(|
pos
|
vtable
.get_tuples
()
.get
(
*
pos
))
.collect
()
}
}
};
let
tuples
=
(
*
vtable
)
.get_tuples_with_buckets
(
buckets
);
if
tuples
.is_empty
()
{
let
values
=
(
0
..
cols_count
)
...
...
@@ -417,7 +386,7 @@ impl ExecutionPlan {
})
?
;
for
t
in
tuples
{
for
v
in
t
{
for
v
in
t
.iter
()
{
params
.push
(
v
.clone
());
}
}
...
...
This diff is collapsed.
Click to expand it.
sbroad-core/src/executor/vtable.rs
+
23
−
0
View file @
e2bb7323
...
...
@@ -5,6 +5,7 @@ use std::vec;
use
serde
::{
Deserialize
,
Serialize
};
use
crate
::
errors
::
QueryPlannerError
;
use
crate
::
executor
::
bucket
::
Buckets
;
use
crate
::
ir
::
relation
::
Column
;
use
crate
::
ir
::
transformation
::
redistribution
::{
MotionKey
,
Target
};
use
crate
::
ir
::
value
::
Value
;
...
...
@@ -129,6 +130,28 @@ impl VirtualTable {
self
.index
=
index
.into
();
}
/// Get vtable's tuples corresponding to the buckets.
#[must_use]
pub
fn
get_tuples_with_buckets
(
&
self
,
buckets
:
&
Buckets
)
->
Vec
<&
VTableTuple
>
{
let
tuples
:
Vec
<&
VTableTuple
>
=
match
buckets
{
Buckets
::
All
=>
self
.get_tuples
()
.iter
()
.collect
(),
Buckets
::
Filtered
(
bucket_ids
)
=>
{
if
self
.get_index
()
.is_empty
()
{
// TODO: Implement selection push-down (join_linker3_test).
self
.get_tuples
()
.iter
()
.collect
()
}
else
{
bucket_ids
.iter
()
.filter_map
(|
bucket_id
|
self
.get_index
()
.get
(
bucket_id
))
.flatten
()
.filter_map
(|
pos
|
self
.get_tuples
()
.get
(
*
pos
))
.collect
()
}
}
};
tuples
}
/// Get virtual table tuples' values, participating in the distribution key.
///
/// # Errors
...
...
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