public class Resolver extends Object
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.Modifier and Type | Class and Description |
---|---|
static class |
Resolver.Action
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 |
Resolver.Container
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 |
Resolver.DoNothing
In this case, there's nothing to be done for resolution: the two schemas are
effectively the same.
|
static class |
Resolver.EnumAdjust
Contains information needed to resolve enumerations.
|
static class |
Resolver.ErrorAction
In this case there is an error.
|
static class |
Resolver.Promote
In this case, the writer's type needs to be promoted to the reader's.
|
static class |
Resolver.ReaderUnion
In this case, the reader is a union and the writer is not.
|
static class |
Resolver.RecordAdjust
Instructions for resolving two record schemas.
|
static class |
Resolver.Skip
This only appears inside
Resolver.RecordAdjust.fieldActions , i.e., the actions
for adjusting the fields of a record. |
static class |
Resolver.WriterUnion
In this case, the writer was a union.
|
Constructor and Description |
---|
Resolver() |
Modifier and Type | Method and Description |
---|---|
static Resolver.Action |
resolve(Schema writer,
Schema reader)
Uses GenericData.get() for the data param.
|
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. |
public static Resolver.Action resolve(Schema writer, Schema reader, GenericData data)
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.writer
- The schema used by the writerreader
- The schema used by the readerdata
- Used for getDefaultValue and getting conversionspublic static Resolver.Action resolve(Schema writer, Schema reader)
Copyright © 2009–2022 The Apache Software Foundation. All rights reserved.