Skip to content

Commit

Permalink
Added special 'empty' retriever that just looks up a retrievable base…
Browse files Browse the repository at this point in the history
…d on an id
  • Loading branch information
lucaro committed Dec 9, 2023
1 parent 8ec62fd commit 7af00d5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<RetrievableId>
) : Operator.Nullary<Retrieved> {
override fun toFlow(scope: CoroutineScope): Flow<Retrieved> {

return this.retrievableReader.getAll(ids).map {
Retrieved.Default(it.id, it.type, false)
}.asFlow()

}
}

0 comments on commit 7af00d5

Please sign in to comment.