diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Analyser.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Analyser.kt index a209a6fc..04c0cb07 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Analyser.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Analyser.kt @@ -20,7 +20,7 @@ import kotlin.reflect.KClass * * @author Luca Rossetto * @author Ralph Gasser - * @version 1.1.0 + * @version 1.2.0 */ interface Analyser, D: Descriptor> { /** The [KClass]es of the [ContentElement] accepted by this [Analyser]. */ @@ -56,7 +56,8 @@ interface Analyser, D: Descriptor> { /** * Generates and returns a new [Retriever] instance for this [Analyser]. * - * Some [Analyser]s may not come with their own [Retriever], in which case the implementation of this method should throw an [UnsupportedOperationException] + * This is the base-case, every [Analyser] should support this operation unless the [Analyser] is not meant to be used for retrieval at all, + * in which case the implementation of this method should throw an [UnsupportedOperationException] * * @param field The [Schema.Field] to create an [Retriever] for. * @param query The [Query] to use with the [Retriever]. @@ -70,14 +71,34 @@ interface Analyser, D: Descriptor> { /** * Generates and returns a new [Retriever] instance for this [Analyser]. * - * Some [Analyser]s may not come with their own [Retriever], in which case the implementation of this method should throw an [UnsupportedOperationException] + * Some [Analyser]s may not come with their own [Retriever] or may not support generating a [Retriever] from [Content]. + * In both chases, the implementation of this method should throw an [UnsupportedOperationException]. * * @param field The [Schema.Field] to create an [Retriever] for. * @param content An array of [Content] elements to use with the [Retriever] * @param context The [QueryContext] to use with the [Retriever] * * @return A new [Retriever] instance for this [Analyser] - * @throws [UnsupportedOperationException], if this [Analyser] does not support the creation of an [Retriever] instance. + * @throws [UnsupportedOperationException], if this [Analyser] does not support the creation of an [Retriever] instance from [Content]. + */ + fun newRetrieverForContent(field: Schema.Field, content: Collection, context: QueryContext): Retriever { + throw UnsupportedOperationException("This Analyser does not support the creation of a retriever from a collection of descriptors.") + } + + /** + * Generates and returns a new [Retriever] instance for this [Analyser] from the provided [Collection] of [Descriptor]s. + * + * Some [Analyser]s may not come with their own [Retriever] or may not support generating a [Retriever] from a [Descriptor]. + * In both chases, the implementation of this method should throw an [UnsupportedOperationException]. + * + * @param field The [Schema.Field] to create an [Retriever] for. + * @param descriptors An array of [Descriptor] elements to use with the [Retriever] + * @param context The [QueryContext] to use with the [Retriever] + * + * @return A new [Retriever] instance for this [Analyser] + * @throws [UnsupportedOperationException], if this [Analyser] does not support the creation of an [Retriever] instance from [Descriptor]s. */ - fun newRetrieverForContent(field: Schema.Field, content: Collection, context: QueryContext): Retriever + fun newRetrieverForDescriptors(field: Schema.Field, descriptors: Collection, context: QueryContext): Retriever { + throw UnsupportedOperationException("This Analyser does not support the creation of a retriever from a collection of descriptors.") + } } \ No newline at end of file diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Schema.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Schema.kt index 5a0285ef..49bea75b 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Schema.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/metamodel/Schema.kt @@ -176,6 +176,22 @@ class Schema(val name: String = "vitrivr", val connection: Connection) : Closeab */ fun getRetrieverForContent(content: Collection, queryContext: QueryContext): Retriever = this.analyser.newRetrieverForContent(this, content, queryContext) + /** + * Returns a [Retriever] instance for this [Schema.Field]. + * + * @param descriptor The [Descriptor] that should be used with the [Retriever]. + * @return [Retriever] instance. + */ + fun getRetrieverForDescriptor(descriptor: D, queryContext: QueryContext): Retriever = this.getRetrieverForDescriptors(listOf(descriptor), queryContext) + + /** + * Returns a [Retriever] instance for this [Schema.Field]. + * + * @param descriptors The [Descriptor] element(s) that should be used with the [Retriever]. + * @return [Retriever] instance. + */ + fun getRetrieverForDescriptors(descriptors: Collection, queryContext: QueryContext): Retriever = this.analyser.newRetrieverForDescriptors(this, descriptors, queryContext) + /** * Returns the [DescriptorInitializer] for this [Schema.Field]. * diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/query/proximity/ProximityQuery.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/query/proximity/ProximityQuery.kt index 3ea73afd..8088a933 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/query/proximity/ProximityQuery.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/model/query/proximity/ProximityQuery.kt @@ -28,7 +28,7 @@ data class ProximityQuery>( val order: SortOrder = SortOrder.ASC, /** The number of results that should be returned by this [ProximityQuery]. */ - val k: Int = 1000, + val k: Long = 1000L, /** Flag indicating, whether [VectorDescriptor] should be returned as well. */ val fetchVector: Boolean = false, diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/averagecolor/AverageColor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/averagecolor/AverageColor.kt index 25572b89..68221b8b 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/averagecolor/AverageColor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/averagecolor/AverageColor.kt @@ -84,26 +84,36 @@ class AverageColor : Analyser { /** * Generates and returns a new [AverageColorRetriever] instance for this [AverageColor]. * - * Invoking this method involves converting the provided [ImageContent] and the [QueryContext] into a [ProximityQuery] that can be used to retrieve - * similar [ImageContent] elements. - * + * Invoking this method involves converting the provided [FloatVectorDescriptor] into a [ProximityQuery] that can be used to retrieve similar [ImageContent] elements. * * @param field The [Schema.Field] to create an [Retriever] for. - * @param content An array of [Content] elements to use with the [Retriever] + * @param descriptors An array of [FloatVectorDescriptor] elements to use with the [Retriever] * @param context The [QueryContext] to use with the [Retriever] */ - override fun newRetrieverForContent(field: Schema.Field, content: Collection, context: QueryContext): AverageColorRetriever { + override fun newRetrieverForDescriptors(field: Schema.Field, descriptors: Collection, context: QueryContext): AverageColorRetriever { require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" } /* Prepare query parameters. */ - val k = context.getProperty(field.fieldName, "limit")?.toIntOrNull() ?: 1000 + val k = context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L val fetchVector = context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false - val vector = this.analyse(content).first().vector /* Return retriever. */ - return this.newRetrieverForQuery(field, ProximityQuery(value = vector, k = k, fetchVector = fetchVector), context) + return this.newRetrieverForQuery(field, ProximityQuery(value = descriptors.first().vector, k = k, fetchVector = fetchVector), context) } + /** + * Generates and returns a new [AverageColorRetriever] instance for this [AverageColor]. + * + * Invoking this method involves converting the provided [ImageContent] and the [QueryContext] into a [FloatVectorDescriptor] + * that can be used to retrieve similar [ImageContent] elements. + * + * @param field The [Schema.Field] to create an [Retriever] for. + * @param content An array of [Content] elements to use with the [Retriever] + * @param context The [QueryContext] to use with the [Retriever] + */ + override fun newRetrieverForContent(field: Schema.Field, content: Collection, context: QueryContext): AverageColorRetriever = + this.newRetrieverForDescriptors(field, this.analyse(content), context) + /** * Performs the [AverageColor] analysis on the provided [List] of [ImageContent] elements. * diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/clip/CLIP.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/clip/CLIP.kt index d7e3177b..ca950f47 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/clip/CLIP.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/clip/CLIP.kt @@ -2,12 +2,14 @@ package org.vitrivr.engine.base.features.external.implementations.clip import org.vitrivr.engine.base.features.external.ExternalAnalyser import org.vitrivr.engine.base.features.external.common.ExternalWithFloatVectorDescriptorAnalyser +import org.vitrivr.engine.base.features.external.implementations.dino.DINORetriever import org.vitrivr.engine.core.context.IndexContext import org.vitrivr.engine.core.context.QueryContext import org.vitrivr.engine.core.model.content.element.ContentElement import org.vitrivr.engine.core.model.content.element.ImageContent import org.vitrivr.engine.core.model.content.element.TextContent import org.vitrivr.engine.core.model.descriptor.vector.FloatVectorDescriptor +import org.vitrivr.engine.core.model.metamodel.Analyser import org.vitrivr.engine.core.model.metamodel.Schema import org.vitrivr.engine.core.model.query.Query import org.vitrivr.engine.core.model.query.proximity.ProximityQuery @@ -74,6 +76,25 @@ class CLIP : ExternalWithFloatVectorDescriptorAnalyser>() { return CLIPRetriever(field, query as ProximityQuery, context) } + /** + * Generates and returns a new [DINORetriever] instance for this [CLIP]. + * + * @param field The [Schema.Field] to create an [Retriever] for. + * @param descriptors An array of [FloatVectorDescriptor] elements to use with the [Retriever] + * @param context The [QueryContext] to use with the [Retriever] + * + * @return A new [Retriever] instance for this [Analyser] + * @throws [UnsupportedOperationException], if this [Analyser] does not support the creation of an [Retriever] instance. + */ + override fun newRetrieverForDescriptors(field: Schema.Field, FloatVectorDescriptor>, descriptors: Collection, context: QueryContext): CLIPRetriever { + /* Prepare query parameters. */ + val k = context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L + val fetchVector = context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false + + /* Return retriever. */ + return this.newRetrieverForQuery(field, ProximityQuery(value = descriptors.first().vector, k = k, fetchVector = fetchVector), context) + } + /** * Generates and returns a new [Retriever] instance for this [CLIP]. * @@ -87,13 +108,11 @@ class CLIP : ExternalWithFloatVectorDescriptorAnalyser>() { override fun newRetrieverForContent(field: Schema.Field, FloatVectorDescriptor>, content: Collection>, context: QueryContext): Retriever, FloatVectorDescriptor> { val host = field.parameters[HOST_PARAMETER_NAME] ?: HOST_PARAMETER_DEFAULT - /* Prepare query parameters. */ - val vector = analyse(content.first(), host) - val k = context.getProperty(field.fieldName, "limit")?.toIntOrNull() ?: 1000 - val fetchVector = context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false + /* Extract vectors from content. */ + val vectors = content.map { analyse(it, host) } /* Return retriever. */ - return this.newRetrieverForQuery(field, ProximityQuery(value = vector.vector, k = k, fetchVector = fetchVector), context) + return this.newRetrieverForDescriptors(field, vectors, context) } /** diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/dino/DINO.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/dino/DINO.kt index 2188ee2e..1a289767 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/dino/DINO.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/dino/DINO.kt @@ -70,6 +70,25 @@ class DINO : ExternalWithFloatVectorDescriptorAnalyser() { return DINORetriever(field, query as ProximityQuery, context) } + /** + * Generates and returns a new [DINORetriever] instance for this [DINO]. + * + * @param field The [Schema.Field] to create an [Retriever] for. + * @param descriptors An array of [FloatVectorDescriptor] elements to use with the [Retriever] + * @param context The [QueryContext] to use with the [Retriever] + * + * @return A new [Retriever] instance for this [Analyser] + * @throws [UnsupportedOperationException], if this [Analyser] does not support the creation of an [Retriever] instance. + */ + override fun newRetrieverForDescriptors(field: Schema.Field, descriptors: Collection, context: QueryContext): DINORetriever { + /* Prepare query parameters. */ + val k = context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L + val fetchVector = context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false + + /* Return retriever. */ + return this.newRetrieverForQuery(field, ProximityQuery(value = descriptors.first().vector, k = k, fetchVector = fetchVector), context) + } + /** * Generates and returns a new [DINORetriever] instance for this [DINO]. * @@ -84,13 +103,11 @@ class DINO : ExternalWithFloatVectorDescriptorAnalyser() { require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" } val host = field.parameters[HOST_PARAMETER_NAME] ?: HOST_PARAMETER_DEFAULT - /* Prepare query parameters. */ - val vector = analyse(content.first(), host) - val k = context.getProperty(field.fieldName, "limit")?.toIntOrNull() ?: 1000 - val fetchVector = context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false + /* Extract vectors from content. */ + val vectors = content.map { analyse(it, host) } /* Return retriever. */ - return this.newRetrieverForQuery(field, ProximityQuery(value = vector.vector, k = k, fetchVector = fetchVector), context) + return this.newRetrieverForDescriptors(field, vectors, context) } /** diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/ASR.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/ASR.kt index c24b9af8..c4597825 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/ASR.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/ASR.kt @@ -53,6 +53,22 @@ class ASR : Analyser, StringDescriptor> { return FulltextRetriever(field, query, context) } + /** + * Generates and returns a new [FulltextRetriever] instance for this [ASR]. + * + * @param field The [Schema.Field] to create an [Retriever] for. + * @param descriptors An array of [StringDescriptor] elements to use with the [Retriever] + * @param context The [QueryContext] to use with the [Retriever] + * @return [FulltextRetriever] + */ + override fun newRetrieverForDescriptors(field: Schema.Field, StringDescriptor>, descriptors: Collection, context: QueryContext): Retriever, StringDescriptor> { + require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" } + + /* Prepare query parameters and return retriever. */ + val limit = context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L + return this.newRetrieverForQuery(field, SimpleFulltextQuery(value = descriptors.first().value, limit = limit), context) + } + /** * Generates and returns a new [FulltextRetriever] instance for this [ASR]. * @@ -64,10 +80,9 @@ class ASR : Analyser, StringDescriptor> { override fun newRetrieverForContent(field: Schema.Field, StringDescriptor>, content: Collection>, context: QueryContext): Retriever, StringDescriptor> { require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" } - /* Prepare query parameters. */ + /* Prepare query parameters and return retriever. */ val text = content.filterIsInstance().firstOrNull() ?: throw IllegalArgumentException("No text content found in the provided content.") val limit = context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L - return this.newRetrieverForQuery(field, SimpleFulltextQuery(value = Value.String(text.content), limit = limit), context) } } \ No newline at end of file diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/OCR.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/OCR.kt index 01c54e0a..00f56ad4 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/OCR.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/base/features/fulltext/OCR.kt @@ -53,6 +53,22 @@ class OCR : Analyser, StringDescriptor> { return FulltextRetriever(field, query, context) } + /** + * Generates and returns a new [FulltextRetriever] instance for this [OCR]. + * + * @param field The [Schema.Field] to create an [Retriever] for. + * @param descriptors An array of [StringDescriptor] elements to use with the [Retriever] + * @param context The [QueryContext] to use with the [Retriever] + * @return [FulltextRetriever] + */ + override fun newRetrieverForDescriptors(field: Schema.Field, StringDescriptor>, descriptors: Collection, context: QueryContext): Retriever, StringDescriptor> { + require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" } + + /* Prepare query parameters and return retriever. */ + val limit = context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L + return this.newRetrieverForQuery(field, SimpleFulltextQuery(value = descriptors.first().value, limit = limit), context) + } + /** * Generates and returns a new [FulltextRetriever] instance for this [OCR]. * diff --git a/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonics.kt b/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonics.kt index e0718e9c..627a5244 100644 --- a/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonics.kt +++ b/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonics.kt @@ -23,7 +23,6 @@ import org.vitrivr.engine.core.util.math.MathHelper import org.vitrivr.engine.model3d.model.voxel.VoxelModel import org.vitrivr.engine.model3d.model.voxel.Voxelizer import java.util.* -import kotlin.collections.ArrayList import kotlin.reflect.KClass private val logger: KLogger = KotlinLogging.logger {} @@ -73,34 +72,40 @@ class SphericalHarmonics: Analyser { val maxL = field.parameters[MAXL_PARAMETER_NAME]?.toIntOrNull() ?: MAXL_PARAMETER_DEFAULT val numberOfCoefficients: Int = SphericalHarmonicsFunction.numberOfCoefficients(maxL, true) - SphericalHarmonicsFunction.numberOfCoefficients(minL - 1, true) val vectorSize = ((gridSize / 2) - cap) * numberOfCoefficients - return FloatVectorDescriptor(UUID.randomUUID(), UUID.randomUUID(), List(vectorSize){Value.Float(0f)}, true) + return FloatVectorDescriptor(UUID.randomUUID(), UUID.randomUUID(), List(vectorSize) { Value.Float(0f) }, true) } - override fun newRetrieverForContent(field: Schema.Field, content: Collection, context: QueryContext): Retriever { + override fun newRetrieverForQuery(field: Schema.Field, query: Query, context: QueryContext): Retriever { require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" } + require(query is ProximityQuery<*> && query.value.first() is Value.Float) { } + /* Construct query. */ + @Suppress("UNCHECKED_CAST") + return SphericalHarmonicsRetriever(field, query as ProximityQuery, context) + } + + override fun newRetrieverForDescriptors(field: Schema.Field, descriptors: Collection, context: QueryContext): Retriever { /* Extract parameters from field and context. */ - val mesh = content.first().content.getMaterials().first().meshes.first() - val gridSize = field.parameters[GRID_SIZE_PARAMETER_NAME]?.toIntOrNull() ?: GRID_SIZE_PARAMETER_DEFAULT - val cap = field.parameters[CAP_PARAMETER_NAME]?.toIntOrNull() ?: CAP_PARAMETER_DEFAULT - val minL = field.parameters[MINL_PARAMETER_NAME]?.toIntOrNull() ?: MINL_PARAMETER_DEFAULT - val maxL = field.parameters[MAXL_PARAMETER_NAME]?.toIntOrNull() ?: MAXL_PARAMETER_DEFAULT - val descriptor = this.analyse(mesh, gridSize, cap, minL, maxL) - val k = context.getProperty(field.fieldName, "limit")?.toIntOrNull() ?: 1000 //TODO get limit + val k = context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L val returnDescriptor = context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false - /* Construct query. */ - val query = ProximityQuery(value = descriptor.vector, k = k, distance = Distance.EUCLIDEAN, fetchVector = returnDescriptor) - return SphericalHarmonicsRetriever(field, query, context) + /* Construct query and return retriever. */ + val query = ProximityQuery(value = descriptors.first().vector, k = k, distance = Distance.EUCLIDEAN, fetchVector = returnDescriptor) + return this.newRetrieverForQuery(field, query, context) } - override fun newRetrieverForQuery(field: Schema.Field, query: Query, context: QueryContext): Retriever { + override fun newRetrieverForContent(field: Schema.Field, content: Collection, context: QueryContext): Retriever { require(field.analyser == this) { "The field '${field.fieldName}' analyser does not correspond with this analyser. This is a programmer's error!" } - require(query is ProximityQuery<*> && query.value.first() is Value.Float) { } - /* Construct query. */ - @Suppress("UNCHECKED_CAST") - return SphericalHarmonicsRetriever(field, query as ProximityQuery, context) + /* Extract parameters from field and context. */ + val gridSize = field.parameters[GRID_SIZE_PARAMETER_NAME]?.toIntOrNull() ?: GRID_SIZE_PARAMETER_DEFAULT + val cap = field.parameters[CAP_PARAMETER_NAME]?.toIntOrNull() ?: CAP_PARAMETER_DEFAULT + val minL = field.parameters[MINL_PARAMETER_NAME]?.toIntOrNull() ?: MINL_PARAMETER_DEFAULT + val maxL = field.parameters[MAXL_PARAMETER_NAME]?.toIntOrNull() ?: MAXL_PARAMETER_DEFAULT + val descriptors = content.map { this.analyse(it.content.getMaterials().first().meshes.first(), gridSize, cap, minL, maxL) } + + /* Return retriever. */ + return this.newRetrieverForDescriptors(field, descriptors, context) } override fun newExtractor(field: Schema.Field, input: Operator, context: IndexContext, persisting: Boolean, parameters: Map): SphericalHarmonicsExtractor { diff --git a/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/parsing/QueryParser.kt b/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/parsing/QueryParser.kt index 9de72955..36fe226f 100644 --- a/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/parsing/QueryParser.kt +++ b/vitrivr-engine-query/src/main/kotlin/org/vitrivr/engine/query/parsing/QueryParser.kt @@ -1,7 +1,6 @@ package org.vitrivr.engine.query.parsing import org.vitrivr.engine.core.model.content.element.ContentElement -import org.vitrivr.engine.core.model.descriptor.vector.FloatVectorDescriptor import org.vitrivr.engine.core.model.metamodel.Schema import org.vitrivr.engine.core.model.query.basics.Distance import org.vitrivr.engine.core.model.query.proximity.ProximityQuery @@ -80,7 +79,7 @@ class QueryParser(val schema: Schema) { return when (input) { is VectorInputData -> { /* TODO: Not very happy with this, since this requires a bit too much knowledge about the schema. */ /* Prepare query parameters. */ - val k = description.context.getProperty(field.fieldName, "limit")?.toIntOrNull() ?: 1000 + val k = description.context.getProperty(field.fieldName, "limit")?.toLongOrNull() ?: 1000L val fetchVector = description.context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false val distance = description.context.getProperty(field.fieldName, "distance")?.let { Distance.valueOf(it) } ?: Distance.EUCLIDEAN val vector = input.data.map { Value.Float(it) } @@ -94,16 +93,7 @@ class QueryParser(val schema: Schema) { val id = UUID.fromString(input.id) val reader = field.getReader() val descriptor = reader.getBy(id, "retrievableId") ?: throw IllegalArgumentException("No retrievable with id '$id' present in ${field.fieldName}") - require(descriptor is FloatVectorDescriptor) { "Descriptor is not a FloatVectorDescriptor." } - - /* Prepare query parameters. */ - val k = description.context.getProperty(field.fieldName, "limit")?.toIntOrNull() ?: 1000 - val fetchVector = description.context.getProperty(field.fieldName, "returnDescriptor")?.toBooleanStrictOrNull() ?: false - val distance = description.context.getProperty(field.fieldName, "distance")?.let { Distance.valueOf(it) } ?: Distance.EUCLIDEAN - - /* Prepare query. */ - val query = ProximityQuery(value = descriptor.vector, k = k, fetchVector = fetchVector, distance = distance) - field.getRetrieverForQuery(query, description.context) + field.getRetrieverForDescriptor(descriptor, description.context) } else -> { /* Handles all content input. */