Created
August 16, 2012 03:34
-
-
Save alebon/3366333 to your computer and use it in GitHub Desktop.
OrientDB Spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySpec extends Specification { | |
"OrientGraph Repository" should { | |
"create 15 relationships properly" in { | |
val db = OGraphDatabasePool.global() | |
.acquire("remote:127.0.0.1/db", "admin", "admin") | |
val clazz = db.getVertexType("TARGET_VERTEX") | |
if (clazz == null) { | |
db.createVertexType("TARGET_VERTEX") | |
} | |
val clazz2 = db.getVertexType("SOURCE_VERTEX") | |
if (clazz2 == null) { | |
db.createVertexType("SOURCE_VERTEX") | |
} | |
db.begin(TXTYPE.OPTIMISTIC) | |
var repoVertex: ODocument = null | |
try { | |
repoVertex = db.createVertex("TARGET_VERTEX") | |
repoVertex.field("name", "TestRepositoryFOREDGESTEST") | |
repoVertex.save | |
db.commit() | |
} catch { | |
case e:Exception => | |
println(e.getMessage) | |
} finally { | |
// Do nothing | |
} | |
for (i <- 1 to 15) { | |
db.begin(TXTYPE.OPTIMISTIC) | |
db.declareIntent(new OIntentMassiveInsert()) | |
var countSize = 0 | |
val maxItems = 1 | |
try { | |
for (i <- 1 to maxItems) { | |
val vertex = db.createVertex("SOURCE_VERTEX") | |
//vertex.setClassName("TestEntity") | |
vertex.field("entityCount", i) | |
vertex.field("name", "Lorem ipsum dolor" + i) | |
vertex.field("lastUpdate", new util.Date().toString) | |
vertex.save | |
val vertexEdge = db.createEdge(repoVertex, vertex) | |
vertexEdge.field("rel", "TEST_ENTITY") | |
vertexEdge.save | |
countSize += vertex.getSize | |
} | |
println("Overall size for " + maxItems + ": " + (countSize/1024) + " KByte") | |
println("DB Size: " + (db.getSize/1024) + " KByte") | |
} catch { | |
case e:Exception => | |
println(e.getMessage) | |
} finally { | |
// Do nothing | |
} | |
db.commit() | |
} | |
db.close() | |
true must_== true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment