KandraCodec

Converts values between Kotlin types and the DataStax Java driver's type system.

Null contract: if a column is NULL in Scylla:

  • Nullable Kotlin type → returns null (correct)

  • Non-nullable Kotlin type → throws KandraQueryException with a clear message

Encode null contract: if value is null on write:

Custom types can be registered via registerEncoder and registerDecoder. A shared default instance is available via KandraCodec.default.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun decode(row: Row, column: ColumnSchema): Any?

Reads a column from row using the column's metadata and returns a typed Kotlin value.

Link copied to clipboard
fun encode(value: Any?, type: KType): Any?

Converts a Kotlin value to the form expected by the DataStax driver.

Link copied to clipboard
fun <T : Any> registerDecoder(klass: KClass<T>, decoder: (Row, String) -> T?)

Registers a custom decoder: reads a column from a Row and returns a Kotlin value of type T.

Link copied to clipboard
fun <T : Any> registerEncoder(klass: KClass<T>, encoder: (T) -> Any?)

Registers a custom encoder: converts a Kotlin value of type T to a driver-compatible value.