Class FieldParserFactory
java.lang.Object
org.apache.drill.exec.store.easy.json.parser.FieldParserFactory
Creates a field parser given a field description and an optional field
listener.
Parse position: { ... field : ^ ?
for a newly-seen field.
Constructs a value parser and its listeners by looking ahead
some number of tokens to "sniff" the type of the value. For
example:
foo: <value>
- Field valuefoo: [ <value> ]
- 1D array valuefoo: [ [<value> ] ]
- 2D array value- Etc.
There are two cases in which no type estimation is possible:
- The value is
null
, indicated byValueDef.JsonType.NULL
. - The value is an array, and the array is empty, indicated
by
ValueDef.JsonType.EMPTY
.
ValueDefFactory
handles syntactic type inference. The associated
listener enforces semantic rules. For example, if a schema is
available, and we know that field "x" must be an Integer, but
this class reports that it is an object, then the listener should
raise an exception.
Also, the parser cannot enforce type consistency. This method looks only at the first appearance of a value: a sample size of one. JSON allows anything. The listener must enforce semantic rules that say whether a different type is allowed for later values.
-
Constructor Summary
ConstructorDescriptionFieldParserFactory
(JsonStructureParser structParser, Function<JsonStructureParser, ObjectParser> parserFactory) -
Method Summary
Modifier and TypeMethodDescriptionarrayValueParser
(ArrayListener arrayListener, ElementParser elementParser) jsonTextParser
(ValueListener fieldListener) objectValueParser
(ObjectParser objParser) scalarArrayValueParser
(ArrayListener arrayListener, ElementParser elementParser) simpleValueParser
(ValueListener fieldListener) textValueParser
(ValueListener fieldListener)
-
Constructor Details
-
FieldParserFactory
public FieldParserFactory(JsonStructureParser structParser, Function<JsonStructureParser, ObjectParser> parserFactory)
-
-
Method Details
-
rootParser
-
ignoredFieldParser
-
jsonTextParser
-
simpleValueParser
-
textValueParser
-
scalarArrayValueParser
public ElementParser scalarArrayValueParser(ArrayListener arrayListener, ElementParser elementParser) -
arrayValueParser
-
objectValueParser
-