-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from Chuckame/anything-root
feat: Support everything at root level
- Loading branch information
Showing
80 changed files
with
2,411 additions
and
1,714 deletions.
There are no files selected for viewing
38 changes: 0 additions & 38 deletions
38
src/main/kotlin/com/github/avrokotlin/avro4k/AnnotationExtractor.kt
This file was deleted.
Oops, something went wrong.
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
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
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
25 changes: 0 additions & 25 deletions
25
src/main/kotlin/com/github/avrokotlin/avro4k/SerialDescriptor.kt
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/main/kotlin/com/github/avrokotlin/avro4k/decoder/ArrayDecoder.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,46 @@ | ||
package com.github.avrokotlin.avro4k.decoder | ||
|
||
import com.github.avrokotlin.avro4k.Avro | ||
import com.github.avrokotlin.avro4k.internal.DecodedNullError | ||
import com.github.avrokotlin.avro4k.internal.IllegalIndexedAccessError | ||
import kotlinx.serialization.descriptors.SerialDescriptor | ||
import org.apache.avro.Schema | ||
|
||
internal class ArrayDecoder( | ||
private val collection: Collection<Any?>, | ||
private val writerSchema: Schema, | ||
override val avro: Avro, | ||
) : AvroTaggedDecoder<Schema>() { | ||
private val iterator = collection.iterator() | ||
private val elementType = if (writerSchema.type == Schema.Type.BYTES) writerSchema else writerSchema.elementType | ||
|
||
private var currentItem: Any? = null | ||
private var decodedNullMark = false | ||
|
||
override val Schema.writerSchema: Schema | ||
get() = this@ArrayDecoder.elementType | ||
|
||
override fun SerialDescriptor.getTag(index: Int): Schema { | ||
return elementType | ||
} | ||
|
||
override fun decodeTaggedNotNullMark(tag: Schema): Boolean { | ||
decodedNullMark = true | ||
currentItem = iterator.next() | ||
return currentItem != null | ||
} | ||
|
||
override fun decodeTaggedValue(tag: Schema): Any { | ||
val value = if (decodedNullMark) currentItem else iterator.next() | ||
decodedNullMark = false | ||
return value ?: throw DecodedNullError() | ||
} | ||
|
||
override fun decodeElementIndex(descriptor: SerialDescriptor): Int { | ||
throw IllegalIndexedAccessError() | ||
} | ||
|
||
override fun decodeCollectionSize(descriptor: SerialDescriptor) = collection.size | ||
|
||
override fun decodeSequentially() = true | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/com/github/avrokotlin/avro4k/decoder/AvroDecoder.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,15 @@ | ||
package com.github.avrokotlin.avro4k.decoder | ||
|
||
import kotlinx.serialization.encoding.Decoder | ||
import org.apache.avro.Schema | ||
import org.apache.avro.generic.GenericFixed | ||
|
||
interface AvroDecoder : Decoder { | ||
val currentWriterSchema: Schema | ||
|
||
fun decodeBytes(): ByteArray | ||
|
||
fun decodeFixed(): GenericFixed | ||
|
||
fun decodeValue(): Any | ||
} |
Oops, something went wrong.