diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/persistence/PersistingSink.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/persistence/PersistingSink.kt index 44772d8c..d4a7d343 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/persistence/PersistingSink.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/operators/persistence/PersistingSink.kt @@ -20,7 +20,11 @@ import org.vitrivr.engine.core.operators.Operator * @author Ralph Gasser * @version 1.0.0 */ -class PersistingSink(override val input: Operator, val context: IndexContext, override val name: String = "output") : Operator.Sink { +class PersistingSink( + override val input: Operator, + val context: IndexContext, + override val name: String = "output" +) : Operator.Sink { /** Logger instance. */ private val logger = KotlinLogging.logger {} @@ -61,16 +65,17 @@ class PersistingSink(override val input: Operator, val context: Ind collect(retrievable, Triple(retrievables, relationships, descriptors)) /* Write entities to database. */ - this.writer.connection.withTransaction { - this.writer.addAll(retrievables) - this.writer.connectAll(relationships) - for ((f, d) in descriptors) { - val writer = f.let { field -> this.descriptorWriters.computeIfAbsent(field) { it.getWriter() } } as? DescriptorWriter> - if (writer?.addAll(d) != true) { - logger.error { "Failed to persist descriptors for field ${f.fieldName}." } - } + //this.writer.connection.withTransaction { + this.writer.addAll(retrievables) + this.writer.connectAll(relationships) + for ((f, d) in descriptors) { + val writer = + f.let { field -> this.descriptorWriters.computeIfAbsent(field) { it.getWriter() } } as? DescriptorWriter> + if (writer?.addAll(d) != true) { + logger.error { "Failed to persist descriptors for field ${f.fieldName}." } } } + //} logger.debug { "Persisted ${retrievables.size} retrievables, ${relationships.size} relationships and ${descriptors.values.sumOf { it.size }} descriptors." } } @@ -78,7 +83,10 @@ class PersistingSink(override val input: Operator, val context: Ind /** * Collects all [Retrievable]s, [Relationship]s and [Descriptor]s that are reachable from the given [Retrievable] and should be persisted.s */ - private fun collect(retrievable: Retrievable, into: Triple, MutableSet, MutableMap, MutableSet>>>) { + private fun collect( + retrievable: Retrievable, + into: Triple, MutableSet, MutableMap, MutableSet>>> + ) { if (retrievable.transient) return /* Add retrievable. */ @@ -88,9 +96,15 @@ class PersistingSink(override val input: Operator, val context: Ind for (relationship in retrievable.relationships) { if (!relationship.transient) { into.second.add(relationship) - if (relationship.subjectId == retrievable.id && relationship is Relationship.WithObject && !into.first.contains(relationship.`object`)) { + if (relationship.subjectId == retrievable.id && relationship is Relationship.WithObject && !into.first.contains( + relationship.`object` + ) + ) { collect(relationship.`object`, into) - } else if (relationship.objectId == retrievable.id && relationship is Relationship.WithSubject && !into.first.contains(relationship.subject)) { + } else if (relationship.objectId == retrievable.id && relationship is Relationship.WithSubject && !into.first.contains( + relationship.subject + ) + ) { collect(relationship.subject, into) } } @@ -101,7 +115,7 @@ class PersistingSink(override val input: Operator, val context: Ind val field = descriptor.field if (field != null) { into.third.compute(field) { _, v -> (v ?: mutableSetOf()).apply { add(descriptor) } } - }else{ + } else { logger.debug { "Descriptor $descriptor has no field and will not be persisted." } } }