Package org.apache.avro.io.parsing
Class Symbol
java.lang.Object
org.apache.avro.io.parsing.Symbol
- Direct Known Subclasses:
Symbol.Alternative,Symbol.ImplicitAction,Symbol.IntCheckAction,Symbol.Repeater,Symbol.Root,Symbol.Sequence
Symbol is the base of all symbols (terminals and non-terminals) of the
grammar.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classstatic final classstatic classstatic classstatic enumstatic classstatic classprotected static classprotected static classstatic classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolfinal Symbol.Kindstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final SymbolThe terminal symbols for the grammar.final Symbol[]The production for this symbol.static final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbolstatic final Symbol -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSymbol(Symbol.Kind kind) Constructs a new symbol of the given kind kind.protectedSymbol(Symbol.Kind kind, Symbol[] production) -
Method Summary
Modifier and TypeMethodDescriptionstatic Symbol.DefaultStartActiondefaultStartAction(byte[] contents) static Symbol.EnumAdjustActionenumAdjustAction(int rsymCount, Object[] adj) static Symbol.EnumLabelsActionenumLabelsAction(List<String> symbols) For JSON.static Symbol.FieldAdjustActionfieldAdjustAction(int rindex, String fname, Set<String> aliases) static Symbol.FieldOrderActionfieldOrderAction(Schema.Field[] fields) flatten(Map<Symbol.Sequence, Symbol.Sequence> map, Map<Symbol.Sequence, List<org.apache.avro.io.parsing.Symbol.Fixup>> map2) intprotected static intflattenedSize(Symbol[] symbols, int start) Returns the amount of space required to flatten the given sub-array of symbols.static booleanReturns true if the Parser contains any Error symbol, indicating that it may fail for some inputs.static Symbol.IntCheckActionintCheckAction(int size) static Symbol.SkipActionskipAction(Symbol symToSkip) static Symbol.UnionAdjustActionunionAdjustAction(int rindex, Symbol sym) static Symbol.WriterUnionAction
-
Field Details
-
kind
-
production
The production for this symbol. If this symbol is a terminal this is null. Otherwise this holds the the sequence of the symbols that forms the production for this symbol. The sequence is in the reverse order of production. This is useful for easy copying onto parsing stack. Please note that this is a final. So the production for a symbol should be known before that symbol is constructed. This requirement cannot be met for those symbols which are recursive (e.g. a record that holds union a branch of which is the record itself). To resolve this problem, we initialize the symbol with an array of nulls. Later we fill the symbols. Not clean, but works. The other option is to not have this field a final. But keeping it final and thus keeping symbol immutable gives some comfort. See various generators how we generate records. -
NULL
The terminal symbols for the grammar. -
BOOLEAN
-
INT
-
LONG
-
FLOAT
-
DOUBLE
-
STRING
-
BYTES
-
FIXED
-
ENUM
-
UNION
-
ARRAY_START
-
ARRAY_END
-
MAP_START
-
MAP_END
-
ITEM_END
-
WRITER_UNION_ACTION
-
FIELD_ACTION
-
RECORD_START
-
RECORD_END
-
UNION_END
-
FIELD_END
-
DEFAULT_END_ACTION
-
MAP_KEY_MARKER
-
-
Constructor Details
-
Symbol
Constructs a new symbol of the given kind kind. -
Symbol
-
-
Method Details
-
flatten
public Symbol flatten(Map<Symbol.Sequence, Symbol.Sequence> map, Map<Symbol.Sequence, List<org.apache.avro.io.parsing.Symbol.Fixup>> map2) -
flattenedSize
public int flattenedSize() -
flattenedSize
Returns the amount of space required to flatten the given sub-array of symbols.- Parameters:
symbols- The array of input symbols.start- The index where the subarray starts.- Returns:
- The number of symbols that will be produced if one expands the given input.
-
hasErrors
Returns true if the Parser contains any Error symbol, indicating that it may fail for some inputs. -
intCheckAction
-
enumAdjustAction
-
writerUnionAction
-
skipAction
-
fieldAdjustAction
public static Symbol.FieldAdjustAction fieldAdjustAction(int rindex, String fname, Set<String> aliases) -
fieldOrderAction
-
defaultStartAction
-
unionAdjustAction
-
enumLabelsAction
For JSON.
-