public <T> T executeAndRollback( Function<? super GraphDatabaseService, T> function ) { return transaction( function, false ); }
public <T> T executeAndCommit( Function<? super GraphDatabaseService, T> function ) { return transaction( function, true ); }
public void executeAndCommit( Consumer<? super GraphDatabaseService> consumer ) { transaction( (Function<? super GraphDatabaseService,Void>) t -> { consumer.accept( t ); return null; }, true ); }
@Test public void multipleIteratorsNestedInterleavedExact() throws Exception { try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryExact( ktx ) ) { List<Long> actual1 = new ArrayList<>(); try ( NodeValueIndexCursor cursor2 = indexCoordinator.queryExact( ktx ) ) { List<Long> actual2 = new ArrayList<>(); // Interleave exhaustInterleaved( cursor1, actual1, cursor2, actual2 ); // then indexCoordinator.assertExactResult( actual1 ); indexCoordinator.assertExactResult( actual2 ); } } tx.success(); } }
@Test public void multipleIteratorsNestedInterleavedExists() throws Exception { try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryExists( ktx ) ) { List<Long> actual1 = new ArrayList<>(); try ( NodeValueIndexCursor cursor2 = indexCoordinator.queryExists( ktx ) ) { List<Long> actual2 = new ArrayList<>(); // Interleave exhaustInterleaved( cursor1, actual1, cursor2, actual2 ); // then indexCoordinator.assertExistsResult( actual1 ); indexCoordinator.assertExistsResult( actual2 ); } } tx.success(); } }
@Test public void multipleIteratorsNestedInterleavedRange() throws Exception { Assume.assumeTrue( indexCoordinator.supportRangeQuery() ); try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryRange( ktx ); NodeValueIndexCursor cursor2 = indexCoordinator.queryRange( ktx ) ) { List<Long> actual1 = new ArrayList<>(); List<Long> actual2 = new ArrayList<>(); // Interleave exhaustInterleaved( cursor1, actual1, cursor2, actual2 ); // then indexCoordinator.assertRangeResult( actual1 ); indexCoordinator.assertRangeResult( actual2 ); } tx.success(); } }
@Test public void multipleIteratorsNestedInnerNewExists() throws Exception { try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryExists( ktx ) ) { List<Long> actual1 = new ArrayList<>(); while ( cursor1.next() ) { actual1.add( cursor1.nodeReference() ); try ( NodeValueIndexCursor cursor2 = indexCoordinator.queryExists( ktx ) ) { List<Long> actual2 = asList( cursor2 ); indexCoordinator.assertExistsResult( actual2 ); } } // then indexCoordinator.assertExistsResult( actual1 ); } tx.success(); } }
@Test public void multipleIteratorsNestedInnerNewExact() throws Exception { try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryExact( ktx ) ) { List<Long> actual1 = new ArrayList<>(); while ( cursor1.next() ) { actual1.add( cursor1.nodeReference() ); try ( NodeValueIndexCursor cursor2 = indexCoordinator.queryExact( ktx ) ) { List<Long> actual2 = asList( cursor2 ); indexCoordinator.assertExactResult( actual2 ); } } // then indexCoordinator.assertExactResult( actual1 ); } tx.success(); } }
@Test public void multipleIteratorsNestedInnerNewRange() throws Exception { Assume.assumeTrue( indexCoordinator.supportRangeQuery() ); try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryRange( ktx ) ) { List<Long> actual1 = new ArrayList<>(); while ( cursor1.next() ) { actual1.add( cursor1.nodeReference() ); try ( NodeValueIndexCursor cursor2 = indexCoordinator.queryRange( ktx ) ) { List<Long> actual2 = asList( cursor2 ); indexCoordinator.assertRangeResult( actual2 ); } } // then indexCoordinator.assertRangeResult( actual1 ); } tx.success(); } }
@Test public void multipleCursorsNotNestedExists() throws Exception { try ( Transaction tx = db.beginTx() ) { KernelTransaction ktx = db.transaction(); // when try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryExists( ktx ); NodeValueIndexCursor cursor2 = indexCoordinator.queryExists( ktx ) ) { List<Long> actual1 = asList( cursor1 ); List<Long> actual2 = asList( cursor2 ); // then indexCoordinator.assertExistsResult( actual1 ); indexCoordinator.assertExistsResult( actual2 ); } tx.success(); } }
@Test public void multipleCursorsNotNestedExact() throws Exception { try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryExact( ktx ); NodeValueIndexCursor cursor2 = indexCoordinator.queryExact( ktx ) ) { List<Long> actual1 = asList( cursor1 ); List<Long> actual2 = asList( cursor2 ); // then indexCoordinator.assertExactResult( actual1 ); indexCoordinator.assertExactResult( actual2 ); } tx.success(); } }
@Test public void multipleIteratorsNotNestedRange() throws KernelException { Assume.assumeTrue( indexCoordinator.supportRangeQuery() ); try ( Transaction tx = db.beginTx() ) { // when KernelTransaction ktx = db.transaction(); try ( NodeValueIndexCursor cursor1 = indexCoordinator.queryRange( ktx ); NodeValueIndexCursor cursor2 = indexCoordinator.queryRange( ktx ) ) { List<Long> actual1 = asList( cursor1 ); List<Long> actual2 = asList( cursor2 ); // then indexCoordinator.assertRangeResult( actual1 ); indexCoordinator.assertRangeResult( actual2 ); } tx.success(); } }
void init( DatabaseRule db ) { try ( Transaction tx = db.beginTx() ) { for ( int i = 0; i < numberOfNodes; i++ ) { Node node = db.createNode( indexLabel ); node.setProperty( numberProp1, numberProp1Values[i] ); node.setProperty( numberProp2, numberProp2Values[i] ); node.setProperty( stringProp1, stringProp1Values[i] ); node.setProperty( stringProp2, stringProp2Values[i] ); } tx.success(); } try ( Transaction tx = db.beginTx() ) { TokenRead tokenRead = db.transaction().tokenRead(); indexedLabelId = tokenRead.nodeLabel( indexLabel.name() ); numberPropId1 = tokenRead.propertyKey( numberProp1 ); numberPropId2 = tokenRead.propertyKey( numberProp2 ); stringPropId1 = tokenRead.propertyKey( stringProp1 ); stringPropId2 = tokenRead.propertyKey( stringProp2 ); tx.success(); } indexDescriptor = extractIndexDescriptor(); }
public <T> T executeAndCommit( Function<? super GraphDatabaseService, T> function ) { return transaction( function, true ); }
public <T> T executeAndRollback( Function<? super GraphDatabaseService, T> function ) { return transaction( function, false ); }
public void executeAndCommit( Consumer<? super GraphDatabaseService> consumer ) { transaction( (Function<? super GraphDatabaseService,Void>) t -> { consumer.accept( t ); return null; }, true ); }