diff --git a/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/execution/RetrievalRuntime.kt b/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/execution/RetrievalRuntime.kt index 1b30304a..2684b469 100644 --- a/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/execution/RetrievalRuntime.kt +++ b/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/execution/RetrievalRuntime.kt @@ -33,11 +33,24 @@ class RetrievalRuntime { OperatorType.RETRIEVER -> { operationDescription as RetrieverDescription + val inputDescription = informationNeed.inputs[operationDescription.input] + ?: throw IllegalArgumentException("Input '${operationDescription.input}' for operation '$operationName' not found") + + if (operationDescription.field.isEmpty()) { //special case, handle pass-through + + if(inputDescription.type != InputType.ID) { + throw IllegalArgumentException("Only inputs of type ID are supported for direct retrievable lookup") + } + + operators[operationName] = RetrievedLookup( + schema.connection.getRetrievableReader(), listOf(UUID.fromString((inputDescription as RetrievableIdInputData).id)) + ) + + } + val field = schema[operationDescription.field] ?: throw IllegalArgumentException("Retriever '${operationDescription.field}' not defined in schema") - val inputDescription = informationNeed.inputs[operationDescription.input] - ?: throw IllegalArgumentException("Input '${operationDescription.input}' for operation '$operationName' not found") val retriever = when (inputDescription.type) { InputType.VECTOR -> { diff --git a/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/execution/RetrievedLookup.kt b/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/execution/RetrievedLookup.kt new file mode 100644 index 00000000..f183baf8 --- /dev/null +++ b/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/execution/RetrievedLookup.kt @@ -0,0 +1,22 @@ +package org.vitrivr.engine.query.execution + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.asFlow +import org.vitrivr.engine.core.database.retrievable.RetrievableReader +import org.vitrivr.engine.core.model.retrievable.RetrievableId +import org.vitrivr.engine.core.model.retrievable.Retrieved +import org.vitrivr.engine.core.operators.Operator + +class RetrievedLookup( + private val retrievableReader: RetrievableReader, + private val ids: Collection +) : Operator.Nullary { + override fun toFlow(scope: CoroutineScope): Flow { + + return this.retrievableReader.getAll(ids).map { + Retrieved.Default(it.id, it.type, false) + }.asFlow() + + } +} \ No newline at end of file