This annotation is used to disable generics in the encoding of a record's name.
AvroFixed overrides the schema type for a field or a value class so that the schema is set to org.apache.avro.Schema.Type.FIXED rather than whatever the default would be.
AvroFixed overrides the schema type for a field or a value class so that the schema is set to org.apache.avro.Schema.Type.FIXED rather than whatever the default would be.
This annotation can be used in the following ways:
- On a field, eg case class Foo(@AvroField(10) name: String)
which results in the field name
having schema type FIXED with
a size of 10.
- On a value type, eg @AvroField(7) case class Foo(name: String) extends AnyVal
which results in all usages of the value type having schema
FIXED with a size of 7 rather than the default.
AvroName allows the name used by Avro to be different from what is defined in code.
AvroName allows the name used by Avro to be different from what is defined in code.
For example, if a case class defines a field z, such as
case class Foo(z: String)
then normally this will be
serialized as an entry 'z' in the Avro Record.
However, if the field is annotated such as
case class Foo(@AvroName("x") z: String)
then the entry
in the Avro Record will be for 'x'.
Similarly for deserialization, if a field is annotated then the name that is looked up in the avro record will be the annotated name and not the field name in Scala.
The second example is with classes. If a class is annotated with @AvroName then the name used in the record schema will not be the classname but the annotated value.
This will also have an effect on serialization. For example, when decoding records into an Either, the decoder must decide if the value is a Left or a Right. It usually does this by comparing the name in the record to the classnames of the either types, but when annotated, it will compare the name in the record to the annotated value.
A Decoder is used to convert an Avro value, such as a GenericRecord, SpecificRecord, GenericFixed, EnumSymbol, or a basic JVM type, into a target Scala type.
A Decoder is used to convert an Avro value, such as a GenericRecord, SpecificRecord, GenericFixed, EnumSymbol, or a basic JVM type, into a target Scala type.
For example, a Decoder[String] would convert an input of type Utf8 - which is one of the ways Avro can encode strings - into a plain Java String.
Another example, a decoder for Option[String] would handle inputs of null by emitting a None, and a non-null input by wrapping the decoded value in a Some.
A final example is converting a GenericData.Array or a Java collection type into a Scala collection type.
An Encoder encodes a Scala value of type T into a compatible Avro value based on the given schema.
An Encoder encodes a Scala value of type T into a compatible Avro value based on the given schema.
For example, given a string, and a schema of type Schema.Type.STRING then the string would be encoded as an instance of Utf8, whereas the same string and a Schema.Type.FIXED would be encoded as an instance of GenericData.Fixed.
Another example is given a Scala enumeration value, and a schema of type Schema.Type.ENUM, the value would be encoded as an instance of GenericData.EnumSymbol.
Implements methods to retrieve a suitable record name and namespace for a given Scala type, taking into account type parameters and annotations.
Implements methods to retrieve a suitable record name and namespace for a given Scala type, taking into account type parameters and annotations.
the name of the scala class without type parameters. Eg, List[Int] would be List.
the name of the scala class with type parameters encoded,
Eg, List[Int] would be ListInt
usually the package name, or if the class is nested, then the package name + outer class
An implementation of org.apache.avro.generic.GenericContainer that is both a GenericRecord and a SpecificRecord.
A SchemaFor generates an Avro Schema for a Scala or Java type.
A SchemaFor generates an Avro Schema for a Scala or Java type.
For example, a String SchemaFor could return an instance of Schema.Type.STRING or Schema.Type.FIXED depending on the type required for Strings.
When we set a default on an avro field, the type must match the schema definition.
When we set a default on an avro field, the type must match the schema definition. For example, if our field has a schema of type Long, then the default must be a number value.
This class will accept an Avro encoded value and convert it to a suitable default type.
This annotation is used to disable generics in the encoding of a record's name.
Normally, the record name for a generic type is the name of the raw type, plus the actual type parameters. For example, a class Foo with type parameters Int and Boolean, would have a generated name of
FooInt_Boolean
When this annotation is present on a type, the name used in the schema will simply be the raw type, eg
Foo
.