AvroCodec

dev.constructive.eo.avro.AvroCodec
See theAvroCodec companion trait
object AvroCodec

Attributes

Companion
trait
Source
AvroCodec.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
AvroCodec.type

Members list

Value members

Concrete methods

def decodeRecord(bytes: Array[Byte], schema: Schema): Either[AvroFailure, IndexedRecord]

Binary-decode bytes under schema to a generic record — no typed codec involved. Catches apache-avro's binary-decoder throws (IOException / EOFException / AvroRuntimeException) into AvroFailure.BinaryParseFailed.

Binary-decode bytes under schema to a generic record — no typed codec involved. Catches apache-avro's binary-decoder throws (IOException / EOFException / AvroRuntimeException) into AvroFailure.BinaryParseFailed.

Attributes

Source
AvroCodec.scala
def decodeResolvedRecord(bytes: Array[Byte], readSchema: Schema, writeSchema: Schema): Either[AvroFailure, IndexedRecord]

Binary-decode bytes (encoded under readSchema) and RESOLVE them into writeSchema via apache-avro's schema resolution (reorder / default / promotion / aliases) — the drift counterpart of decodeRecord (which assumes one schema). Named from the reader's point of view: readSchema is the schema the bytes are read in, writeSchema the shape they resolve into (what you'd write). In apache-avro's own vocabulary these are the writer schema and the reader schema respectively — hence GenericDatumReader(readSchema, writeSchema) below. Incompatible schemas → AvroFailure.ResolveFailed.

Binary-decode bytes (encoded under readSchema) and RESOLVE them into writeSchema via apache-avro's schema resolution (reorder / default / promotion / aliases) — the drift counterpart of decodeRecord (which assumes one schema). Named from the reader's point of view: readSchema is the schema the bytes are read in, writeSchema the shape they resolve into (what you'd write). In apache-avro's own vocabulary these are the writer schema and the reader schema respectively — hence GenericDatumReader(readSchema, writeSchema) below. Incompatible schemas → AvroFailure.ResolveFailed.

Attributes

Source
AvroCodec.scala
def decodeResolvedValue[A](bytes: Array[Byte], readSchema: Schema)(using codec: AvroCodec[A]): Either[AvroFailure, A]

decodeResolvedRecord resolving readSchemacodec's schema (the write schema), then the codec's Any ⇒ A side — the drift counterpart of decodeValue.

decodeResolvedRecord resolving readSchemacodec's schema (the write schema), then the codec's Any ⇒ A side — the drift counterpart of decodeValue.

Attributes

Source
AvroCodec.scala
def decodeValue[A](bytes: Array[Byte])(using codec: AvroCodec[A]): Either[AvroFailure, A]

decodeRecord under codec's schema, then the codec's Any ⇒ A side — AvroFailure.DecodeFailed when the parsed record doesn't line up with A.

decodeRecord under codec's schema, then the codec's Any ⇒ A side — AvroFailure.DecodeFailed when the parsed record doesn't line up with A.

Attributes

Source
AvroCodec.scala
def encodeRecord(datum: Any, schema: Schema): Either[AvroFailure, Array[Byte]]

Binary-encode an already-Any-shaped datum under schema — the write-side counterpart of decodeRecord. GenericDatumWriter throws AvroTypeException / NullPointerException / ClassCastException when the datum doesn't line up with the schema; caught into AvroFailure.EncodeFailed.

Binary-encode an already-Any-shaped datum under schema — the write-side counterpart of decodeRecord. GenericDatumWriter throws AvroTypeException / NullPointerException / ClassCastException when the datum doesn't line up with the schema; caught into AvroFailure.EncodeFailed.

Attributes

Source
AvroCodec.scala
def encodeValue[A](value: A)(using codec: AvroCodec[A]): Either[AvroFailure, Array[Byte]]

The codec's A ⇒ Any side, then encodeRecord under codec's schema.

The codec's A ⇒ Any side, then encodeRecord under codec's schema.

Attributes

Source
AvroCodec.scala

Givens

Givens

given default: AvroConfig

Default project-wide kindlings config: identity field-name transform, no namespace override, no decimal config. Users can shadow this with their own given AvroConfig if they need a snake-cased schema or a forced namespace.

Default project-wide kindlings config: identity field-name transform, no namespace override, no decimal config. Users can shadow this with their own given AvroConfig if they need a snake-cased schema or a forced namespace.

Attributes

Source
AvroCodec.scala
given derived: [A] => (AvroEncoder[A], AvroDecoder[A], AvroSchemaFor[A]) => AvroCodec[A]

Combine kindlings' derived AvroEncoder[A] / AvroDecoder[A] / AvroSchemaFor[A] into a single AvroCodec. Each kindlings typeclass is summoned independently, so this works whether the user has hand-written one of the sides or used kindlings' macro derivation for both.

Combine kindlings' derived AvroEncoder[A] / AvroDecoder[A] / AvroSchemaFor[A] into a single AvroCodec. Each kindlings typeclass is summoned independently, so this works whether the user has hand-written one of the sides or used kindlings' macro derivation for both.

Attributes

Source
AvroCodec.scala