From ba290fd3a007b4fdabf6130a2e9f975059edfd8a Mon Sep 17 00:00:00 2001 From: Ralph Gasser Date: Thu, 18 Jan 2024 10:58:29 +0100 Subject: [PATCH] Fixes compilation issue due to type erasure. --- .../language/basics/expression/ValueList.kt | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/cottontaildb-client/src/main/kotlin/org/vitrivr/cottontail/client/language/basics/expression/ValueList.kt b/cottontaildb-client/src/main/kotlin/org/vitrivr/cottontail/client/language/basics/expression/ValueList.kt index 1a079086c..4eaf45eb5 100644 --- a/cottontaildb-client/src/main/kotlin/org/vitrivr/cottontail/client/language/basics/expression/ValueList.kt +++ b/cottontaildb-client/src/main/kotlin/org/vitrivr/cottontail/client/language/basics/expression/ValueList.kt @@ -15,21 +15,24 @@ import java.util.* @Serializable @SerialName("ValueList") class ValueList(val value: List): Expression() { - constructor(list: List): this( list.map { BooleanValue(it) }) - constructor(list: List): this( list.map { ShortValue(it) }) - constructor(list: List): this( list.map { ShortValue(it) }) - constructor(list: List): this( list.map { IntValue(it) }) - constructor(list: List): this( list.map { LongValue(it) }) - constructor(list: List): this( list.map { FloatValue(it) }) - constructor(list: List): this( list.map { DoubleValue(it) }) - constructor(list: List): this( list.map { DateValue(it) }) - constructor(list: List): this( list.map { StringValue(it) }) - constructor(list: List): this( list.map { UuidValue(it) }) - constructor(list: List): this( list.map { BooleanVectorValue(it) }) - constructor(list: List): this( list.map { IntVectorValue(it) }) - constructor(list: List): this( list.map { LongVectorValue(it) }) - constructor(list: List): this( list.map { FloatVectorValue(it) }) - constructor(list: List): this( list.map { DoubleVectorValue(it) }) + constructor(list: List): this(when (list.first()) { + is Boolean -> list.filterIsInstance().map { BooleanValue(it) } + is Byte -> list.filterIsInstance().map { ByteValue(it) } + is Short -> list.filterIsInstance().map { ShortValue(it) } + is Int -> list.filterIsInstance().map { IntValue(it) } + is Long -> list.filterIsInstance().map { LongValue(it) } + is Float -> list.filterIsInstance().map { FloatValue(it) } + is Double -> list.filterIsInstance().map { DoubleValue(it) } + is Date -> list.filterIsInstance().map { DateValue(it) } + is String -> list.filterIsInstance().map { StringValue(it) } + is UUID -> list.filterIsInstance().map { UuidValue(it) } + is BooleanArray -> list.filterIsInstance().map { BooleanVectorValue(it) } + is IntArray -> list.filterIsInstance().map { IntVectorValue(it) } + is LongArray -> list.filterIsInstance().map { LongVectorValue(it) } + is FloatArray -> list.filterIsInstance().map { FloatVectorValue(it) } + is DoubleArray -> list.filterIsInstance().map { DoubleVectorValue(it) } + else -> throw IllegalArgumentException("Cannot create ValueList from list of type ${list.first().javaClass.simpleName}.") + }) override fun toGrpc(): CottontailGrpc.Expression { val builder = CottontailGrpc.Expression.newBuilder()