Accessing Neo4J from C++

3,539 views
Skip to first unread message

Andreas H.

unread,
Sep 14, 2011, 2:50:04 PM9/14/11
to gremli...@googlegroups.com
Hi Neo4j-Users,

I have been googeling for this quite some time, but either I did not come up with the right search-terms or no one shares my problem:

What performant way would you recommand to interact with Neo4j from a C++ program (inserting and updating lots of nodes, but also doing complex queries).

The only way I found was the HTTP REST interface, which leads to the next question: Any tools you recommand? I don't like the idea to start with CURL and implement all the parsing I would need.

Sorry, if the answer to my questions is obvious... Please point me into the right direction.

Thanks,
Andreas

Saikat Kanjilal

unread,
Sep 14, 2011, 2:53:49 PM9/14/11
to gremli...@googlegroups.com
There is a C++ curl library called libcurl that you can use so you wouldnt really be starting with CURL but would be calling the CURL APIs with this library.  See the following link:  



Hope this helps, the other option is more complicated and would involve writing JNI wrappers 

Peter Neubauer

unread,
Sep 14, 2011, 3:04:58 PM9/14/11
to gremli...@googlegroups.com
Also,
there are embedded - Python drivers just coming out that use jpype. I
am no expert but that might be a way?

http://docs.neo4j.org/chunked/snapshot/python-embedded-installation.html

Cheers,

/peter neubauer

GTalk:      neubauer.peter
Skype       peter.neubauer
Phone       +46 704 106975
LinkedIn   http://www.linkedin.com/in/neubauer
Twitter      http://twitter.com/peterneubauer

http://www.neo4j.org               - Your high performance graph database.
http://startupbootcamp.org/    - Öresund - Innovation happens HERE.
http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.

James Thornton

unread,
Sep 14, 2011, 5:25:03 PM9/14/11
to gremli...@googlegroups.com
What performant way would you recommand to interact with Neo4j from a C++ 
> program (inserting and updating lots of nodes, but also doing complex queries).

Hi Andreas -

The standard way is to use the REST interface, but it's fairly straight forward to set up a ZeroMQ channel between Neo4j/JVM code and code in another programming language.

Here are the C++ and Java bindings:


I am doing this for Python/Java to create a fast connection between a Python program and the new Neo4jBatchGraph library (see https://groups.google.com/d/msg/gremlin-users/1wITOCYBtL0/nlz52WOpjY8J)-- I'll post an example soon. 

- James
 

Andreas H.

unread,
Sep 14, 2011, 5:37:16 PM9/14/11
to gremli...@googlegroups.com
Hi!

Thanks for these quick answers, but thats not really what I was hoping for ):

@Saikat: I already know libcurl, but I thought, there already exists some kind of graph-database specific abstraction layer for it...

@Peter: Do you think about SWIG oder boost.python? As it is easier to integrate Python in C++ as it would be to wrap Java-Classes? Or do you suggest to use something like jpype but for C++ instead of Python?

Blue skies,
Andreas

Andreas H.

unread,
Sep 14, 2011, 5:45:48 PM9/14/11
to gremli...@googlegroups.com
Hi James -

Your answer came in while writing my last post. Seems I was too cutty (:
That ZeroMQ looks pretty interesting. I will have a closer look at it tomorrow.

Thanks!

James Thornton

unread,
Sep 14, 2011, 5:46:01 PM9/14/11
to gremli...@googlegroups.com
Do you think about SWIG oder boost.python? As it is easier to integrate 
> Python in C++ as it would be to wrap Java-Classes?

If you go the Python route, Bulbs is a Python library for Rexster (http://bulbflow.com).

- James

Andreas H.

unread,
Oct 6, 2011, 9:26:17 AM10/6/11
to gremli...@googlegroups.com
Hi!

As mentioned in another thread ( https://groups.google.com/forum/#!topic/gremlin-users/C1OlTG9xCpo ) a C++ interaction is now possible by using James' ZeroMQ binding.
Code is available here: https://github.com/Squelsh/lightsocket/tree/squelsh

- Andy

Peter Neubauer

unread,
Oct 6, 2011, 9:30:27 AM10/6/11
to gremli...@googlegroups.com
Nice,
great to see some examples of this, certainly a very interesting binding!

Cheers,

/peter neubauer

GTalk:      neubauer.peter
Skype       peter.neubauer
Phone       +46 704 106975
LinkedIn   http://www.linkedin.com/in/neubauer
Twitter      http://twitter.com/peterneubauer

http://www.neo4j.org               - Your high performance graph database.
http://startupbootcamp.org/    - Öresund - Innovation happens HERE.
http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.

Arun Koshy

unread,
Oct 6, 2011, 9:43:59 AM10/6/11
to gremli...@googlegroups.com
Now this is starting to get real ;-)

James Thornton

unread,
Oct 6, 2011, 1:08:23 PM10/6/11
to gremli...@googlegroups.com
This is cool Andreas!

Andreas H.

unread,
Apr 16, 2013, 9:35:11 AM4/16/13
to gremli...@googlegroups.com
Hi Alireza,

the code is still there, just the access scheme on GitHub seems to be chagend :
https://github.com/Squelsh/lightsocket

Cheers,
Andy

Am Montag, 15. April 2013 13:59:27 UTC+2 schrieb Alireza Rezaei Mahdiraji:

Hi Andy,
The code link is not working anymore. Is the code available in some other address?
Best,
Alireza

James Thornton

unread,
Apr 16, 2013, 10:15:36 AM4/16/13
to gremli...@googlegroups.com
Hi Alireza -

Andy's C++ code has also been merged into the main Lightsocket repo (https://github.com/Squelsh/lightsocket); however, Lightsocket is several years old, and Blueprints has changed a lot during that time.

If I were writing a C++ binding today, I would write it for RexPro (https://github.com/tinkerpop/rexster/wiki/RexPro). 

RexPro is a binary protocol for connecting to Rexster's new Grizzly NIO TCP sockets. Here's an overview of the some high-level concepts to think about when writing a RexPro driver (https://groups.google.com/d/msg/gremlin-users/QY_kf6D4k4s/DN1iWqDfJ7wJ). 

As Stephen has said, the RexPro protocol is still in flux, but it's the future and much more current than Lightsocket. I might revive Lightsocket again someday as a ZeroMQ routing library, but RexPro is what you should build clients on today.

RexPro makes it easy to plug in different serializers and protocols, one of the things we want to do is make it easy to write RexPro clients in any language.

The last few days I've been looking into different protocol options and the tradeoffs of each, e.g. Avro, Thrift, websockets, SPDY, etc.

SPDY (http://www.chromium.org/spdy) is the foundation of HTTP 2.0, and it looks like it might replacement backend protocols as well. 

SPDY will work for public facing sites and it has nice properties to make it ideal for the backend as well -- you can enable TLS or disable TLS on the backend if you want, and it uses binary framed messages so the the message doesn't have to be reparsed at each stage (http://www.igvita.com/2012/01/18/building-a-modern-web-stack-for-the-realtime-web/). 

Plus, HAProxy now supports SPDY so it could be used with load-balance servers without having to build load-balancing logic into the client.

Rexter uses Grizzly as its NIO server, and Grizzly 2.3 supports SPDY so it will be easy to add to Rexster: 
Ilya Grigorik of Google gave an AirBnB TechTalk on SPDY, and at the end he makes the case for using it for modern backend RPC instead of stuff like Thrift, etc.

"Building a Modern Web Stack"
SPDY clients exists in several languages, and the list is growing. SPDY handles connection management,m and you don't need to worry about connection pools since it's multiplexed so this would significantly simplify RexPro client development.

Thoughts? 

- James
Reply all
Reply to author
Forward
0 new messages