Neo4j bolt driver for Pharo Smalltalk, based on Seabolt.
client := SbClient new.
client settings password: 'neoneo'.
client connect.
cypher := 'UNWIND range(1, 10) AS n RETURN n'.
result := client transactCypher: cypher.
client release.
result inspect.
sessionManager := SbClientSessionManager default.
sessionManager standBy: 3 setting: [:settings | settings password: 'neoneo'].
cypher := 'MATCH p = (n:Movie)<-[r]-(m) RETURN p LIMIT 10'.
sessionManager clientDo: [ :cli |
result := cli runCypher: cypher.
Transcript cr; show: result fieldValues.
].
sessionManager := SbClientSessionManager default.
sessionManager standBy: 3 setting: [:settings | settings password: 'neoneo'].
cypher := 'MATCH (n:Movie) WHERE n.title = $name RETURN n'.
args := {'name'->'The Matrix'} asDictionary.
sessionManager clientDo: [ :cli |
result := cli runCypher: cypher arguments: args.
Transcript cr; show: result firstFieldValues first properties.
].
Execute cypher generated by SCypher
node := 'n' asCypherIdentifier.
nameParam := 'name' asCypherParameter.
cypher := (CyQuery statements: {
CyMatch of: (CyNode name: node label: 'Movie').
CyWhere of: (CyExpression eq: (node prop: 'title') with: nameParam).
CyReturn of: node.
}) cypherString.
args := {nameParam identifier -> 'The Matrix'} asDictionary.
sessionManager clientDo: [ :cli |
result := cli runCypher: cypher arguments: args.
Transcript cr; show: result firstFieldValues first properties.
].
Metacello new
baseline: 'SmallBolt';
repository: 'github://mumez/SmallBolt/src';
load.
You also need to put a Seabolt shared library (libseabolt). The latest pre-built libraries are in shared-libraries directory. The libraries tagged with #stable are located at stable release. BaselineOfSmallBolt will automatically download the appropriate library from the release according to the current platform.
SmallBolt communicates with Neo4j via efficient Bolt protocol using FFI. Generally, it is about 3 times faster than Neo4reSt REST client.
Neo4reSt REST client:
graphDb := N4GraphDb new.
graphDb settings password: 'neoneo'.
[1000 timesRepeat: [
cypher := 'MATCH (m:Movie)<-[r]-(n) RETURN m,r,n LIMIT 10'.
resp := graphDb restClient queryByCypher: cypher.
resp result data
]] timeToRun. "=>0:00:00:04.854"
SmallBolt:
client := SbClient new.
client settings password: 'neoneo'.
client connect.
[1000 timesRepeat: [
cypher := 'MATCH (m:Movie)<-[r]-(n) RETURN m,r,n LIMIT 10'.
result := client runCypher: cypher.
result fieldValues
]] timeToRun. "=>0:00:00:01.499"