diff --git a/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/descriptors/AbstractDescriptorReader.kt b/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/descriptors/AbstractDescriptorReader.kt index 296a8f20..c3666c65 100644 --- a/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/descriptors/AbstractDescriptorReader.kt +++ b/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/descriptors/AbstractDescriptorReader.kt @@ -34,9 +34,11 @@ abstract class AbstractDescriptorReader(final override val field * * @return [Sequence] of all [Descriptor]s. */ - override fun get(id: UUID): D? { + override fun get(id: UUID): D? = getBy(id, CottontailConnection.DESCRIPTOR_ID_COLUMN_NAME) + + override fun getBy(id: UUID, columnName: String): D? { val query = org.vitrivr.cottontail.client.language.dql.Query(this.entityName) - .where(Compare(Column(this.entityName.column(CottontailConnection.DESCRIPTOR_ID_COLUMN_NAME)), Compare.Operator.EQUAL, Literal(id.toString()))) + .where(Compare(Column(this.entityName.column(columnName)), Compare.Operator.EQUAL, Literal(id.toString()))) return try { val result = this.connection.client.query(query) val ret = if (result.hasNext()) { diff --git a/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/retrievable/RetrievableReader.kt b/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/retrievable/RetrievableReader.kt index 6f899d2b..7456bf5b 100644 --- a/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/retrievable/RetrievableReader.kt +++ b/vitrivr-engine-base/src/main/kotlin/org/vitrivr/engine/base/database/cottontail/retrievable/RetrievableReader.kt @@ -47,10 +47,12 @@ internal class RetrievableReader(private val connection: CottontailConnection) : * @param id [RetrievableId]s to return. * @return A [Sequence] of all [Retrievable]. */ - override fun get(id: RetrievableId): Retrievable? { + override fun get(id: RetrievableId): Retrievable? = getBy(id, RETRIEVABLE_ID_COLUMN_NAME) + + override fun getBy(id: UUID, columnName: String): Retrievable? { val query = Query(this.entityName).where( Compare( - Column(this.entityName.column(RETRIEVABLE_ID_COLUMN_NAME)), + Column(this.entityName.column(columnName)), Compare.Operator.EQUAL, Literal(id.toString()) ) @@ -60,8 +62,8 @@ internal class RetrievableReader(private val connection: CottontailConnection) : if (it.hasNext()) { val tuple = it.next() val retrievableId = UUID.fromString( - tuple.asString(RETRIEVABLE_ID_COLUMN_NAME) - ?: throw IllegalArgumentException("The provided tuple is missing the required field '${RETRIEVABLE_ID_COLUMN_NAME}'.") + tuple.asString(columnName) + ?: throw IllegalArgumentException("The provided tuple is missing the required field '${columnName}'.") ) val type = tuple.asString(RETRIEVABLE_TYPE_COLUMN_NAME) Retrieved.Default(retrievableId, type, false) /* TODO: Use UUID type once supported. */ diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/database/Reader.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/database/Reader.kt index 5cc68e4a..6a40b2e4 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/database/Reader.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/database/Reader.kt @@ -14,13 +14,18 @@ import java.util.* */ interface Reader { /** - * Returns a [Persistable] of type [T] that corresponds to the provided [UUID]. + * Returns a [Persistable] of type [T] that corresponds to the provided [UUID]. * * @param id The [UUID] to return. * @return [Sequence] of [Persistable] of type [T] */ operator fun get(id: UUID): T? + /** + * Returns a [Persistable] of type [T] that corresponds to the provided [UUID] in a specified columnName. + */ + fun getBy(id: UUID, columnName: String): T? + /** * Checks if a [Persistable] of type [T] with the provided [UUID] exists. * 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 22c9fc06..d481a012 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 @@ -68,7 +68,7 @@ class RetrievalRuntime { val id = UUID.fromString((inputDescription as RetrievableIdInputData).id) val reader = field.getReader() - val descriptor = reader[id] ?: throw IllegalArgumentException("No retrievable with id '$id' present in ${field.fieldName}") + val descriptor = reader.getBy(id, "retrievableId") ?: throw IllegalArgumentException("No retrievable with id '$id' present in ${field.fieldName}") field.getRetrieverForDescriptor(descriptor, informationNeed.context)