Skip to content

Commit 5e5c13e

Browse files
committed
Initial commit
0 parents  commit 5e5c13e

File tree

4 files changed

+188
-0
lines changed

4 files changed

+188
-0
lines changed

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
README
2+
======
3+
4+
This repository offers some simple project templates to get started with Graph databases. It will primarily focus on:
5+
6+
+ [Tinkerpop 3](http://www.tinkerpop.com)
7+
+ [Neo4J](http://neo4j.com)
8+
+ [OrientDB](http://www.orientechnologies.com/orientdb)
9+
10+
It you are going to use any information and/or artifacts of this repository, please be aware of the fact that
11+
12+
+ You need a current version of Java installed (Java 7 or better). I highly recommend using Java 8!
13+
+ You need a current version of Maven 3 installed
14+
15+
To test your Java version:
16+
17+
````bash
18+
$ java -version
19+
java version "1.8.0_25"
20+
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
21+
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
22+
````
23+
24+
To test your maven install (environment variable JAVA_HOME must be defined!):
25+
26+
````bash
27+
$ echo $JAVA_HOME
28+
/usr/lib/jvm/java-8-oracle
29+
30+
$ mvn --version
31+
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T15:51:42+02:00)
32+
Maven home: /usr/share/maven/apache-maven-3.2.2
33+
Java version: 1.8.0_25, vendor: Oracle Corporation
34+
Java home: /usr/lib/jvm/jdk1.8.0_25/jre
35+
Default locale: en_US, platform encoding: UTF-8
36+
OS name: "linux", version: "3.13.0-39-generic", arch: "amd64", family: "unix"
37+
````
38+
39+
or if your JAVA_HOME links to another Java version:
40+
41+
````bash
42+
export JAVA_HOME=/usr/lib/jvm/java-8-oracle && mvn --version
43+
````
44+

orientdb-embedded-graph/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
README
2+
======
3+
4+
This Maven project can be used to start developing an embedded OrientDB 2.x Graph database.
5+
6+
To build this project:
7+
8+
````bash
9+
cd orientdb-embedded-graph/
10+
$ mvn clean install
11+
[INFO] Scanning for projects...
12+
[INFO]
13+
[INFO] ------------------------------------------------------------------------
14+
[INFO] Building orientdb-embedded-graph 1.0.0-SNAPSHOT
15+
[INFO] ------------------------------------------------------------------------
16+
17+
...
18+
19+
[INFO] ------------------------------------------------------------------------
20+
[INFO] BUILD SUCCESS
21+
[INFO] ------------------------------------------------------------------------
22+
[INFO] Total time: 2.046 s
23+
[INFO] Finished at: 2014-11-13T13:53:51+01:00
24+
[INFO] Final Memory: 16M/205M
25+
[INFO] ------------------------------------------------------------------------
26+
````
27+
28+
Now you can you the example `Main` class
29+
30+
````bash
31+
$ export JAVA_HOME=/usr/lib/jvm/java-8-oracle && mvn exec:java -Dexec.mainClass=eu.infomas.research.orientdb.Main
32+
````
33+
34+
Both OrientDB and Maven report some warning, those warnings can be ignored.
35+
36+
Finally you can check the result, using the OrientDB console (should be installed separately)
37+
38+
````
39+
$ ./console.sh
40+
41+
OrientDB console v.2.0-M2 (build UNKNOWN@r; 2014-09-29 21:06:32+0000) www.orientechnologies.com
42+
Type 'help' to display all the commands supported.
43+
Installing extensions for GREMLIN language v.2.6.0
44+
45+
orientdb> connect plocal:/home/rmuller/orientdb/test admin admin
46+
47+
Connecting to database [plocal:/home/rmuller/orientdb/test] with user 'admin'...OK
48+
orientdb {db=test}> select from V
49+
50+
----+----+------+----+---------+-----------+--------+----+----------
51+
# |@RID|name |age |out_knows|out_created|in_knows|lang|in_created
52+
----+----+------+----+---------+-----------+--------+----+----------
53+
0 |#9:0|marko |29 |[size=2] |[size=1] |null |null|null
54+
1 |#9:1|vadas |27 |null |null |[size=1]|null|null
55+
2 |#9:2|lop |null|null |null |null |java|[size=3]
56+
3 |#9:3|josh |32 |null |[size=2] |[size=1]|null|null
57+
4 |#9:4|ripple|null|null |null |null |java|[size=1]
58+
5 |#9:5|peter |35 |null |[size=1] |null |null|null
59+
----+----+------+----+---------+-----------+--------+----+----------
60+
61+
6 item(s) found. Query executed in 0.005 sec(s).
62+
63+
````

orientdb-embedded-graph/pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>eu.infomas.research</groupId>
8+
<artifactId>orientdb-embedded-graph</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<maven.compiler.source>1.8</maven.compiler.source>
15+
<maven.compiler.target>1.8</maven.compiler.target>
16+
<orientdb.version>2.0-M2</orientdb.version>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>com.orientechnologies</groupId>
22+
<artifactId>orientdb-graphdb</artifactId>
23+
<version>${orientdb.version}</version>
24+
25+
</dependency>
26+
</dependencies>
27+
28+
<build>
29+
<plugins>
30+
31+
</plugins>
32+
</build>
33+
34+
</project>
35+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package eu.infomas.research.orientdb;
2+
3+
import com.tinkerpop.blueprints.Vertex;
4+
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
5+
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
6+
7+
/**
8+
* {@code Main}.
9+
*
10+
* @author <a href="mailto:[email protected]">Ronald K. Muller</a>
11+
*/
12+
public class Main {
13+
14+
private static final String DB_DIR = System.getProperty("user.home") + "/orientdb/test";
15+
16+
public static void main(String... args) {
17+
// start with a non existing database
18+
final OrientGraphFactory factory = new OrientGraphFactory(
19+
"plocal:" + DB_DIR, "admin", "admin");
20+
try {
21+
final OrientGraphNoTx g = factory.getNoTx();
22+
// database is now auto created
23+
24+
// example from Tinkerpop 3 ()
25+
// Changed to be compatible with current OrientDB implementation
26+
Vertex marko = g.addVertex(null, "name", "marko", "age", 29);
27+
Vertex vadas = g.addVertex(null, "name", "vadas", "age", 27);
28+
Vertex lop = g.addVertex(null, "name", "lop", "lang", "java");
29+
Vertex josh = g.addVertex(null, "name", "josh", "age", 32);
30+
Vertex ripple = g.addVertex(null, "name", "ripple", "lang", "java");
31+
Vertex peter = g.addVertex(null, "name", "peter", "age", 35);
32+
33+
marko.addEdge("knows", vadas).setProperty("weight", 0.5f);
34+
marko.addEdge("knows", josh).setProperty("weight", 1.0f);
35+
marko.addEdge("created", lop).setProperty("weight", 0.4f);
36+
josh.addEdge("created", ripple).setProperty("weight", 1.0f);
37+
josh.addEdge("created", lop).setProperty("weight", 0.4f);
38+
peter.addEdge("created", lop).setProperty("weight", 0.2f);
39+
} finally {
40+
// this also closes the OrientGraph instances created by the factory
41+
// Note that OrientGraphFactory does not implement Closeable
42+
factory.close();
43+
}
44+
}
45+
46+
}

0 commit comments

Comments
 (0)