diff --git a/.gitignore b/.gitignore index 927f3c2fc74a697b1f5ca4408eed3813a77df9e2..aeacb505551e26fb449c854a9fe82761d3e2850e 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 0000000000000000000000000000000000000000..4085f5559116282f23f5d312d09150eb1da83400 --- /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 0000000000000000000000000000000000000000..7e11dfafb20410313d1fbf3773c50d15fbe29201 --- /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 0000000000000000000000000000000000000000..7c6a16fe71a3ad6d8455d8b13bf5c6917f140a76 --- /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 0000000000000000000000000000000000000000..266442620a5b2bdbdfcf5a7eed0a352eaac430ff --- /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;