Package org.apache.avro
Class Resolver
java.lang.Object
org.apache.avro.Resolver
Encapsulate schema-resolution logic in an easy-to-consume representation. See
resolve(org.apache.avro.Schema, org.apache.avro.Schema, org.apache.avro.generic.GenericData)
and also the separate document entitled
refactoring-resolution for more information. It might also be
helpful to study ResolvingGrammarGenerator
as an example of how to use this class.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An abstract class for an action to be taken to resolve a writer's schema (found in public instance variable writer) against a reader's schema (in reader).static class
Used for array and map schemas: the public instance variable elementAction contains the resolving action needed for the element type of an array or value top of a map.static class
In this case, there's nothing to be done for resolution: the two schemas are effectively the same.static class
Contains information needed to resolve enumerations.static class
In this case there is an error.static class
In this case, the writer's type needs to be promoted to the reader's.static class
In this case, the reader is a union and the writer is not.static class
Instructions for resolving two record schemas.static class
This only appears insideResolver.RecordAdjust.fieldActions
, i.e., the actions for adjusting the fields of a record.static class
In this case, the writer was a union. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Resolver.Action
Uses GenericData.get() for the data param.static Resolver.Action
resolve
(Schema writer, Schema reader, GenericData data) Returns aResolver.Action
tree for resolving the writer schema writer and the reader schema reader.
-
Constructor Details
-
Resolver
public Resolver()
-
-
Method Details
-
resolve
Returns aResolver.Action
tree for resolving the writer schema writer and the reader schema reader. This method walks the reader's and writer's schemas together, generating an appropriate subclass ofResolver.Action
to encapsulate the information needed to resolve the corresponding parts of each schema tree. For convenience, everyResolver.Action
object has a pointer to the corresponding parts of the reader's and writer's trees being resolved by the action. Each subclass ofResolver.Action
has additional information needed for different types of schema, e.g., theResolver.EnumAdjust
subclass has information about re-ordering and deletion of enumeration symbols, whileResolver.RecordAdjust
has information about re-ordering and deletion of record fields. Note that aliases are applied to the writer's schema before resolution actually takes place. This means that the writer field of the resultingResolver.Action
objects will not be the same schema as provided to this method. However, the reader field will be.- Parameters:
writer
- The schema used by the writerreader
- The schema used by the readerdata
- Used for getDefaultValue and getting conversions- Returns:
- Nested actions for resolving the two
-
resolve
Uses GenericData.get() for the data param.
-