-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
46 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/com/sksamuel/avro4k/arrow/OptionSerializer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.sksamuel.avro4k.arrow | ||
|
||
import arrow.core.Option | ||
import com.sksamuel.avro4k.decoder.ExtendedDecoder | ||
import com.sksamuel.avro4k.encoder.ExtendedEncoder | ||
import com.sksamuel.avro4k.serializer.AvroSerializer | ||
import kotlinx.serialization.Encoder | ||
import kotlinx.serialization.SerialDescriptor | ||
import kotlinx.serialization.Serializer | ||
import org.apache.avro.Schema | ||
import java.time.LocalDate | ||
|
||
//class Tuple2Serializer : AvroSerializer<Tuple2<*, *>>() { | ||
// | ||
// override fun encodeAvroValue(schema: Schema, encoder: ExtendedEncoder, obj: Tuple2<*, *>) { | ||
// } | ||
// | ||
// override fun decodeAvroValue(schema: Schema, decoder: ExtendedDecoder): Tuple2<*, *> { | ||
// TODO() | ||
// } | ||
// | ||
// override val descriptor: SerialDescriptor | ||
// get() = TODO() | ||
//} | ||
// | ||
|
||
@Serializer(forClass = Option::class) | ||
class OptionSerializer<A> : AvroSerializer<Option<A>>() { | ||
|
||
override fun encodeAvroValue(schema: Schema, encoder: ExtendedEncoder, obj: Option<A>) { | ||
} | ||
|
||
override fun decodeAvroValue(schema: Schema, decoder: ExtendedDecoder): Option<A> { | ||
} | ||
|
||
|
||
} |
46 changes: 0 additions & 46 deletions
46
src/main/kotlin/com/sksamuel/avro4k/arrow/Tuple2Serializer.kt
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/test/kotlin/com/sksamuel/avro4k/arrow/OptionSchemaTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.sksamuel.avro4k.arrow | ||
|
||
import arrow.core.Option | ||
import com.sksamuel.avro4k.Avro | ||
import io.kotlintest.shouldBe | ||
import io.kotlintest.specs.FunSpec | ||
import kotlinx.serialization.Serializable | ||
|
||
class OptionSchemaTest : FunSpec({ | ||
|
||
test("options of primitives as basic unions") { | ||
|
||
@Serializable | ||
data class Test(@Serializable(OptionSerializer::class) val b: Option<String>) | ||
|
||
val schema = Avro.default.schema(Test.serializer()) | ||
val expected = org.apache.avro.Schema.Parser().parse(javaClass.getResourceAsStream("/option.json")) | ||
schema shouldBe expected | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |