-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds JSONL connection #88
Changes from 3 commits
f1c31a7
9468813
90c7646
2aa6ee3
0af2442
8d03253
a5ac9ec
0d0998a
de1e4f8
539aa59
8d0f859
08494ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.vitrivr.engine.core.model.serializer | ||
|
||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import java.util.* | ||
|
||
object DateSerializer: KSerializer<Date> { | ||
override val descriptor = PrimitiveSerialDescriptor("Date", PrimitiveKind.LONG) | ||
override fun serialize(encoder: Encoder, value: Date) = encoder.encodeLong(value.time) | ||
override fun deserialize(decoder: Decoder): Date = Date(decoder.decodeLong()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.vitrivr.engine.core.model.serializer | ||
|
||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import org.vitrivr.engine.core.model.types.Value | ||
import java.util.* | ||
|
||
object DateTimeSerializer: KSerializer<Value.DateTime> { | ||
override val descriptor = PrimitiveSerialDescriptor("DateTime", PrimitiveKind.LONG) | ||
override fun serialize(encoder: Encoder, value: Value.DateTime) = encoder.encodeLong(value.value.time) | ||
override fun deserialize(decoder: Decoder): Value.DateTime = Value.DateTime(Date(decoder.decodeLong())) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.vitrivr.engine.core.model.serializer | ||
|
||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.descriptors.PrimitiveKind | ||
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor | ||
import kotlinx.serialization.encoding.Decoder | ||
import kotlinx.serialization.encoding.Encoder | ||
import java.util.UUID | ||
|
||
object UUIDSerializer: KSerializer<UUID> { | ||
override val descriptor = PrimitiveSerialDescriptor("UUID", PrimitiveKind.STRING) | ||
override fun serialize(encoder: Encoder, value: UUID) = encoder.encodeString(value.toString()) | ||
override fun deserialize(decoder: Decoder): UUID = UUID.fromString(decoder.decodeString()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.vitrivr.engine.core.model.types | ||
|
||
import kotlinx.serialization.Serializable | ||
import java.util.* | ||
|
||
/** | ||
|
@@ -55,6 +56,7 @@ sealed interface Type { | |
* | ||
* Primarily needed, since simple strings and longer texts are treated differently by certain databases. | ||
*/ | ||
@Serializable | ||
data object Text : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.String("") | ||
|
@@ -65,6 +67,7 @@ sealed interface Type { | |
* | ||
* Primarily needed, since simple strings and longer texts are treated differently by certain databases. | ||
*/ | ||
@Serializable | ||
data object String : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.String("") | ||
|
@@ -73,6 +76,7 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Boolean] value. | ||
*/ | ||
@Serializable | ||
data object Boolean : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.Boolean(false) | ||
|
@@ -81,6 +85,7 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Byte] value. | ||
*/ | ||
@Serializable | ||
data object Byte : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.Byte(0) | ||
|
@@ -89,6 +94,7 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Short] value. | ||
*/ | ||
@Serializable | ||
data object Short : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.Short(0) | ||
|
@@ -97,6 +103,7 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Int] value. | ||
*/ | ||
@Serializable | ||
data object Int : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.Int(0) | ||
|
@@ -105,6 +112,7 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Long] value. | ||
*/ | ||
@Serializable | ||
data object Long : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.Long(0L) | ||
|
@@ -113,6 +121,7 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Float] value. | ||
*/ | ||
@Serializable | ||
data object Float : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.Float(0.0f) | ||
|
@@ -121,6 +130,7 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Double] value. | ||
*/ | ||
@Serializable | ||
data object Double : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.Double(0.0) | ||
|
@@ -129,42 +139,57 @@ sealed interface Type { | |
/** | ||
* A [Type] that represents a [Datetime] value. | ||
*/ | ||
@Serializable | ||
data object Datetime : Type { | ||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.DateTime(Date()) | ||
} | ||
|
||
/** | ||
* A [Type] that represents a [UUID] value. | ||
*/ | ||
@Serializable | ||
data object UUID : Type { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just so I can understand why this is needed: UUIDs (thus far) are only used internally by the engine as IDs. Adding this as a type basically means, that we want to be able to actually use UUIDs as fields. Is that the intent? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since I had to touch the type system anyway to make everything serializable, I thought adding this would be nice for completeness' sake. This way, the type can be used, for example, in a struct descriptor that needs to deal with external identifiers. |
||
override val dimensions: kotlin.Int = 1 | ||
override fun defaultValue(): Value<*> = Value.UUIDValue(java.util.UUID(0L, 0L)) | ||
} | ||
|
||
/** | ||
* A [Type] that represents a [BooleanVector] value. | ||
*/ | ||
@Serializable | ||
data class BooleanVector(override val dimensions: kotlin.Int) : Type { | ||
override fun defaultValue(): Value<*> = Value.BooleanVector(this.dimensions) | ||
} | ||
|
||
/** | ||
* A [Type] that represents a [IntVector] value. | ||
*/ | ||
@Serializable | ||
data class IntVector(override val dimensions: kotlin.Int) : Type { | ||
override fun defaultValue(): Value<*> = Value.IntVector(this.dimensions) | ||
} | ||
|
||
/** | ||
* A [Type] that represents a [LongVector] value. | ||
*/ | ||
@Serializable | ||
data class LongVector(override val dimensions: kotlin.Int) : Type { | ||
override fun defaultValue(): Value<*> = Value.LongVector(this.dimensions) | ||
} | ||
|
||
/** | ||
* A [Type] that represents a [FloatVector] value. | ||
*/ | ||
@Serializable | ||
data class FloatVector(override val dimensions: kotlin.Int) : Type { | ||
override fun defaultValue(): Value<*> = Value.FloatVector(this.dimensions) | ||
} | ||
|
||
/** | ||
* A [Type] that represents a [DoubleVector] value. | ||
*/ | ||
@Serializable | ||
data class DoubleVector(override val dimensions: kotlin.Int) : Type { | ||
override fun defaultValue(): Value<*> = Value.DoubleVector(this.dimensions) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works? Amazing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was surprized too