Created
December 5, 2015 17:22
-
-
Save ikwattro/187c07d077f411079bda to your computer and use it in GitHub Desktop.
test
This file contains hidden or 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
package com.graphaware.test; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.neo4j.graphdb.*; | |
import org.neo4j.test.TestGraphDatabaseFactory; | |
import static org.junit.Assert.assertEquals; | |
public class LabelsBatchTest { | |
protected GraphDatabaseService db; | |
@Before | |
public void prepareDatabase() { | |
db = new TestGraphDatabaseFactory().newImpermanentDatabase(); | |
} | |
@After | |
public void destroyDb() { | |
db.shutdown(); | |
} | |
@Test | |
public void addLabelsInBatch() throws InterruptedException { | |
for (int i = 0; i < 1000; ++i) { | |
try (Transaction tx = db.beginTx()) { | |
//System.out.println(i); | |
db.execute("FOREACH (x in range(1, 1000) | CREATE (:Node {value:x}))"); | |
tx.success(); | |
} | |
} | |
int c = 0; | |
try (Transaction tx = db.beginTx()) { | |
ResourceIterator<Node> it = db.findNodes(DynamicLabel.label("Node")); | |
while (it.hasNext()) { | |
it.next(); | |
++c; | |
} | |
tx.success(); | |
} | |
assertEquals(1000000, c); | |
for (int i = 0; i < 1000; ++i) { | |
try (Transaction tx = db.beginTx()) { | |
db.execute("MATCH (n:Node) WITH n LIMIT 1000 SET n:SecondLabel"); | |
tx.success(); | |
} | |
} | |
int c2 = 0; | |
try (Transaction tx = db.beginTx()) { | |
ResourceIterator<Node> it = db.findNodes(DynamicLabel.label("SecondLabel")); | |
while (it.hasNext()) { | |
it.next(); | |
++c2; | |
} | |
tx.success(); | |
} | |
assertEquals(1000000, c2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment