@Test public void makeSureRelationshipGroupsNextAndPrevGetsAssignedCorrectly() { newDb( 1 ); try ( Transaction tx = db.beginTx() ) { Node node = db.createNode(); Node node0 = db.createNode(); Node node2 = db.createNode(); node0.createRelationshipTo( node, MyRelTypes.TEST ); node.createRelationshipTo( node2, MyRelTypes.TEST2 ); for ( Relationship rel : node.getRelationships() ) { rel.delete(); } node.delete(); tx.success(); } db.shutdown(); }
@Test public void verifyGroupIsDeletedWhenNeeded() { // TODO test on a lower level instead newDb( 2 ); Transaction tx = db.beginTx(); Node node = db.createNode(); Relationship rel1 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); Relationship rel2 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); Relationship rel3 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); Relationship rel4 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); Relationship rel5 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); Relationship rel6 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); tx.success(); tx.close(); NeoStores neoStores = db.getDependencyResolver().resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); NodeStore nodeStore = neoStores.getNodeStore(); NodeRecord nodeRecord = getRecord( nodeStore, node.getId() ); long group = nodeRecord.getNextRel(); RecordStore<RelationshipGroupRecord> groupStore = neoStores.getRelationshipGroupStore(); RelationshipGroupRecord groupRecord = getRecord( groupStore, group ); assertNotEquals( groupRecord.getNext(), -1 ); RelationshipGroupRecord otherGroupRecord = groupStore.getRecord( groupRecord.getNext(), groupStore.newRecord(), NORMAL ); assertEquals( -1, otherGroupRecord.getNext() ); // TODO Delete all relationships of one type and see to that the correct group is deleted. }
@Test public void createDenseNodeWithLowThreshold() { newDb( 2 ); // Create node with two relationships Node node; try ( Transaction tx = db.beginTx() ) { node = db.createNode(); node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); assertEquals( 2, node.getDegree() ); assertEquals( 1, node.getDegree( MyRelTypes.TEST ) ); assertEquals( 1, node.getDegree( MyRelTypes.TEST2 ) ); tx.success(); } try ( Transaction tx = db.beginTx() ) { node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); tx.success(); } db.shutdown(); }
try ( Transaction tx = db.beginTx() ) node = db.createNode(); rel1 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); rel2 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); rel3 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); rel4 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); rel5 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); rel6 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST2 ); tx.success();
try ( Transaction tx = db.beginTx() ) node = db.createNode(); rel1 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); rel2 = db.createNode().createRelationshipTo( node, MyRelTypes.TEST ); rel3 = node.createRelationshipTo( node, MyRelTypes.TEST ); rel4 = node.createRelationshipTo( db.createNode(), MyRelTypes.TEST ); rel5 = db.createNode().createRelationshipTo( node, MyRelTypes.TEST ); rel6 = node.createRelationshipTo( node, MyRelTypes.TEST ); tx.success();
@Test public void testAddToIndex() throws Exception { Map<String, String> config = TimelineIndexProvider.CONFIG; IndexManager indexMan = db.index(); Index<Node> index = indexMan.forNodes("timeline1", config); assertNotNull(index); Transaction tx = db.beginTx(); Node n1 = db.createNode(); n1.setProperty("time", 123); index.add(n1, "timestamp", 123L); Node n2 = db.createNode(); n2.setProperty("time", 123); index.add(n2, "timestamp", 123L); Node n3 = db.createNode(); n3.setProperty("time", 124); index.add(n3, "timestamp", 124L); tx.success(); tx.finish(); GraphvizWriter writer = new GraphvizWriter(); writer.emit(System.out, Walker.fullGraph(db)); IndexHits<Node> hits = index.get("timestamp", 123L); assertEquals(2, hits.size()); hits = index.query("[122 TO 125]"); assertEquals(3, hits.size()); ExecutionEngine engine = new ExecutionEngine(db); ExecutionResult result = engine.execute("start n=node:timeline1('[100 TO 200]') return n"); System.out.println(result.toString()); }