Skip to content

Commit

Permalink
Merge branch 'dev' into feature/filtercriteria
Browse files Browse the repository at this point in the history
  • Loading branch information
net-cscience-raphael committed Dec 12, 2024
2 parents ade752c + 72f01a9 commit b3bfafb
Show file tree
Hide file tree
Showing 5 changed files with 2,405 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ScalarDescriptorReader(field: Schema.Field<*, ScalarDescriptor<*, *>>, con
*/
private fun queryFulltext(query: SimpleFulltextQuery): Sequence<ScalarDescriptor<*, *>> {
val queryString = query.value.value.split(" ").map { "$it:*" }.joinToString(" | ") { it }
val statement = "SELECT * FROM v3c.\"${tableName.lowercase()}\" WHERE ${query.attributeName} @@ to_tsquery(?)"
val statement = "SELECT * FROM \"${tableName.lowercase()}\" WHERE $VALUE_ATTRIBUTE_NAME @@ to_tsquery(?)"
return sequence {
this@ScalarDescriptorReader.connection.jdbc.prepareStatement(statement).use { stmt ->
stmt.setString(1, queryString)
Expand Down
3 changes: 3 additions & 0 deletions vitrivr-engine-query/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ plugins {

dependencies {
api project(':vitrivr-engine-core')

/* Open API annotations. */
implementation group: 'io.javalin.community.openapi', name: 'javalin-openapi-plugin', version: version_javalin
}

/* Publication of vitrivr engine query to Maven Central. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
package org.vitrivr.engine.query.model.api.input

import io.javalin.openapi.Discriminator
import io.javalin.openapi.DiscriminatorProperty
import io.javalin.openapi.OneOf
import kotlinx.serialization.Serializable
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.content.impl.memory.InMemoryImageContent
import org.vitrivr.engine.core.model.content.impl.memory.InMemoryTextContent
import org.vitrivr.engine.core.util.extension.BufferedImage
import java.awt.image.BufferedImage
import java.text.SimpleDateFormat
import java.util.*

/**
* The abstract [InputData], essentially a query's input value.
*/
@Serializable(with = InputDataSerializer::class)
@OneOf(
discriminator = Discriminator(DiscriminatorProperty("type", type = InputType::class)),
value = [
TextInputData::class,
ImageInputData::class,
VectorInputData::class,
RetrievableIdInputData::class,
BooleanInputData::class,
NumericInputData::class,
DateInputData::class
]
)
sealed class InputData() {
/**
* The [InputType] of this [InputType]. Required for polymorphic deserialisation.
Expand Down Expand Up @@ -50,7 +64,6 @@ sealed class InputData() {
@Serializable
data class TextInputData(val data: String, override val comparison: String? = "==") : InputData() {
override val type = InputType.TEXT

override fun toContent(): TextContent = InMemoryTextContent(data)
}

Expand All @@ -61,11 +74,9 @@ data class TextInputData(val data: String, override val comparison: String? = "=
@Serializable
data class VectorInputData(val data: List<Float>, override val comparison: String? = "==") : InputData(){
override val type = InputType.VECTOR

override fun toContent(): ContentElement<*> {
throw UnsupportedOperationException("Cannot derive content from VectorInputData")
}

}

/**
Expand All @@ -75,13 +86,7 @@ data class VectorInputData(val data: List<Float>, override val comparison: Strin
@Serializable
data class ImageInputData(val data: String, override val comparison: String? = "==") : InputData() {
override val type = InputType.VECTOR
override fun toContent(): ImageContent = InMemoryImageContent(image)

/**
* [BufferedImage] representation of the base64 input.
*/
private val image: BufferedImage by lazy { BufferedImage(data) }

override fun toContent(): ImageContent = InMemoryImageContent(BufferedImage(data))
}

/**
Expand Down Expand Up @@ -135,7 +140,7 @@ data class DateInputData(val data: String, override val comparison: String? = "=
/**
* Parses the input in YYYY-mm-dd format.
*/
fun parseDate():Date{
fun parseDate(): Date {
val formatter = SimpleDateFormat("YYYY-mm-dd", Locale.ENGLISH)
return formatter.parse(data)
}
Expand Down
Loading

0 comments on commit b3bfafb

Please sign in to comment.