Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- suspend fun query() {
- driver.session().use { session ->
- val cursor: StatementResultCursor = session.readTransactionAsync {
- it.runAsync("query ...", params)
- }.await() // HERE WE DIE WITH OOM
- var record = cursor.nextAsync().await()
- while (record != null) {
- val node = record.get("node")
- mySuspendProcessingFunction(node)
- }
- }
- }
- suspend fun query() {
- session.readTransactionAsync { transaction ->
- transaction.runAsync("query ...", params).thenCompose { cursor ->
- cursor.forEachAsync { record ->
- runBlocking { // BUT I NEED TO DO RUN BLOCKING HERE :(
- val node = record.get("node")
- mySuspendProcessingFunction(node)
- }
- }
- }
- }.thenCompose {
- session.closeAsync()
- }.await()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement