Skip to content

Commit

Permalink
Update Migrating-from-v1.md
Browse files Browse the repository at this point in the history
Co-authored-by: Chuckame <Chuckame@users.noreply.github.com>
  • Loading branch information
rutkowskij and Chuckame authored Oct 3, 2024
1 parent 5f351b0 commit 329823e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Migrating-from-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,17 @@ Avro.default.openInputStream(serializer) { decodeFormat = AvroDecodeFormat.Binar
.from(data).use { avroInputStream -> return avroInputStream.nextOrThrow() }

// Now
val reader = GenericDatumReader<Any>(schema)
val decoder = DecoderFactory.get().binaryDecoder(ByteArrayInputStream(data), null)
Avro.decodeFromGenericData(schema, serializer, reader.read(null, decoder))
val inputStream = ByteArrayInputStream(data)
while (inputStream.remaining() > 0) {
// If the writer schema corresponds to the specified type
val element = Avro.decodeFromStream<MyType>(inputStream)

// If the writer schema does not correspond to the specified type
val element = Avro.decodeFromStream<MyType>(writerSchema, inputStream)

// With explicit writer schema and serializer
val element = Avro.decodeFromStream(writerSchema, serializer, inputStream)
}
```

## Writing a collection of Byte as BYTES or FIXED
Expand Down

0 comments on commit 329823e

Please sign in to comment.