18
18
19
19
package com.vaticle.typedb.studio.state.connection
20
20
21
- import com.vaticle.typedb.client.api.TypeDBOptions
22
- import com.vaticle.typedb.client.api.TypeDBTransaction
23
21
import com.vaticle.typedb.client.api.answer.ConceptMap
24
22
import com.vaticle.typedb.client.api.answer.ConceptMapGroup
25
23
import com.vaticle.typedb.client.api.answer.NumericGroup
@@ -52,9 +50,8 @@ import kotlinx.coroutines.launch
52
50
53
51
@OptIn(ExperimentalTime ::class )
54
52
class QueryRunner constructor(
55
- val transaction : TypeDBTransaction , // TODO: restrict in the future, TypeDB 3.0 answers return complete info
53
+ private val transactionState : TransactionState , // TODO: restrict in the future, TypeDB 3.0 answers return complete info
56
54
private val queries : String ,
57
- private val hasStopSignal : AtomicBoolean ,
58
55
private val onComplete : () -> Unit
59
56
) {
60
57
@@ -118,6 +115,8 @@ class QueryRunner constructor(
118
115
private val lastResponse = AtomicLong (0 )
119
116
private val consumerLatch = CountDownLatch (1 )
120
117
private val coroutineScope = CoroutineScope (EmptyCoroutineContext )
118
+ private val hasStopSignal get() = transactionState.hasStopSignalAtomic.atomic
119
+ val transaction get() = transactionState.transaction
121
120
122
121
fun launch () {
123
122
isRunning.set(true )
@@ -218,7 +217,7 @@ class QueryRunner constructor(
218
217
noResultMsg = INSERT_QUERY_NO_RESULT ,
219
218
queryStr = query.toString(),
220
219
stream = Response .Stream .ConceptMaps ()
221
- ) { transaction.query().insert(query, TypeDBOptions .core ().prefetch(true )) }
220
+ ) { transaction.query().insert(query, transactionState.typeDBOptions ().prefetch(true )) }
222
221
}
223
222
224
223
private fun runUpdateQuery (query : TypeQLUpdate ) {
@@ -228,7 +227,7 @@ class QueryRunner constructor(
228
227
noResultMsg = UPDATE_QUERY_NO_RESULT ,
229
228
queryStr = query.toString(),
230
229
stream = Response .Stream .ConceptMaps ()
231
- ) { transaction.query().update(query, TypeDBOptions .core ().prefetch(true )) }
230
+ ) { transaction.query().update(query, transactionState.typeDBOptions ().prefetch(true )) }
232
231
}
233
232
234
233
private fun runMatchQuery (query : TypeQLMatch ) {
0 commit comments