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
Nested ClassesModifier and TypeClassDescriptionstatic classAn 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 classUsed 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 classIn this case, there's nothing to be done for resolution: the two schemas are effectively the same.static classContains information needed to resolve enumerations.static classIn this case there is an error.static classIn this case, the writer's type needs to be promoted to the reader's.static classIn this case, the reader is a union and the writer is not.static classInstructions for resolving two record schemas.static classThis only appears insideResolver.RecordAdjust.fieldActions, i.e., the actions for adjusting the fields of a record.static classIn this case, the writer was a union. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Resolver.ActionUses GenericData.get() for the data param.static Resolver.Actionresolve(Schema writer, Schema reader, GenericData data) Returns aResolver.Actiontree for resolving the writer schema writer and the reader schema reader.
-
Constructor Details
-
Resolver
public Resolver()
-
-
Method Details
-
resolve
Returns aResolver.Actiontree 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.Actionto encapsulate the information needed to resolve the corresponding parts of each schema tree. For convenience, everyResolver.Actionobject has a pointer to the corresponding parts of the reader's and writer's trees being resolved by the action. Each subclass ofResolver.Actionhas additional information needed for different types of schema, e.g., theResolver.EnumAdjustsubclass has information about re-ordering and deletion of enumeration symbols, whileResolver.RecordAdjusthas 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.Actionobjects 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.
-