From: Roel Janssen <roel@gnu.org>
To: 26807@debbugs.gnu.org
Subject: bug#26807: [PATCH] graph: Add Cypher backend.
Date: Sat, 06 May 2017 23:21:32 +0200 [thread overview]
Message-ID: <87fughk7fn.fsf@gnu.org> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-graph-Add-Cypher-backend.patch --]
[-- Type: text/x-patch, Size: 1702 bytes --]
From 0e9c95ef3473fa7066ccd5991b1c14400aaa7076 Mon Sep 17 00:00:00 2001
From: Roel Janssen <roel@gnu.org>
Date: Sat, 6 May 2017 23:15:03 +0200
Subject: [PATCH] graph: Add Cypher backend.
* guix/graph.scm (%cypher-backend): New variable.
---
guix/graph.scm | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/guix/graph.scm b/guix/graph.scm
index 7af2cd3b8..d7fd5f3e4 100644
--- a/guix/graph.scm
+++ b/guix/graph.scm
@@ -229,6 +229,35 @@ nodeArray.push(nodes[\"~a\"]);~%"
emit-d3js-prologue emit-d3js-epilogue
emit-d3js-node emit-d3js-edge))
+
+\f
+;;;
+;;; Cypher export.
+;;;
+
+(define (emit-cypher-prologue name port)
+ (format port ""))
+
+(define (emit-cypher-epilogue port)
+ (format port ""))
+
+(define (emit-cypher-node id label port)
+ (format port "MERGE (p:Package { id: ~s }) SET p.name = ~s;~%"
+ id label ))
+
+(define (emit-cypher-edge id1 id2 port)
+ (format port "MERGE (a:Package { id: ~s });~%" id1)
+ (format port "MERGE (b:Package { id: ~s });~%" id2)
+ (format port "MATCH (a:Package { id: ~s }), (b:Package { id: ~s }) CREATE UNIQUE (a)-[:NEEDS]->(b);~%"
+ id1 id2))
+
+(define %cypher-backend
+ (graph-backend "cypher"
+ "Generate Cypher queries."
+ emit-cypher-prologue emit-cypher-epilogue
+ emit-cypher-node emit-cypher-edge))
+
+
\f
;;;
;;; Shared.
@@ -236,7 +265,8 @@ nodeArray.push(nodes[\"~a\"]);~%"
(define %graph-backends
(list %graphviz-backend
- %d3js-backend))
+ %d3js-backend
+ %cypher-backend))
(define* (export-graph sinks port
#:key
--
2.12.2
[-- Attachment #2: Type: text/plain, Size: 500 bytes --]
Dear Guix,
I would like to add another backend to the 'guix graph' command. This
backend will return a bunch of queries that can be used to create a
graph database for any database engine that uses openCypher (although I
only know one engine and it's called neo4j, which should be GPLv3 code).
If there was a way to ensure node definitions are written to the output
before the edges, I could simplify the queries a bit. But I believe it
is quite fast anyway.
Thanks!
Kind regards,
Roel Janssen
next reply other threads:[~2017-05-06 21:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-06 21:21 Roel Janssen [this message]
2017-05-10 20:59 ` bug#26807: [PATCH] graph: Add Cypher backend Ludovic Courtès
2017-05-11 12:57 ` Roel Janssen
2017-05-11 14:03 ` Ludovic Courtès
2017-05-11 14:15 ` Roel Janssen
2017-05-11 14:29 ` Roel Janssen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fughk7fn.fsf@gnu.org \
--to=roel@gnu.org \
--cc=26807@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.