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
79267b4e
Commit
79267b4e
authored
1 year ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
refactor: extract function ddl_meta_space_update_operable
parent
e9b1b821
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!555
Feat/ddl drop space
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/storage.rs
+23
-0
23 additions, 0 deletions
src/storage.rs
src/traft/node.rs
+7
-46
7 additions, 46 deletions
src/traft/node.rs
with
30 additions
and
46 deletions
src/storage.rs
+
23
−
0
View file @
79267b4e
...
@@ -1670,6 +1670,29 @@ impl ToEntryIter for Indexes {
...
@@ -1670,6 +1670,29 @@ impl ToEntryIter for Indexes {
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
// ddl meta
////////////////////////////////////////////////////////////////////////////////
/// Updates the field `"operable"` for a space with id `space_id` and any
/// necessary entities (currently all existing indexes).
///
/// This function is called when applying the different ddl operations.
pub
fn
ddl_meta_space_update_operable
(
storage
:
&
Clusterwide
,
space_id
:
SpaceId
,
operable
:
bool
,
)
->
traft
::
Result
<
()
>
{
storage
.spaces
.update_operable
(
space_id
,
operable
)
?
;
let
iter
=
storage
.indexes
.by_space_id
(
space_id
)
?
;
for
index
in
iter
{
storage
.indexes
.update_operable
(
index
.space_id
,
index
.id
,
operable
)
?
;
}
Ok
(())
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// ddl
// ddl
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
src/traft/node.rs
+
7
−
46
View file @
79267b4e
...
@@ -13,10 +13,10 @@ use crate::loop_start;
...
@@ -13,10 +13,10 @@ use crate::loop_start;
use
crate
::
r
#
loop
::
FlowControl
;
use
crate
::
r
#
loop
::
FlowControl
;
use
crate
::
rpc
;
use
crate
::
rpc
;
use
crate
::
schema
::{
Distribution
,
IndexDef
,
SpaceDef
};
use
crate
::
schema
::{
Distribution
,
IndexDef
,
SpaceDef
};
use
crate
::
storage
::
ddl_abort_on_master
;
use
crate
::
storage
::
local_schema_version
;
use
crate
::
storage
::
local_schema_version
;
use
crate
::
storage
::
SnapshotData
;
use
crate
::
storage
::
SnapshotData
;
use
crate
::
storage
::
ToEntryIter
as
_
;
use
crate
::
storage
::
ToEntryIter
as
_
;
use
crate
::
storage
::{
ddl_abort_on_master
,
ddl_meta_space_update_operable
};
use
crate
::
storage
::{
Clusterwide
,
ClusterwideSpaceId
,
PropertyName
};
use
crate
::
storage
::{
Clusterwide
,
ClusterwideSpaceId
,
PropertyName
};
use
crate
::
stringify_cfunc
;
use
crate
::
stringify_cfunc
;
use
crate
::
sync
;
use
crate
::
sync
;
...
@@ -881,21 +881,8 @@ impl NodeImpl {
...
@@ -881,21 +881,8 @@ impl NodeImpl {
// Update pico metadata.
// Update pico metadata.
match
ddl
{
match
ddl
{
Ddl
::
CreateSpace
{
id
,
..
}
=>
{
Ddl
::
CreateSpace
{
id
,
..
}
=>
{
self
.storage
ddl_meta_space_update_operable
(
&
self
.storage
,
id
,
true
)
.spaces
.expect
(
"storage shouldn't fail"
);
.update_operable
(
id
,
true
)
.expect
(
"storage error"
);
self
.storage
.indexes
.update_operable
(
id
,
0
,
true
)
.expect
(
"storage error"
);
// For now we just assume that during space creation index with id 1
// exists if and only if it is a bucket_id index.
let
res
=
self
.storage.indexes
.update_operable
(
id
,
1
,
true
);
// TODO: maybe we should first check if this index
// exists or check the space definition if this should
// be done, but for now we just ignore the error "no such index"
let
_
=
res
;
}
}
Ddl
::
DropSpace
{
id
}
=>
{
Ddl
::
DropSpace
{
id
}
=>
{
...
@@ -962,21 +949,8 @@ impl NodeImpl {
...
@@ -962,21 +949,8 @@ impl NodeImpl {
}
}
Ddl
::
DropSpace
{
id
}
=>
{
Ddl
::
DropSpace
{
id
}
=>
{
self
.storage
ddl_meta_space_update_operable
(
&
self
.storage
,
id
,
true
)
.spaces
.expect
(
"storage shouldn't fail"
);
.update_operable
(
id
,
true
)
.expect
(
"storage should never fail"
);
let
iter
=
self
.storage
.indexes
.by_space_id
(
id
)
.expect
(
"storage should never fail"
);
for
index
in
iter
{
self
.storage
.indexes
.update_operable
(
index
.space_id
,
index
.id
,
true
)
.expect
(
"storage should never fail"
);
}
}
}
_
=>
{
_
=>
{
...
@@ -1159,21 +1133,8 @@ impl NodeImpl {
...
@@ -1159,21 +1133,8 @@ impl NodeImpl {
}
}
Ddl
::
DropSpace
{
id
}
=>
{
Ddl
::
DropSpace
{
id
}
=>
{
self
.storage
ddl_meta_space_update_operable
(
&
self
.storage
,
id
,
false
)
.spaces
.expect
(
"storage shouldn't fail"
);
.update_operable
(
id
,
false
)
.expect
(
"storage should never fail"
);
let
iter
=
self
.storage
.indexes
.by_space_id
(
id
)
.expect
(
"storage should never fail"
);
for
index
in
iter
{
self
.storage
.indexes
.update_operable
(
index
.space_id
,
index
.id
,
false
)
.expect
(
"storage should never fail"
);
}
}
}
Ddl
::
DropIndex
{
index_id
,
space_id
}
=>
{
Ddl
::
DropIndex
{
index_id
,
space_id
}
=>
{
...
...
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