Class Resolver

java.lang.Object
org.apache.avro.Resolver

public class Resolver extends Object
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.
  • Constructor Details

    • Resolver

      public Resolver()
  • Method Details

    • resolve

      public static Resolver.Action resolve(Schema writer, Schema reader, GenericData data)
      Returns a Resolver.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 of Resolver.Action to encapsulate the information needed to resolve the corresponding parts of each schema tree. For convenience, every Resolver.Action object has a pointer to the corresponding parts of the reader's and writer's trees being resolved by the action. Each subclass of Resolver.Action has additional information needed for different types of schema, e.g., the Resolver.EnumAdjust subclass has information about re-ordering and deletion of enumeration symbols, while Resolver.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 resulting Resolver.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 writer
      reader - The schema used by the reader
      data - Used for getDefaultValue and getting conversions
      Returns:
      Nested actions for resolving the two
    • resolve

      public static Resolver.Action resolve(Schema writer, Schema reader)
      Uses GenericData.get() for the data param.