protected static void writeList()

in athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/BlockUtils.java [504:546]


    protected static void writeList(BufferAllocator allocator,
            FieldWriter writer,
            Field field,
            int pos,
            Iterator value,
            FieldResolver resolver)
    {
        //Apache Arrow List types have a single 'special' child field which gives us the concrete type of the values
        //stored in the list.
        Field child = null;
        if (field.getChildren() != null && !field.getChildren().isEmpty()) {
            child = field.getChildren().get(0);
        }

        //Mark the beginning of the list, this is essentially how Apache Arrow handles the variable length nature
        //of lists.
        writer.startList();

        Iterator itr = value;
        while (itr.hasNext()) {
            //For each item in the iterator, attempt to write it to the list.
            Object val = itr.next();
            if (val != null) {
                switch (Types.getMinorTypeForArrowType(child.getType())) {
                    case LIST:
                        try {
                            writeList(allocator, (FieldWriter) writer.list(), child, pos, ((List) val).iterator(), resolver);
                        }
                        catch (Exception ex) {
                            throw ex;
                        }
                        break;
                    case STRUCT:
                        writeStruct(allocator, writer.struct(), child, pos, val, resolver);
                        break;
                    default:
                        writeListValue(writer, child.getType(), allocator, val);
                        break;
                }
            }
        }
        writer.endList();
    }