use of org.apache.drill.exec.store.easy.json.parser.ElementParser in project drill by apache.
the class BaseFieldFactory method buildOuterArrays.
/**
* Create layers of repeated list listeners around the type-specific
* array. If the JSON has three array levels, the outer two are repeated
* lists, the inner is type-specific: say an array of {@code BIGINT} or
* a map array.
*/
public ElementParser buildOuterArrays(ObjectWriter writer, int dims, Function<ObjectWriter, ElementParser> innerCreator) {
ObjectWriter[] writers = new ObjectWriter[dims];
writers[0] = writer;
for (int i = 1; i < dims; i++) {
writers[i] = writers[i - 1].array().entry();
}
ElementParser prevElementParser = innerCreator.apply(writers[dims - 1]);
for (int i = dims - 2; i >= 0; i--) {
prevElementParser = parserFactory().arrayValueParser(new StructureArrayListener(writers[i].array()), prevElementParser);
}
return prevElementParser;
}
use of org.apache.drill.exec.store.easy.json.parser.ElementParser in project drill by apache.
the class ExtendedTypeFieldFactory method buildExtendedTypeParser.
private ElementParser buildExtendedTypeParser(FieldDefn fieldDefn) {
// Extended types are objects: { "$type": ... }
// Extended arrays are [ { "$type": ...
TokenIterator tokenizer = fieldDefn.tokenizer();
JsonToken token = tokenizer.requireNext();
ElementParser parser;
switch(token) {
case START_OBJECT:
parser = extendedTypeParserFor(fieldDefn, false);
break;
case START_ARRAY:
parser = arrayParserFor(fieldDefn);
break;
default:
parser = null;
}
tokenizer.unget(token);
return parser;
}
Aggregations