Skip to content

Commit

Permalink
Merge pull request #237 from Chuckame/docs
Browse files Browse the repository at this point in the history
fix: Update docs
  • Loading branch information
Chuckame authored Jul 11, 2024
2 parents 34c32bb + 76d0134 commit 143d6a9
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 67 deletions.
24 changes: 23 additions & 1 deletion Migrating-from-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ val genericData: Any? = Avro.encodeToGenericData(TheDataClass(...))
Avro.decodeFromGenericData<TheDataClass>(genericData)
```


## Configure the `Avro` instance

```kotlin
Expand Down Expand Up @@ -115,3 +114,26 @@ Files.newOutputStream(Path("/your/file.avro")).use { outputStream ->
}
```

## Writing a collection of Byte as BYTES or FIXED

If you really want to encode a `BYTES` type, just use the `ByteArray` type or write your own `AvroSerializer` to control the schema and its serialization.

For encoding to `FIXED`, then just use the `ByteArray` type with the `AvroFixed` annotation (or still write your own serializer).

```kotlin
// Previously
@Serializable
data class TheDataClass(
val collectionOfBytes: List<Byte>,
val listOfBytes: List<Byte>,
val setOfBytes: List<Byte>,
)

// Now
@Serializable
data class TheDataClass(
val collectionOfBytes: ByteArray,
val listOfBytes: ByteArray,
val setOfBytes: ByteArray,
)
```
Loading

0 comments on commit 143d6a9

Please sign in to comment.