Top Description Fields Constructors Methods
org.apache.avro.io.parsing

public Class ResolvingGrammarGenerator

extends ValidatingGrammarGenerator
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, java.nio.charset.StandardCharsets, java.util.Arrays, .HashMap, .Iterator, .List, .Map, org.apache.avro.AvroTypeException, .Resolver, .Schema, .Schema.Field, org.apache.avro.io.Encoder, .EncoderFactory, org.apache.avro.util.internal.Accessor, .Accessor.ResolvingGrammarGeneratorAccessor, com.fasterxml.jackson.databind.JsonNode

The class that generates a resolving grammar to resolve between two schemas.

Field Summary

Modifier and TypeField and Description
private static EncoderFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
encode(Encoder
The encoder to encode into.
e
,
Schema
The schema for the object being encoded.
s
,
JsonNode
The Json node to encode.
n
)

Encodes the given Json node n on to the encoder e according to the schema s.

public final Symbol

Returns:

The start symbol for the resolving grammar
generate
(Schema
The schema used by the writer
writer
,
Schema
The schema used by the reader
reader
)

Resolves the writer schema writer and the reader schema reader and returns the start symbol for the grammar generated.

private Symbol

Returns:

The start symbol for the resolving grammar
generate
(Resolver.Action
The resolver to be implemented
action
,
Map<Object, Symbol>
The <Action> to symbol map of start symbols of resolving grammars so far.
seen
)

Takes a Resolver.Action for resolving two schemas and returns the start symbol for a grammar that implements that resolution.

private static byte[]

Returns:

The binary encoded version of n.
getBinary
(Schema
The schema for encoding
s
,
JsonNode
The Json node that has the value to be encoded.
n
)

Returns the Avro binary encoded version of n according to the schema s.

private Symbol
Inherited from org.apache.avro.io.parsing.ValidatingGrammarGenerator:
generategenerate

Field Detail

factoryback to summary
private static EncoderFactory factory

Constructor Detail

ResolvingGrammarGeneratorback to summary
public ResolvingGrammarGenerator()

Method Detail

encodeback to summary
public static void encode(Encoder e, Schema s, JsonNode n) throws IOException

Encodes the given Json node n on to the encoder e according to the schema s.

Parameters
e:Encoder

The encoder to encode into.

s:Schema

The schema for the object being encoded.

n:JsonNode

The Json node to encode.

generateback to summary
public final Symbol generate(Schema writer, Schema reader) throws IOException

Resolves the writer schema writer and the reader schema reader and returns the start symbol for the grammar generated.

Parameters
writer:Schema

The schema used by the writer

reader:Schema

The schema used by the reader

Returns:Symbol

The start symbol for the resolving grammar

generateback to summary
private Symbol generate(Resolver.Action action, Map<Object, Symbol> seen) throws IOException

Takes a Resolver.Action for resolving two schemas and returns the start symbol for a grammar that implements that resolution. If the action is for a record and there's already a symbol for that record in seen, then that symbol is returned. Otherwise a new symbol is generated and returned.

Parameters
action:Resolver.Action

The resolver to be implemented

seen:Map<Object, Symbol>

The <Action> to symbol map of start symbols of resolving grammars so far.

Returns:Symbol

The start symbol for the resolving grammar

getBinaryback to summary
private static byte[] getBinary(Schema s, JsonNode n) throws IOException

Returns the Avro binary encoded version of n according to the schema s.

Parameters
s:Schema

The schema for encoding

n:JsonNode

The Json node that has the value to be encoded.

Returns:byte[]

The binary encoded version of n.

simpleGenback to summary
private Symbol simpleGen(Schema s, Map<Object, Symbol> seen)