Skip to content

Commit

Permalink
make AvroBinaryInputStream backward compatible (#817)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Berndt <[email protected]>
  • Loading branch information
mberndt123 and mberndt123 authored Jan 23, 2024
1 parent 77e44c3 commit 2beb8cb
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import scala.util.Try
* @see https://avro.apache.org/docs/current/spec.html#binary_encoding
*/
class AvroBinaryInputStream[T](in: InputStream,
writerSchema: Schema)
writerSchema: Schema,
readerSchema: Schema)
(using decoder: Decoder[T]) extends AvroInputStream[T] {

private val datumReader = GenericData.get.createDatumReader(writerSchema).asInstanceOf[DatumReader[Any]]
def this(in: InputStream, writerSchema: Schema)(using decoder: Decoder[T]) = this(in, writerSchema, writerSchema)

private val datumReader = new GenericDatumReader[Any](writerSchema, readerSchema, GenericData.get)
private val avroDecoder = DecoderFactory.get().binaryDecoder(in, null)
private val decodeT = decoder.decode(writerSchema)
private val decodeT = decoder.decode(readerSchema)

private val _iter = new Iterator[Any] {
override def hasNext: Boolean = !avroDecoder.isEnd
Expand Down

0 comments on commit 2beb8cb

Please sign in to comment.