use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestNeo4jCacheAndPersistence method testSameTxWithArray.
@Test
public void testSameTxWithArray() {
getTransaction().success();
getTransaction().finish();
newTransaction();
Node nodeA = getGraphDb().createNode();
Node nodeB = getGraphDb().createNode();
Relationship relA = nodeA.createRelationshipTo(nodeB, MyRelTypes.TEST);
nodeA.setProperty(arrayKey, array);
relA.setProperty(arrayKey, array);
NodeManager nodeManager = ((EmbeddedGraphDatabase) getGraphDb()).getConfig().getGraphDbModule().getNodeManager();
nodeManager.clearCache();
assertTrue(nodeA.getProperty(arrayKey) != null);
assertTrue(relA.getProperty(arrayKey) != null);
relA.delete();
nodeA.delete();
nodeB.delete();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestNeo4jCacheAndPersistence method testAddCacheCleared.
@Test
public void testAddCacheCleared() {
Node nodeA = getGraphDb().createNode();
nodeA.setProperty("1", 1);
Node nodeB = getGraphDb().createNode();
Relationship rel = nodeA.createRelationshipTo(nodeB, MyRelTypes.TEST);
rel.setProperty("1", 1);
getTransaction().success();
getTransaction().finish();
newTransaction();
NodeManager nodeManager = ((EmbeddedGraphDatabase) getGraphDb()).getConfig().getGraphDbModule().getNodeManager();
nodeManager.clearCache();
nodeA.createRelationshipTo(nodeB, MyRelTypes.TEST);
int count = 0;
for (Relationship relToB : nodeA.getRelationships(MyRelTypes.TEST)) {
count++;
}
assertEquals(2, count);
nodeA.setProperty("2", 2);
assertEquals(1, nodeA.getProperty("1"));
rel.setProperty("2", 2);
assertEquals(1, rel.getProperty("1"));
nodeManager.clearCache();
// trigger empty load
getGraphDb().getNodeById(nodeA.getId());
getGraphDb().getRelationshipById(rel.getId());
// apply COW maps
getTransaction().success();
getTransaction().finish();
newTransaction();
count = 0;
for (Relationship relToB : nodeA.getRelationships(MyRelTypes.TEST)) {
count++;
}
assertEquals(2, count);
assertEquals(1, nodeA.getProperty("1"));
assertEquals(1, rel.getProperty("1"));
assertEquals(2, nodeA.getProperty("2"));
assertEquals(2, rel.getProperty("2"));
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestNeo4jCacheAndPersistence method testLowGrabSize.
@Test
public void testLowGrabSize() {
Map<String, String> config = new HashMap<String, String>();
config.put("relationship_grab_size", "1");
String storePath = getStorePath("neo2");
deleteFileOrDirectory(storePath);
EmbeddedGraphDatabase graphDb = new EmbeddedGraphDatabase(storePath, config);
Transaction tx = graphDb.beginTx();
Node node1 = graphDb.createNode();
Node node2 = graphDb.createNode();
node1.createRelationshipTo(node2, MyRelTypes.TEST);
node2.createRelationshipTo(node1, MyRelTypes.TEST2);
node1.createRelationshipTo(node2, MyRelTypes.TEST_TRAVERSAL);
tx.success();
tx.finish();
tx = graphDb.beginTx();
Set<Relationship> rels = new HashSet<Relationship>();
RelationshipType[] types = new RelationshipType[] { MyRelTypes.TEST, MyRelTypes.TEST2, MyRelTypes.TEST_TRAVERSAL };
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node1.getRelationships(types)) {
assertTrue(rels.add(rel));
}
assertEquals(3, rels.size());
rels.clear();
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node1.getRelationships()) {
assertTrue(rels.add(rel));
}
assertEquals(3, rels.size());
rels.clear();
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node2.getRelationships(types)) {
assertTrue(rels.add(rel));
}
assertEquals(3, rels.size());
rels.clear();
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node2.getRelationships()) {
assertTrue(rels.add(rel));
}
assertEquals(3, rels.size());
rels.clear();
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node1.getRelationships(Direction.OUTGOING)) {
assertTrue(rels.add(rel));
}
assertEquals(2, rels.size());
rels.clear();
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node1.getRelationships(Direction.INCOMING)) {
assertTrue(rels.add(rel));
}
assertEquals(1, rels.size());
rels.clear();
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node2.getRelationships(Direction.OUTGOING)) {
assertTrue(rels.add(rel));
}
assertEquals(1, rels.size());
rels.clear();
graphDb.getConfig().getGraphDbModule().getNodeManager().clearCache();
for (Relationship rel : node2.getRelationships(Direction.INCOMING)) {
assertTrue(rels.add(rel));
}
assertEquals(2, rels.size());
tx.success();
tx.finish();
graphDb.shutdown();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestCacheTypes method testOldCache.
@Test
public void testOldCache() {
GraphDatabaseService db = newDb("old");
assertEquals(CacheType.old, ((EmbeddedGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().getCacheType());
db.shutdown();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestCacheTypes method testStrongCache.
@Test
public void testStrongCache() {
GraphDatabaseService db = newDb("strong");
assertEquals(CacheType.strong, ((EmbeddedGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().getCacheType());
db.shutdown();
}
Aggregations