Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flame-clmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
flame
flame-clmc
Commits
b42bc7bf
Commit
b42bc7bf
authored
6 years ago
by
Nikolay Stanchev
Browse files
Options
Downloads
Patches
Plain Diff
Updates the utility functions used to delete a subgraph
parent
7064db83
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/service/clmcservice/graphapi/utilities.py
+12
-11
12 additions, 11 deletions
src/service/clmcservice/graphapi/utilities.py
with
12 additions
and
11 deletions
src/service/clmcservice/graphapi/utilities.py
+
12
−
11
View file @
b42bc7bf
...
...
@@ -223,14 +223,15 @@ def delete_nodes_with_type(graph, node_type):
log
.
info
(
"
Deleting {0} nodes.
"
.
format
(
node_type
))
subgraph
=
graph
.
nodes
.
match
(
node_type
)
deleted_nodes
=
len
(
subgraph
)
for
node
in
subgraph
:
graph
.
delete
(
node
)
# this is the recommended way to delete a number of nodes, rather than deleting them one by one
query
=
"
MATCH (node:{0}) DETACH DELETE node RETURN count(node) as count;
"
.
format
(
node_type
)
log
.
info
(
"
Executing query {0}
"
.
format
(
query
))
result
=
graph
.
run
(
query
)
nodes_matched
=
result
.
data
()[
0
][
"
count
"
]
# we expect exactly one result, which is a dictionary with key 'count'
log
.
info
(
"
Deleted {0} {1} nodes.
"
.
format
(
deleted_nodes
,
node_type
))
log
.
info
(
"
Deleted {0} {1} nodes.
"
.
format
(
nodes_matched
,
node_type
))
return
deleted_nodes
return
nodes_matched
def
build_temporal_subgraph
(
request_id
,
from_timestamp
,
to_timestamp
,
json_queries
,
graph
,
influx_client
):
...
...
@@ -338,11 +339,11 @@ def delete_temporal_subgraph(graph, subgraph_id):
log
.
info
(
"
Deleting subgraph associated with ID {0}
"
.
format
(
subgraph_id
))
subgraph
=
graph
.
nodes
.
match
(
uuid
=
subgraph_id
)
nodes_matched
=
0
for
node
in
subgraph
:
graph
.
delete
(
node
)
nodes_matched
+
=
1
# this is the recommended way to delete a number of nodes, rather than deleting them one by one
query
=
"
MATCH (node {{uuid:
'
{0}
'
}}) DETACH DELETE node RETURN count(node) as count;
"
.
format
(
subgraph_id
)
log
.
info
(
"
Executing query {0}
"
.
format
(
query
))
result
=
graph
.
run
(
query
)
nodes_matched
=
result
.
data
()[
0
][
"
count
"
]
# we expect exactly one result, which is a dictionary with key 'count'
log
.
info
(
"
Deleted {0} nodes associated with ID {1}
"
.
format
(
nodes_matched
,
subgraph_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