use of org.apache.drill.exec.store.easy.json.parser.TokenIterator 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;
}
use of org.apache.drill.exec.store.easy.json.parser.TokenIterator in project drill by apache.
the class ExtendedTypeFieldFactory method extendedTypeParserFor.
private BaseExtendedValueParser extendedTypeParserFor(FieldDefn fieldDefn, boolean isArray) {
TokenIterator tokenizer = fieldDefn.tokenizer();
JsonToken token = tokenizer.peek();
if (token != JsonToken.FIELD_NAME) {
return null;
}
String key = tokenizer.textValue().trim();
if (!key.startsWith(ExtendedTypeNames.TYPE_PREFIX)) {
return null;
}
return parserFor(fieldDefn, key, isArray);
}
use of org.apache.drill.exec.store.easy.json.parser.TokenIterator in project drill by apache.
the class ExtendedTypeFieldFactory method arrayParserFor.
private ElementParser arrayParserFor(FieldDefn fieldDefn) {
TokenIterator tokenizer = fieldDefn.tokenizer();
JsonToken token = tokenizer.requireNext();
if (token != JsonToken.START_OBJECT) {
tokenizer.unget(token);
return null;
}
ValueParser element = extendedTypeParserFor(fieldDefn, true);
tokenizer.unget(token);
if (element == null) {
return null;
}
return scalarArrayParserFor(element);
}
Aggregations