Skip to content

Commit

Permalink
Adds a few constructors to maintain compatibility with Java.
Browse files Browse the repository at this point in the history
  • Loading branch information
ppanopticon committed Jan 18, 2024
1 parent ebfc067 commit 9fcc37a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import org.vitrivr.cottontail.core.values.*
import org.vitrivr.cottontail.grpc.CottontailGrpc
import java.util.*

/**
* A [Literal] value [Expression].
*
* @author Ralph Gasser
* @version 1.0.0
* @version 1.1.0
*/
@Serializable
@SerialName("Literal")
Expand All @@ -22,6 +23,8 @@ data class Literal(val value: PublicValue): Expression() {
constructor(value: Float): this(FloatValue(value))
constructor(value: Double): this(DoubleValue(value))
constructor(value: String): this(StringValue(value))
constructor(value: UUID): this(UuidValue(value))
constructor(value: Date): this(DateValue(value))
constructor(value: BooleanArray): this(BooleanVectorValue(value))
constructor(value: IntArray): this(IntVectorValue(value))
constructor(value: LongArray): this(LongVectorValue(value))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,35 @@ package org.vitrivr.cottontail.client.language.basics.expression

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import org.vitrivr.cottontail.core.values.PublicValue
import org.vitrivr.cottontail.core.values.*
import org.vitrivr.cottontail.grpc.CottontailGrpc
import java.util.*

/**
* A list of [Literal] values [Expression]. Mainly used for IN queries.
*
* @author Ralph Gasser
* @version 1.0.0
* @version 1.1.0
*/
@Serializable
@SerialName("ValueList")
class ValueList(val value: Array<PublicValue>): Expression() {
class ValueList(val value: List<PublicValue>): Expression() {
constructor(list: List<Boolean>): this( list.map { BooleanValue(it) })
constructor(list: List<Byte>): this( list.map { ShortValue(it) })
constructor(list: List<Short>): this( list.map { ShortValue(it) })
constructor(list: List<Int>): this( list.map { IntValue(it) })
constructor(list: List<Long>): this( list.map { LongValue(it) })
constructor(list: List<Float>): this( list.map { FloatValue(it) })
constructor(list: List<Double>): this( list.map { DoubleValue(it) })
constructor(list: List<Date>): this( list.map { DateValue(it) })
constructor(list: List<String>): this( list.map { StringValue(it) })
constructor(list: List<UUID>): this( list.map { UuidValue(it) })
constructor(list: List<BooleanArray>): this( list.map { BooleanVectorValue(it) })
constructor(list: List<IntArray>): this( list.map { IntVectorValue(it) })
constructor(list: List<LongArray>): this( list.map { LongVectorValue(it) })
constructor(list: List<FloatArray>): this( list.map { FloatVectorValue(it) })
constructor(list: List<DoubleArray>): this( list.map { DoubleVectorValue(it) })

override fun toGrpc(): CottontailGrpc.Expression {
val builder = CottontailGrpc.Expression.newBuilder()
for (data in this.value) {
Expand Down

0 comments on commit 9fcc37a

Please sign in to comment.