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
91b9b11d
Verified
Commit
91b9b11d
authored
2 years ago
by
Denis Smirnov
Browse files
Options
Downloads
Patches
Plain Diff
refactoring: temporary spaces structure
parent
a74b67de
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
sbroad-core/src/backend/sql/ir.rs
+15
-30
15 additions, 30 deletions
sbroad-core/src/backend/sql/ir.rs
with
15 additions
and
30 deletions
sbroad-core/src/backend/sql/ir.rs
+
15
−
30
View file @
91b9b11d
...
...
@@ -137,53 +137,38 @@ impl From<PatternWithParams> for String {
}
}
pub
struct
TmpSpaceList
{
index
:
AHashMap
<
String
,
usize
>
,
spaces
:
Vec
<
TmpSpace
>
,
pub
struct
TmpSpaceMap
{
inner
:
AHashMap
<
String
,
TmpSpace
>
,
}
impl
Iterator
for
TmpSpace
List
{
impl
Iterator
for
TmpSpace
Map
{
type
Item
=
TmpSpace
;
fn
next
(
&
mut
self
)
->
Option
<
Self
::
Item
>
{
self
.
spaces
.pop
(
)
self
.
inner
.drain
()
.next
()
.map
(|(
_
,
v
)|
v
)
}
}
impl
TmpSpace
List
{
impl
TmpSpace
Map
{
fn
with_capacity
(
capacity
:
usize
)
->
Self
{
TmpSpaceList
{
index
:
AHashMap
::
with_capacity
(
capacity
),
spaces
:
Vec
::
with_capacity
(
capacity
),
TmpSpaceMap
{
inner
:
AHashMap
::
with_capacity
(
capacity
),
}
}
fn
get
(
&
self
,
name
:
&
str
)
->
Result
<
Option
<&
TmpSpace
>
,
SbroadError
>
{
match
self
.index
.get
(
name
)
{
Some
(
index
)
=>
{
let
space
=
self
.spaces
.get
(
*
index
)
.ok_or_else
(||
{
SbroadError
::
NotFound
(
Entity
::
Space
,
format!
(
"in the temporary space list ({name})"
),
)
})
?
;
Ok
(
Some
(
space
))
}
None
=>
Ok
(
None
),
}
fn
get
(
&
self
,
name
:
&
str
)
->
Option
<&
TmpSpace
>
{
self
.inner
.get
(
name
)
}
fn
insert
(
&
mut
self
,
name
:
String
,
space
:
TmpSpace
)
->
Result
<
(),
SbroadError
>
{
if
self
.in
dex
.contains_key
(
&
name
)
{
if
self
.in
ner
.contains_key
(
&
name
)
{
return
Err
(
SbroadError
::
FailedTo
(
Action
::
Insert
,
Some
(
Entity
::
Space
),
format!
(
"in the temporary space
list
({name})"
),
format!
(
"in the temporary space
map
({name})"
),
));
}
let
index
=
self
.spaces
.len
();
self
.index
.insert
(
name
,
index
);
self
.spaces
.push
(
space
);
self
.inner
.insert
(
name
,
space
);
Ok
(())
}
}
...
...
@@ -238,10 +223,10 @@ impl ExecutionPlan {
nodes
:
&
[
&
SyntaxData
],
buckets
:
&
Buckets
,
name_base
:
&
str
,
)
->
Result
<
(
PatternWithParams
,
TmpSpace
List
),
SbroadError
>
{
)
->
Result
<
(
PatternWithParams
,
TmpSpace
Map
),
SbroadError
>
{
let
vtable_engine
=
self
.vtable_engine
()
?
;
let
capacity
=
self
.get_vtables
()
.map_or
(
1
,
HashMap
::
len
);
let
mut
tmp_spaces
=
TmpSpace
List
::
with_capacity
(
capacity
);
let
mut
tmp_spaces
=
TmpSpace
Map
::
with_capacity
(
capacity
);
let
(
sql
,
params
)
=
child_span
(
"
\"
syntax.ordered.sql
\"
"
,
||
{
let
mut
params
:
Vec
<
Value
>
=
Vec
::
new
();
...
...
@@ -420,7 +405,7 @@ impl ExecutionPlan {
)
})
?
;
// BETWEEN can refer to the same virtual table multiple times.
if
tmp_spaces
.get
(
&
name
)
?
.is_none
()
{
if
tmp_spaces
.get
(
&
name
)
.is_none
()
{
let
space
=
TmpSpace
::
initialize
(
self
,
name_base
,
...
...
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