Search in sources :

Example 1 with TokenIterator

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;
}
Also used : TokenIterator(org.apache.drill.exec.store.easy.json.parser.TokenIterator) JsonToken(com.fasterxml.jackson.core.JsonToken) ElementParser(org.apache.drill.exec.store.easy.json.parser.ElementParser)

Example 2 with TokenIterator

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);
}
Also used : TokenIterator(org.apache.drill.exec.store.easy.json.parser.TokenIterator) JsonToken(com.fasterxml.jackson.core.JsonToken)

Example 3 with TokenIterator

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);
}
Also used : TokenIterator(org.apache.drill.exec.store.easy.json.parser.TokenIterator) ValueParser(org.apache.drill.exec.store.easy.json.parser.ValueParser) JsonToken(com.fasterxml.jackson.core.JsonToken)

Aggregations

JsonToken (com.fasterxml.jackson.core.JsonToken)3 TokenIterator (org.apache.drill.exec.store.easy.json.parser.TokenIterator)3 ElementParser (org.apache.drill.exec.store.easy.json.parser.ElementParser)1 ValueParser (org.apache.drill.exec.store.easy.json.parser.ValueParser)1