Search in sources :

Example 1 with StructureArrayListener

use of org.apache.drill.exec.store.easy.json.loader.SimpleArrayListener.StructureArrayListener 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;
}
Also used : StructureArrayListener(org.apache.drill.exec.store.easy.json.loader.SimpleArrayListener.StructureArrayListener) ObjectWriter(org.apache.drill.exec.vector.accessor.ObjectWriter) ElementParser(org.apache.drill.exec.store.easy.json.parser.ElementParser)

Aggregations

StructureArrayListener (org.apache.drill.exec.store.easy.json.loader.SimpleArrayListener.StructureArrayListener)1 ElementParser (org.apache.drill.exec.store.easy.json.parser.ElementParser)1 ObjectWriter (org.apache.drill.exec.vector.accessor.ObjectWriter)1