private void newDb( int denseNodeThreshold ) { db = new ImpermanentGraphDatabase( MapUtil.stringMap( "dbms.relationship_grouping_threshold", "" + denseNodeThreshold ) ); fs = db.getDependencyResolver().resolveDependency( FileSystemAbstraction.class ); }
@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 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(); }
@Before public void setup() throws Exception { db = new ImpermanentGraphDatabase(); db.cleanContent(true); }
@Override public GraphDatabaseFacade newGraphDatabase( Config config, GraphDatabaseFacadeFactory.Dependencies dependencies ) { File storeDir = config.get( GraphDatabaseSettings.database_path ); config.augment( stringMap( GraphDatabaseSettings.ephemeral.name(), "true", new BoltConnector( "bolt" ).listen_address.name(), "localhost:0" ) ); return new ImpermanentGraphDatabase( storeDir, config, GraphDatabaseDependencies.newDependencies( dependencies ) ); } }
@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()); }
private static Representation executeTestScript(final String script, Map params) throws BadInputException { Transaction tx = null; try { tx = neo4j.beginTx(); return plugin.executeScript( neo4j, script, params ); } finally { tx.success(); tx.finish(); } }
@BeforeClass public static void setup() throws IOException { graphdb = (ImpermanentGraphDatabase)new TestGraphDatabaseFactory().newImpermanentDatabase(); graphdb.cleanContent(); engine = new ExecutionEngine( graphdb ); }
@After public void after() throws IOException { if ( db != null ) { db.shutdown(); } fs.close(); }
/** * This is deprecated. Use {@link TestGraphDatabaseFactory} instead */ @Deprecated public ImpermanentGraphDatabase( File storeDir, Map<String, String> params, Iterable<KernelExtensionFactory<?>> kernelExtensions ) { this( storeDir, params, getDependencies( kernelExtensions ) ); }
@Before public void setup() throws IOException { graphdb = new ImpermanentGraphDatabase(); graphdb.cleanContent(true); engine = new ExecutionEngine( graphdb ); }
private void createInMemoryGraphDatabaseService() { this.graphDb = new ImpermanentGraphDatabase(configurationParameters); }
public void intro_examples() throws Exception try ( Transaction ignored = graphdb.beginTx() )
@AfterClass public static void shutdown() { try { if ( graphdb != null ) graphdb.shutdown(); } finally { graphdb = null; } }
/** * This is deprecated. Use {@link TestGraphDatabaseFactory} instead */ @Deprecated public ImpermanentGraphDatabase( File storeDir, Map<String, String> params, Iterable<KernelExtensionFactory<?>> kernelExtensions ) { this( storeDir, params, getDependencies( kernelExtensions ) ); }
@Before public void setup() throws IOException { graphdb = new ImpermanentGraphDatabase(); graphdb.cleanContent( false ); engine = new ExecutionEngine( graphdb ); }
private void createInMemoryGraphDatabaseService() { this.graphDb = new ImpermanentGraphDatabase(configurationParameters); }
Relationship rel5; Relationship rel6; 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(); NeoStores neoStores = db.getDependencyResolver().resolveDependency( RecordStorageEngine.class ).testAccessNeoStores(); NodeStore nodeStore = neoStores.getNodeStore(); NodeRecord nodeRecord = getRecord( nodeStore, node.getId() );
@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(); }
@BeforeClass public static void setUp() throws Exception { database = new WrappingDatabase( new ImpermanentGraphDatabase() ); session = new GremlinSession( database ); }