-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
101 lines (66 loc) · 1.92 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
neo4j
=====
Neo4j manager that provides many storage commands
Usage
=====
neo <db-dir> <command>
Following commands are available
* touch : create an empty database
* example : create a sample database
* info : print node information
* load <tsv> : load graph data from tsv
* dump : dump graph data as tsv
* list : print list of node ids
* edges : print edge list
Requirement
===========
* Scala-2.8.0
Tested on following jars in neo4j-1.2.M02
* geronimo-jta_1.1_spec-1.1.1.jar
* neo4j-graph-algo-0.7-1.2.M02.jar
* neo4j-kernel-1.2-1.2.M02.jar
Setup
=====
1. compile
% sbt package
2. alias for convenient access to neo4j.ctl object
% alias neo="scala -cp 'lib/*:target/scala_2.8.0/*' sc.ala.neo4j.ctl"
StorageManaging
===============
create a sample database in "/tmp/neo1"
% neo /tmp/neo1 example
dump graph data as tsv written with triple (n1,edge,n2)
% neo /tmp/neo1 dump > data.tsv
% cat data.tsv
Java -null Scala
Ruby +robust Scala
load graph data from tsv written with triple (n1,edge,n2)
% neo /tmp/neo2 load data.tsv
here, both /tmp/neo1 and /tmp/neo2 contain same data
Coding
======
% sbt console
import sc.ala.neo4j.Neo
// create empty database
new Neo("/tmp/neo3") { touch }
// write new nodes and edges
new Neo("/tmp/neo3") { W{
N("Python") --> "Looks like" --> N("Ruby")
}}
// NOTE: here "W" is a writer transaction
// and "N" is an alias for findNodeOrCreateByName
// read node named "Ruby"
new Neo("/tmp/neo3") { R{
println("id: " + n("Ruby").getId)
}}
// => id: 2
// NOTE: here "R" is a reader transaction
// and "n" is an alias for findNodeByName
// "n" raise an error when the node is not found
new Neo("/tmp/neo3") { R{
n("XXX")
}}
// => sc.ala.neo4j.NodeNotFound: XXX
Author
======
maiha@wota.jp