From d0179563c8658aa13c063e0e162a46423ede5ba7 Mon Sep 17 00:00:00 2001 From: cwy-p8d-u1 <sven-ove.haensel@stud.hs-hannover.de> Date: Sun, 11 Feb 2024 12:40:32 +0100 Subject: [PATCH] update gitignore --- .gitignore | 6 +- .../eval/query/memgraph/queries/queries.txt | 4 + .../eval/query/neo4j/queries/queries.txt | 4 + .../eval/query/ongdb/queries/queries.txt | 4 + .../eval/query/pg/queries/queries.txt | 74 +++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 code/infrastructure/eval/query/memgraph/queries/queries.txt create mode 100644 code/infrastructure/eval/query/neo4j/queries/queries.txt create mode 100644 code/infrastructure/eval/query/ongdb/queries/queries.txt create mode 100644 code/infrastructure/eval/query/pg/queries/queries.txt diff --git a/.gitignore b/.gitignore index 927f3c2..aeacb50 100755 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,12 @@ code/infrastructure/sql/* code/infrastructure/neo4j/* code/infrastructure/ongdb/* code/infrastructure/memgraph/* +code/infrastructure/eval/query/memgraph/log +code/infrastructure/eval/query/neo4j/log +code/infrastructure/eval/query/ongdb/log +code/infrastructure/eval/query/pg/log code/eval/spielwiese -code/infrastructure/eval/* + code/tests/bulk spielwiese code/infrastructure/monitoring/dashboards diff --git a/code/infrastructure/eval/query/memgraph/queries/queries.txt b/code/infrastructure/eval/query/memgraph/queries/queries.txt new file mode 100644 index 0000000..4085f55 --- /dev/null +++ b/code/infrastructure/eval/query/memgraph/queries/queries.txt @@ -0,0 +1,4 @@ +anc|MATCH path=(node:Host)-[*]->(ancestor) RETURN ancestor, size(path) AS distance_upstream ORDER BY distance_upstream; +desc|MATCH path=(node:Host)<-[*]-(descendant) RETURN descendant, size(path) AS distance_downstream ORDER BY distance_downstream; +path|MATCH path = (a:Subject {_uuid:'0CF2BB3E-36B8-11E8-BF66-D9AA8AFF4A69'})-[ *bfs]-(b:Event) RETURN path; +2-hop|MATCH (a:Subject) where a._uuid='0CF2BB3E-36B8-11E8-BF66-D9AA8AFF4A69' CALL neighbors.by_hop(a, [""], 2) YIELD nodes RETURN nodes; \ No newline at end of file diff --git a/code/infrastructure/eval/query/neo4j/queries/queries.txt b/code/infrastructure/eval/query/neo4j/queries/queries.txt new file mode 100644 index 0000000..7e11dfa --- /dev/null +++ b/code/infrastructure/eval/query/neo4j/queries/queries.txt @@ -0,0 +1,4 @@ +anc|MATCH path=(node:Host)-[*]->(ancestor) RETURN ancestor, length(path) AS distance_upstream ORDER BY distance_upstream; +desc|MATCH path=(node:Host)<-[*]-(descendant) RETURN descendant, length(path) AS distance_downstream ORDER BY distance_downstream; +path|MATCH path = shortestPath((a:Subject where a._uuid='0CF2BB3E-36B8-11E8-BF66-D9AA8AFF4A69')-[*]-(b:Event)) RETURN path; +2-hop|MATCH (startNode: Host)-[*1..2]-(neighborhood) RETURN neighborhood; \ No newline at end of file diff --git a/code/infrastructure/eval/query/ongdb/queries/queries.txt b/code/infrastructure/eval/query/ongdb/queries/queries.txt new file mode 100644 index 0000000..7c6a16f --- /dev/null +++ b/code/infrastructure/eval/query/ongdb/queries/queries.txt @@ -0,0 +1,4 @@ +anc|MATCH path=(node:Host)-[*]->(ancestor) RETURN ancestor, length(path) AS distance_upstream ORDER BY distance_upstream; +desc|MATCH path=(node:Host)<-[*]-(descendant) RETURN descendant, length(path) AS distance_downstream ORDER BY distance_downstream; +path|MATCH (a:Subject)-[*]-(b:Event) WHERE a._uuid = '0CF2BB3E-36B8-11E8-BF66-D9AA8AFF4A69' WITH a, b MATCH path = shortestPath((a)-[*]-(b)) RETURN path +2-hop|MATCH (startNode: Host)-[*1..2]-(neighborhood) RETURN neighborhood; \ No newline at end of file diff --git a/code/infrastructure/eval/query/pg/queries/queries.txt b/code/infrastructure/eval/query/pg/queries/queries.txt new file mode 100644 index 0000000..2664426 --- /dev/null +++ b/code/infrastructure/eval/query/pg/queries/queries.txt @@ -0,0 +1,74 @@ +ancestors|WITH RECURSIVE AncestorCTE AS ( + SELECT n.node_no, e.dest, n.type, 1 AS Level + FROM node_list n + JOIN edge_list e ON n.uuid = e.source + WHERE n.node_no = 30 -- Replace with the desired starting node_no + + UNION ALL + + SELECT n.node_no, e.dest, n.type, d.Level + 1 + FROM node_list n + JOIN edge_list e ON n.uuid = e.source + JOIN AncestorCTE d ON e.dest = n.uuid + WHERE d.Level <5 -- Replace with the desired level +) +SELECT DISTINCT node_no, dest, type, Level FROM AncestorCTE; +--- +descendant|WITH RECURSIVE DescendantCTE AS ( + SELECT n.node_no, e.source, 1 AS Level + FROM node_list n + JOIN edge_list e ON n.uuid = e.dest + WHERE n.node_no = 1 -- Replace with the desired starting node_no + + UNION ALL + + SELECT n.node_no, e.source, a.Level + 1 + FROM node_list n + JOIN edge_list e ON n.uuid = e.dest + JOIN DescendantCTE a ON e.source = n.uuid + WHERE a.Level < 3 -- Replace with the desired level +) +SELECT DISTINCT node_no, source, Level FROM DescendantCTE; +--- +path|WITH RECURSIVE path_cte AS ( + -- Anchor member initialization + SELECT + el.source AS start_node, + el.dest AS end_node, + ARRAY[el.source::varchar] AS path, -- Cast to varchar to ensure type consistency + 1 AS depth -- Keep track of the depth to prevent infinite loops + FROM + edge_list el + WHERE + el.source = '5CC868CD-FF30-5E2B-BB74-6C5B474A62B2' -- Replace with the UUID of the starting node + + UNION ALL + + -- Recursive member definition + SELECT + p.start_node, + el.dest, + p.path || el.dest::varchar, -- Ensure el.dest is cast to varchar + p.depth + 1 + FROM + edge_list el + JOIN + path_cte p ON el.source = p.end_node + WHERE + NOT (el.dest = ANY(p.path)) -- Prevent cycles by ensuring we don't revisit nodes + AND p.depth < 100 -- Example limit to prevent infinite recursion +) + +-- Final query to select the path +SELECT distinct + start_node, end_node, path, depth +FROM + path_cte +WHERE + end_node = '83C8ED1F-5045-DBCD-B39F-918F0DF4F851' -- Replace with the UUID of the ending node +ORDER BY + depth ASC -- Optional: orders by the shortest path +--LIMIT 1 -- Optionally limit to one path if multiple paths exist +; +--- +k-hop|Select 1; -- GitLab