diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractBatchedExtractor.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractBatchedExtractor.kt index 76dbe6590..da0f289f3 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractBatchedExtractor.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractBatchedExtractor.kt @@ -41,7 +41,7 @@ abstract class AbstractBatchedExtractor, D : Descriptor<*> retrievable.filteredAttribute(ContentAuthorAttribute::class.java)?.getContentIds(it) } return retrievable.content.filter { content -> - this.analyser.contentClasses.any { it.isInstance(content) && (contentIds?.contains(content.id) ?: false) } + this.analyser.contentClasses.any { it.isInstance(content) && (contentIds?.contains(content.id) ?: true) } }.map { it as C } } diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractExtractor.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractExtractor.kt index 09870c7e8..59ee75ebf 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractExtractor.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/AbstractExtractor.kt @@ -37,8 +37,8 @@ abstract class AbstractExtractor, D : Descriptor<*>>(final retrievable.filteredAttribute(ContentAuthorAttribute::class.java)?.getContentIds(it) } return retrievable.content.filter { content -> - this.analyser.contentClasses.any { it.isInstance(content) && (contentIds?.contains(content.id) ?: false) } - }.map { it as C } + this.analyser.contentClasses.any { it.isInstance(content) && (contentIds?.contains(content.id) ?: true) } + }.map { it as C} } /** diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColorExtractor.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColorExtractor.kt index 575102162..303315e27 100644 --- a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColorExtractor.kt +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/features/averagecolor/AverageColorExtractor.kt @@ -41,7 +41,7 @@ class AverageColorExtractor(input: Operator, analyser: AverageColor * @return List of resulting [Descriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.map { (this.analyser as AverageColor).analyse(it).copy(retrievableId = retrievable.id, field = this.field) } } } \ No newline at end of file diff --git a/vitrivr-engine-index/src/main/kotlin/org/vitrivr/engine/index/exporters/ThumbnailExporter.kt b/vitrivr-engine-index/src/main/kotlin/org/vitrivr/engine/index/exporters/ThumbnailExporter.kt index 31212163e..2648699c4 100644 --- a/vitrivr-engine-index/src/main/kotlin/org/vitrivr/engine/index/exporters/ThumbnailExporter.kt +++ b/vitrivr-engine-index/src/main/kotlin/org/vitrivr/engine/index/exporters/ThumbnailExporter.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.onEach import org.vitrivr.engine.core.context.IndexContext import org.vitrivr.engine.core.model.content.element.ImageContent import org.vitrivr.engine.core.model.retrievable.Retrievable +import org.vitrivr.engine.core.model.retrievable.attributes.ContentAuthorAttribute import org.vitrivr.engine.core.operators.Operator import org.vitrivr.engine.core.operators.general.Exporter import org.vitrivr.engine.core.operators.general.ExporterFactory @@ -46,20 +47,24 @@ class ThumbnailExporter : ExporterFactory { } } ?: MimeType.JPG logger.debug { "Creating new ThumbnailExporter with maxSideResolution=$maxSideResolution and mimeType=$mimeType." } - return Instance(input, context, maxSideResolution, mimeType) + return Instance(input, context, maxSideResolution, mimeType, context[name, "contentSources"]?.split(",")?.toSet() ?: emptySet()) } /** * The [Exporter] generated by this [ThumbnailExporter]. */ - private class Instance(override val input: Operator, private val context: IndexContext, private val maxResolution: Int, private val mimeType: MimeType) : Exporter { + private class Instance(override val input: Operator, private val context: IndexContext, private val maxResolution: Int, private val mimeType: MimeType, private val contentSources:Set) : Exporter { init { require(mimeType in SUPPORTED) { "ThumbnailExporter only support image formats JPEG and PNG." } } + override fun toFlow(scope: CoroutineScope): Flow = this.input.toFlow(scope).onEach { retrievable -> val resolvable = this.context.resolver.resolve(retrievable.id) - val content = retrievable.content.filterIsInstance() + + val contentIds = retrievable.filteredAttribute(ContentAuthorAttribute::class.java)?.getContentIds(contentSources) + + val content = retrievable.content.filterIsInstance().filter { contentIds?.contains(it.id) ?: true } if (resolvable != null && content.isNotEmpty()) { val writer = when (mimeType) { MimeType.JPEG, diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/cld/CLDExtractor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/cld/CLDExtractor.kt index 96224e977..0f6ec0d76 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/cld/CLDExtractor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/cld/CLDExtractor.kt @@ -38,7 +38,7 @@ class CLDExtractor(input: Operator, analyser: CLD, field: Schema.Fi * @return List of resulting [Descriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.map { (this.analyser as CLD).analyse(it).copy(retrievableId = retrievable.id, field = this.field) } } } \ No newline at end of file diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/dominantcolor/DominantColorExtractor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/dominantcolor/DominantColorExtractor.kt index 67051f4ed..e080f285a 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/dominantcolor/DominantColorExtractor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/dominantcolor/DominantColorExtractor.kt @@ -26,7 +26,7 @@ class DominantColorExtractor(input: Operator, analyser: DominantCol override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return (this.analyser as DominantColor).analyse(content).map { it.copy(retrievableId = retrievable.id, field = this@DominantColorExtractor.field) } } diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/ehd/EHDExtractor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/ehd/EHDExtractor.kt index 5e6f060df..8e3d8279e 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/ehd/EHDExtractor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/ehd/EHDExtractor.kt @@ -38,7 +38,7 @@ class EHDExtractor(input: Operator, analyser: EHD, field: Schema.Fi * @return List of resulting [Descriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.map { (this.analyser as EHD).analyse(it).copy(retrievableId = retrievable.id, field = this.field) } } } \ No newline at end of file diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/clip/CLIPExtractor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/clip/CLIPExtractor.kt index d3f9d064d..4cf4edcf8 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/clip/CLIPExtractor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/clip/CLIPExtractor.kt @@ -36,7 +36,7 @@ class CLIPExtractor(input: Operator, analyser: CLIP, field: Schema. * @return List of resulting [Descriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.map { c -> CLIP.analyse(c, this.host).copy(retrievableId = retrievable.id, field = this@CLIPExtractor.field) } diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/dino/DINOExtractor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/dino/DINOExtractor.kt index d1748e536..408e48ca2 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/dino/DINOExtractor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/external/implementations/dino/DINOExtractor.kt @@ -36,7 +36,7 @@ class DINOExtractor(input: Operator, analyser: DINO, field: Schema. * @return List of resulting [Descriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.map { c -> DINO.analyse(c, this.host).copy(retrievableId = retrievable.id, field = this@DINOExtractor.field) } diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/huehistogram/HueHistogramExtractor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/huehistogram/HueHistogramExtractor.kt index cda421324..68db85144 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/huehistogram/HueHistogramExtractor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/huehistogram/HueHistogramExtractor.kt @@ -39,7 +39,7 @@ class HueHistogramExtractor(input: Operator, analyser: HueHistogram * @return List of resulting [Descriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.map { (this.analyser as HueHistogram).analyse(it).copy(retrievableId = retrievable.id, field = this.field) } } } \ No newline at end of file diff --git a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/mediancolor/MedianColorExtractor.kt b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/mediancolor/MedianColorExtractor.kt index 53560654f..64e9480f0 100644 --- a/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/mediancolor/MedianColorExtractor.kt +++ b/vitrivr-engine-module-features/src/main/kotlin/org/vitrivr/engine/module/features/feature/mediancolor/MedianColorExtractor.kt @@ -39,7 +39,7 @@ class MedianColorExtractor(input: Operator, analyser: MedianColor, * @return List of resulting [Descriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.map { (this.analyser as MedianColor).analyse(it).copy(retrievableId = retrievable.id, field = this.field) } } } \ No newline at end of file diff --git a/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonicsExtractor.kt b/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonicsExtractor.kt index 62416b0be..5ffba9757 100644 --- a/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonicsExtractor.kt +++ b/vitrivr-engine-module-m3d/src/main/kotlin/org/vitrivr/engine/model3d/features/sphericalharmonics/SphericalHarmonicsExtractor.kt @@ -27,9 +27,9 @@ class SphericalHarmonicsExtractor( private val gridSize: Int, private val cap: Int, private val minL: Int, - private val maxL: Int -) : - AbstractExtractor(input, analyser, field) { + private val maxL: Int, + parameters : Map +) : AbstractExtractor(input, analyser, field, parameters) { init { require(this.minL < this.maxL) { "Parameter mismatch: min_l must be smaller than max_l. "} @@ -52,7 +52,7 @@ class SphericalHarmonicsExtractor( * @return List of resulting [FloatVectorDescriptor]s. */ override fun extract(retrievable: Retrievable): List { - val content = retrievable.content.filterIsInstance() + val content = this.filterContent(retrievable) return content.flatMap { c -> c.content.getMaterials().flatMap { mat -> mat.meshes.map { mesh -> SphericalHarmonics.analyse(mesh, this.gridSize, this.minL, this.maxL, this.cap).copy(field = this.field) } } } } } \ No newline at end of file